1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-04 02:28:03 +00:00

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

This commit is contained in:
Mitchell Livingston 2008-02-07 01:26:12 +00:00
parent 864c563ba1
commit 015f40e498
3 changed files with 38 additions and 2 deletions

View file

@ -1912,7 +1912,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[fDisplayedTorrents sortUsingDescriptors: [NSArray arrayWithObject: groupDescriptor]];
NSMutableArray * groups = [NSMutableArray array], * groupTorrents;
int i, oldGroupValue = -2;
int oldGroupValue = -2;
for (i = 0; i < [fDisplayedTorrents count]; i++)
{
Torrent * torrent = [fDisplayedTorrents objectAtIndex: i];
@ -1937,6 +1937,22 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
[self sortTorrentsIgnoreSelected];
[fTableView selectValues: selectedValues];
//reset expanded/collapsed rows
if (groupRows && [fDisplayedTorrents count] > 0 && [NSApp isOnLeopardOrBetter])
{
NSIndexSet * collapsed = [fTableView collapsedGroupsIndexes];
enumerator = [fDisplayedTorrents objectEnumerator];
NSDictionary * dict;
while ((dict = [enumerator nextObject]))
{
int value = [[dict objectForKey: @"Group"] intValue];
if ([collapsed containsIndex: value >= 0 ? value : INT_MAX])
[fTableView collapseItem: dict];
else
[fTableView expandItem: dict];
}
}
[self setBottomCountTextFiltering: groupRows || filterStatus || filterGroup || filterText];
[self setWindowSizeToFit];

View file

@ -33,7 +33,7 @@
@interface TorrentTableView : NSOutlineView
{
IBOutlet Controller * fController;
NSIndexSet * fGroupIndexes;
NSMutableIndexSet * fCollapsedGroups;
TorrentCell * fTorrentCell;
@ -51,6 +51,8 @@
NSTimer * fPiecesBarTimer;
}
- (NSIndexSet *) collapsedGroupsIndexes;
- (void) removeButtonTrackingAreas;
- (void) setControlButtonHover: (int) row;
- (void) setRevealButtonHover: (int) row;

View file

@ -61,6 +61,8 @@
if (![NSApp isOnLeopardOrBetter])
[[self tableColumnWithIdentifier: @"Torrent"] setDataCell: fTorrentCell];
fCollapsedGroups = [[NSMutableIndexSet alloc] init];
fMouseControlRow = -1;
fMouseRevealRow = -1;
fMouseActionRow = -1;
@ -76,6 +78,8 @@
- (void) dealloc
{
[fCollapsedGroups release];
[fPiecesBarTimer invalidate];
[fMenuTorrent release];
@ -86,6 +90,11 @@
[super dealloc];
}
- (NSIndexSet *) collapsedGroupsIndexes
{
return fCollapsedGroups;
}
- (BOOL) outlineView: (NSOutlineView *) outlineView isGroupItem: (id) item
{
return ![item isKindOfClass: [Torrent class]];
@ -247,11 +256,17 @@
- (void) outlineViewItemDidExpand: (NSNotification *) notification
{
int value = [[[[notification userInfo] objectForKey: @"NSObject"] objectForKey: @"Group"] intValue];
[fCollapsedGroups removeIndex: value >= 0 ? value : INT_MAX];
[[NSNotificationCenter defaultCenter] postNotificationName: @"OutlineExpandCollapse" object: self];
}
- (void) outlineViewItemDidCollapse: (NSNotification *) notification
{
int value = [[[[notification userInfo] objectForKey: @"NSObject"] objectForKey: @"Group"] intValue];
[fCollapsedGroups addIndex: value >= 0 ? value : INT_MAX];
[[NSNotificationCenter defaultCenter] postNotificationName: @"OutlineExpandCollapse" object: self];
}
@ -322,7 +337,10 @@
{
id tableItem = [self itemAtRow: i];
if (![tableItem isKindOfClass: [Torrent class]] && [[tableItem objectForKey: @"Group"] intValue] == group)
{
[indexSet addIndex: i];
break;
}
}
}
}