From a06c1ace830c54a974d6c599c2ba71f9eb8ef547 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 7 Feb 2008 21:26:04 +0000 Subject: [PATCH] save collapsed groups between launches --- macosx/Controller.m | 1 + macosx/TorrentTableView.h | 1 + macosx/TorrentTableView.m | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index 1801a0287..f94609779 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -580,6 +580,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi //save history [self updateTorrentHistory]; + [fTableView saveCollapsedGroups]; //remaining calls the same as dealloc [fInfoController release]; diff --git a/macosx/TorrentTableView.h b/macosx/TorrentTableView.h index 33f29fb2e..6be0693f7 100644 --- a/macosx/TorrentTableView.h +++ b/macosx/TorrentTableView.h @@ -55,6 +55,7 @@ - (BOOL) isGroupCollapsed: (int) value; - (void) removeCollapsedGroup: (int) value; - (void) removeAllCollapsedGroups; +- (void) saveCollapsedGroups; - (void) removeButtonTrackingAreas; - (void) setControlButtonHover: (int) row; diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index 0426c43e1..0afe32d22 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -63,7 +63,11 @@ if (![NSApp isOnLeopardOrBetter]) [[self tableColumnWithIdentifier: @"Torrent"] setDataCell: fTorrentCell]; - fCollapsedGroups = [[NSMutableIndexSet alloc] init]; + NSData * groupData = [fDefaults dataForKey: @"CollapsedGroups"]; + if (groupData) + fCollapsedGroups = [[NSUnarchiver unarchiveObjectWithData: groupData] retain]; + else + fCollapsedGroups = [[NSMutableIndexSet alloc] init]; fMouseControlRow = -1; fMouseRevealRow = -1; @@ -113,6 +117,11 @@ [fCollapsedGroups removeAllIndexes]; } +- (void) saveCollapsedGroups +{ + [fDefaults setObject: [NSArchiver archivedDataWithRootObject: fCollapsedGroups] forKey: @"CollapsedGroups"]; +} + - (BOOL) outlineView: (NSOutlineView *) outlineView isGroupItem: (id) item { return ![item isKindOfClass: [Torrent class]];