Changeset 566


Ignore:
Timestamp:
Jul 13, 2006, 12:32:00 AM (16 years ago)
Author:
livings124
Message:

remember selected rows correctly when filtering

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r565 r566  
    957957- (void) applyFilter
    958958{
     959    //remember selected rows if needed
     960    NSArray * selectedTorrents = nil;
     961    int numSelected = [fTableView numberOfSelectedRows];
     962    if (numSelected > 0 && numSelected < [fFilteredTorrents count])
     963        selectedTorrents = [self torrentsAtIndexes: [fTableView selectedRowIndexes]];
     964
    959965    NSMutableArray * tempTorrents = [[NSMutableArray alloc] initWithCapacity: [fTorrents count]];
    960966
     
    990996   
    991997    [self sortTorrents];
     998   
     999    //set selected rows if needed...this selecting is more accurate than sort's
     1000    if (selectedTorrents)
     1001    {
     1002        Torrent * torrent;
     1003        NSEnumerator * enumerator = [selectedTorrents objectEnumerator];
     1004        NSMutableIndexSet * indexSet = [[NSMutableIndexSet alloc] init];
     1005        unsigned index;
     1006        while ((torrent = [enumerator nextObject]))
     1007            if ((index = [fFilteredTorrents indexOfObject: torrent]) != NSNotFound)
     1008                [indexSet addIndex: index];
     1009       
     1010        [fTableView selectRowIndexes: indexSet byExtendingSelection: NO];
     1011        [indexSet release];
     1012    }
    9921013}
    9931014
Note: See TracChangeset for help on using the changeset viewer.