From dd0bf1fa8fe8fedf6638af574657ca154a5bda6b Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 7 Feb 2008 16:20:24 +0000 Subject: [PATCH] better encapsulate the collapsed group values --- macosx/Controller.m | 11 +++-------- macosx/TorrentCell.m | 2 -- macosx/TorrentTableView.h | 2 +- macosx/TorrentTableView.m | 15 ++++++++++----- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index 7c37f552b..98068d3e0 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1948,19 +1948,16 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi [fTableView selectValues: selectedValues]; //reset expanded/collapsed rows - #warning redo to not require storing an indexset? 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 + if ([fTableView isGroupCollapsed: [[dict objectForKey: @"Group"] intValue]]) [fTableView expandItem: dict]; + else + [fTableView collapseItem: dict]; } } @@ -2155,8 +2152,6 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi - (void) setGroup: (id) sender { - NSIndexSet * collapsedGroupsIndexes = [fTableView collapsedGroupsIndexes]; - NSEnumerator * enumerator = [[fTableView selectedTorrents] objectEnumerator]; Torrent * torrent; while ((torrent = [enumerator nextObject])) diff --git a/macosx/TorrentCell.m b/macosx/TorrentCell.m index cae47284e..fd041c293 100644 --- a/macosx/TorrentCell.m +++ b/macosx/TorrentCell.m @@ -459,8 +459,6 @@ BOOL minimal = [fDefaults boolForKey: @"SmallView"]; - #warning use inset instead of edges - //group coloring NSRect iconRect = [self iconRectForBounds: cellFrame]; diff --git a/macosx/TorrentTableView.h b/macosx/TorrentTableView.h index 1268d8417..269544482 100644 --- a/macosx/TorrentTableView.h +++ b/macosx/TorrentTableView.h @@ -51,7 +51,7 @@ NSTimer * fPiecesBarTimer; } -- (NSIndexSet *) collapsedGroupsIndexes; +- (BOOL) isGroupCollapsed: (int) value; - (void) removeCollapsedGroup: (int) value; - (void) removeAllCollapsedGroups; diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index 0fc0899c4..4da3e6433 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -28,6 +28,8 @@ #import "NSApplicationAdditions.h" #import "NSMenuAdditions.h" +#define MAX_GROUP (INT_MAX-100) + #define ACTION_MENU_GLOBAL_TAG 101 #define ACTION_MENU_UNLIMITED_TAG 102 #define ACTION_MENU_LIMIT_TAG 103 @@ -90,15 +92,18 @@ [super dealloc]; } -- (NSIndexSet *) collapsedGroupsIndexes +- (BOOL) isGroupCollapsed: (int) value { - return fCollapsedGroups; + if (value < 0) + value = MAX_GROUP; + + return [fCollapsedGroups containsIndex: value]; } - (void) removeCollapsedGroup: (int) value { if (value < 0) - value = INT_MAX; + value = MAX_GROUP; [fCollapsedGroups removeIndex: value]; } @@ -270,7 +275,7 @@ - (void) outlineViewItemDidExpand: (NSNotification *) notification { int value = [[[[notification userInfo] objectForKey: @"NSObject"] objectForKey: @"Group"] intValue]; - [fCollapsedGroups removeIndex: value >= 0 ? value : INT_MAX]; + [fCollapsedGroups removeIndex: value >= 0 ? value : MAX_GROUP]; [[NSNotificationCenter defaultCenter] postNotificationName: @"OutlineExpandCollapse" object: self]; } @@ -278,7 +283,7 @@ - (void) outlineViewItemDidCollapse: (NSNotification *) notification { int value = [[[[notification userInfo] objectForKey: @"NSObject"] objectForKey: @"Group"] intValue]; - [fCollapsedGroups addIndex: value >= 0 ? value : INT_MAX]; + [fCollapsedGroups addIndex: value >= 0 ? value : MAX_GROUP]; [[NSNotificationCenter defaultCenter] postNotificationName: @"OutlineExpandCollapse" object: self]; }