Ignore:
Timestamp:
Jun 21, 2007, 10:36:01 PM (15 years ago)
Author:
livings124
Message:

add a menu item in the context menu to only check selected (and uncheck others)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r2172 r2178  
    601601- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
    602602{
     603    if ([fTorrents count] != 1)
     604        return NO;
     605   
    603606    SEL action = [menuItem action];
    604607   
     
    627630    }
    628631   
     632    if (action == @selector(setOnlySelectedCheck:))
     633        return [fFileOutline selectedRow] != -1;
     634   
    629635    if (action == @selector(setPriority:))
    630636    {
     
    10231029   
    10241030    Torrent * torrent = [fTorrents objectAtIndex: 0];
    1025     NSIndexSet * indexSet = [fFileOutline selectedRowIndexes], * itemIndexes;
    1026     NSMutableIndexSet * usedIndexes = [NSMutableIndexSet indexSet];
     1031    NSIndexSet * indexSet = [fFileOutline selectedRowIndexes];
     1032    NSMutableIndexSet * itemIndexes = [NSMutableIndexSet indexSet];
    10271033    int i;
    10281034    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    1029     {
    1030         itemIndexes = [[fFileOutline itemAtRow: i] objectForKey: @"Indexes"];
    1031         if (![usedIndexes containsIndexes: itemIndexes])
    1032         {
    1033             [torrent setFileCheckState: state forIndexes: itemIndexes];
    1034             [usedIndexes addIndexes: itemIndexes];
    1035         }
    1036     }
     1035        [itemIndexes addIndexes: [[fFileOutline itemAtRow: i] objectForKey: @"Indexes"]];
     1036   
     1037    [torrent setFileCheckState: state forIndexes: itemIndexes];
     1038    [fFileOutline reloadData];
     1039}
     1040
     1041- (void) setOnlySelectedCheck: (id) sender
     1042{
     1043    Torrent * torrent = [fTorrents objectAtIndex: 0];
     1044    NSIndexSet * indexSet = [fFileOutline selectedRowIndexes];
     1045    NSMutableIndexSet * itemIndexes = [NSMutableIndexSet indexSet];
     1046    int i;
     1047    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
     1048        [itemIndexes addIndexes: [[fFileOutline itemAtRow: i] objectForKey: @"Indexes"]];
     1049   
     1050    [torrent setFileCheckState: NSOnState forIndexes: itemIndexes];
     1051   
     1052    NSMutableIndexSet * remainingItemIndexes = [NSMutableIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [torrent fileCount])];
     1053    [remainingItemIndexes removeIndexes: indexSet];
     1054    [torrent setFileCheckState: NSOffState forIndexes: remainingItemIndexes];
    10371055   
    10381056    [fFileOutline reloadData];
     
    10511069    Torrent * torrent = [fTorrents objectAtIndex: 0];
    10521070    NSIndexSet * indexSet = [fFileOutline selectedRowIndexes];
     1071    NSMutableIndexSet * itemIndexes = [NSMutableIndexSet indexSet];
    10531072    int i;
    10541073    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    1055         [torrent setFilePriority: priority forIndexes: [[fFileOutline itemAtRow: i] objectForKey: @"Indexes"]];
    1056    
     1074        [itemIndexes addIndexes: [[fFileOutline itemAtRow: i] objectForKey: @"Indexes"]];
     1075   
     1076    [torrent setFilePriority: priority forIndexes: itemIndexes];
    10571077    [fFileOutline reloadData];
    10581078}
Note: See TracChangeset for help on using the changeset viewer.