Changeset 4935


Ignore:
Timestamp:
Feb 7, 2008, 1:26:12 AM (14 years ago)
Author:
livings124
Message:

initial saving of collapsed/expanded groups when switching filters, adding torrents, etc

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r4930 r4935  
    19131913       
    19141914        NSMutableArray * groups = [NSMutableArray array], * groupTorrents;
    1915         int i, oldGroupValue = -2;
     1915        int oldGroupValue = -2;
    19161916        for (i = 0; i < [fDisplayedTorrents count]; i++)
    19171917        {
     
    19371937    [self sortTorrentsIgnoreSelected];
    19381938    [fTableView selectValues: selectedValues];
     1939   
     1940    //reset expanded/collapsed rows
     1941    if (groupRows && [fDisplayedTorrents count] > 0 && [NSApp isOnLeopardOrBetter])
     1942    {
     1943        NSIndexSet * collapsed = [fTableView collapsedGroupsIndexes];
     1944        enumerator = [fDisplayedTorrents objectEnumerator];
     1945        NSDictionary * dict;
     1946        while ((dict = [enumerator nextObject]))
     1947        {
     1948            int value = [[dict objectForKey: @"Group"] intValue];
     1949            if ([collapsed containsIndex: value >= 0 ? value : INT_MAX])
     1950                [fTableView collapseItem: dict];
     1951            else
     1952                [fTableView expandItem: dict];
     1953        }
     1954    }
    19391955   
    19401956    [self setBottomCountTextFiltering: groupRows || filterStatus || filterGroup || filterText];
  • trunk/macosx/TorrentTableView.h

    r4930 r4935  
    3434{
    3535    IBOutlet Controller * fController;
    36     NSIndexSet * fGroupIndexes;
     36    NSMutableIndexSet * fCollapsedGroups;
    3737   
    3838    TorrentCell * fTorrentCell;
     
    5151    NSTimer * fPiecesBarTimer;
    5252}
     53
     54- (NSIndexSet *) collapsedGroupsIndexes;
    5355
    5456- (void) removeButtonTrackingAreas;
  • trunk/macosx/TorrentTableView.m

    r4930 r4935  
    6262            [[self tableColumnWithIdentifier: @"Torrent"] setDataCell: fTorrentCell];
    6363       
     64        fCollapsedGroups = [[NSMutableIndexSet alloc] init];
     65       
    6466        fMouseControlRow = -1;
    6567        fMouseRevealRow = -1;
     
    7779- (void) dealloc
    7880{
     81    [fCollapsedGroups release];
     82   
    7983    [fPiecesBarTimer invalidate];
    8084    [fMenuTorrent release];
     
    8589   
    8690    [super dealloc];
     91}
     92
     93- (NSIndexSet *) collapsedGroupsIndexes
     94{
     95    return fCollapsedGroups;
    8796}
    8897
     
    248257- (void) outlineViewItemDidExpand: (NSNotification *) notification
    249258{
     259    int value = [[[[notification userInfo] objectForKey: @"NSObject"] objectForKey: @"Group"] intValue];
     260    [fCollapsedGroups removeIndex: value >= 0 ? value : INT_MAX];
     261   
    250262    [[NSNotificationCenter defaultCenter] postNotificationName: @"OutlineExpandCollapse" object: self];
    251263}
     
    253265- (void) outlineViewItemDidCollapse: (NSNotification *) notification
    254266{
     267    int value = [[[[notification userInfo] objectForKey: @"NSObject"] objectForKey: @"Group"] intValue];
     268    [fCollapsedGroups addIndex: value >= 0 ? value : INT_MAX];
     269   
    255270    [[NSNotificationCenter defaultCenter] postNotificationName: @"OutlineExpandCollapse" object: self];
    256271}
     
    323338                id tableItem = [self itemAtRow: i];
    324339                if (![tableItem isKindOfClass: [Torrent class]] && [[tableItem objectForKey: @"Group"] intValue] == group)
     340                {
    325341                    [indexSet addIndex: i];
     342                    break;
     343                }
    326344            }
    327345        }
Note: See TracChangeset for help on using the changeset viewer.