Changeset 2053


Ignore:
Timestamp:
Jun 13, 2007, 12:11:01 AM (15 years ago)
Author:
livings124
Message:

add priority selector in file table

Location:
branches/file_selection/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/file_selection/macosx/English.lproj/InfoWindow.nib/info.nib

    r2033 r2053  
    2222        <key>IBOpenObjects</key>
    2323        <array>
    24                 <integer>549</integer>
    2524                <integer>5</integer>
    2625        </array>
  • branches/file_selection/macosx/InfoWindowController.m

    r2041 r2053  
    106106    [fFileOutline setDoubleAction: @selector(revealFile:)];
    107107   
     108    //set file outline
     109    NSSegmentedCell * priorityCell = [[fFileOutline tableColumnWithIdentifier: @"Priority"] dataCell];
     110    int i;
     111    for (i = 0; i < [priorityCell segmentCount]; i++)
     112    {
     113        [priorityCell setLabel: @"" forSegment: i];
     114        [priorityCell setWidth: 6.0 forSegment: i];
     115    }
     116   
    108117    //set blank inspector
    109118    [self updateInfoForTorrents: [NSArray array]];
     
    625634       
    626635        //determine which priorities are checked
    627         NSDictionary * item;
    628636        NSIndexSet * indexSet = [fFileOutline selectedRowIndexes];
    629637        BOOL current = NO, other = NO;
     
    643651                current = YES;
    644652            else
    645                 other = YES; 
     653                other = YES;
    646654        }
    647655       
    648656        [menuItem setState: current ? (other ? NSMixedState : NSOnState) : NSOffState];
    649        
    650657        return YES;
    651658    }
     
    842849}
    843850
    844 - (id) outlineView: (NSOutlineView *) outlineView objectValueForTableColumn: (NSTableColumn *) tableColumn
    845             byItem: (id) item
     851- (id) outlineView: (NSOutlineView *) outlineView objectValueForTableColumn: (NSTableColumn *) tableColumn byItem: (id) item
    846852{
    847853    if ([[tableColumn identifier] isEqualToString: @"Check"])
     
    860866            forTableColumn: (NSTableColumn *) tableColumn item: (id) item
    861867{
    862     if ([[tableColumn identifier] isEqualToString: @"Name"])
    863     {
    864         BOOL isFolder;
    865         if ((isFolder = [[item objectForKey: @"IsFolder"] boolValue]))
     868    NSString * identifier = [tableColumn identifier];
     869    if ([identifier isEqualToString: @"Name"])
     870    {
     871        if ([[item objectForKey: @"IsFolder"] boolValue])
    866872            [cell setImage: nil];
    867873        else
     
    872878        }
    873879    }
    874     else if ([[tableColumn identifier] isEqualToString: @"Check"])
     880    else if ([identifier isEqualToString: @"Check"])
    875881    {
    876882        Torrent * torrent = [fTorrents objectAtIndex: 0];
     
    880886            [cell setEnabled: [torrent canChangeDownloadCheckFile: [[item objectForKey: @"Index"] intValue]]];
    881887    }
     888    else if ([identifier isEqualToString: @"Priority"])
     889    {
     890        Torrent * torrent = [fTorrents objectAtIndex: 0];
     891        [(NSSegmentedCell *)cell setSelected: [torrent hasFilePriority: PRIORITY_LOW forItem: item] forSegment: 0];
     892        [(NSSegmentedCell *)cell setSelected: [torrent hasFilePriority: PRIORITY_NORMAL forItem: item] forSegment: 1];
     893        [(NSSegmentedCell *)cell setSelected: [torrent hasFilePriority: PRIORITY_HIGH forItem: item] forSegment: 2];
     894    }
    882895    else;
    883896}
     
    886899        forTableColumn: (NSTableColumn *) tableColumn byItem: (id) item
    887900{
    888     Torrent * torrent = [fTorrents objectAtIndex: 0];
    889     int state = [object intValue] != NSOffState ? NSOnState : NSOffState;
    890    
    891     [torrent setFileCheckState: state forFileItem: item];
    892     [fFileOutline reloadData];
     901    NSString * identifier = [tableColumn identifier];
     902    if ([identifier isEqualToString: @"Check"])
     903    {
     904        [[fTorrents objectAtIndex: 0] setFileCheckState: [object intValue] != NSOffState ? NSOnState : NSOffState
     905                                        forFileItem: item];
     906        [fFileOutline reloadData];
     907    }
     908    else if ([identifier isEqualToString: @"Priority"])
     909    {
     910        int priority = [object intValue], actualPriority;
     911        if (priority == 0)
     912            actualPriority = PRIORITY_LOW;
     913        else if (priority == 2)
     914            actualPriority = PRIORITY_HIGH;
     915        else
     916            actualPriority = PRIORITY_NORMAL;
     917       
     918        [[fTorrents objectAtIndex: 0] setFilePriority: actualPriority forFileItem: item];
     919        [fFileOutline reloadData];
     920    }
     921    else;
    893922}
    894923
  • branches/file_selection/macosx/TorrentTableView.m

    r1969 r2053  
    240240    Torrent * torrent;
    241241    NSImage * image;
    242     NSRect buttonRect = NSMakeRect(0, 0, BUTTON_WIDTH, BUTTON_WIDTH);
    243242
    244243    [super drawRect: r];
     
    265264
    266265        if (image)
    267             [image compositeToPoint: NSMakePoint(rect.origin.x, NSMaxY(rect)) fromRect: buttonRect
    268                     operation: NSCompositeSourceOver];
     266            [image compositeToPoint: NSMakePoint(rect.origin.x, NSMaxY(rect)) operation: NSCompositeSourceOver];
    269267
    270268        rect = [self revealRectForRow: i];
    271269        image = NSPointInRect(fClickPoint, rect) ? fRevealOnIcon : fRevealOffIcon;
    272         [image compositeToPoint: NSMakePoint(rect.origin.x, NSMaxY(rect)) fromRect: buttonRect
    273                     operation: NSCompositeSourceOver];
     270        [image compositeToPoint: NSMakePoint(rect.origin.x, NSMaxY(rect)) operation: NSCompositeSourceOver];
    274271    }
    275272}
Note: See TracChangeset for help on using the changeset viewer.