mirror of
https://github.com/transmission/transmission
synced 2025-03-12 07:03:44 +00:00
better encapsulate the collapsed group values
This commit is contained in:
parent
940ac6a52a
commit
dd0bf1fa8f
4 changed files with 14 additions and 16 deletions
|
@ -1948,19 +1948,16 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
||||||
[fTableView selectValues: selectedValues];
|
[fTableView selectValues: selectedValues];
|
||||||
|
|
||||||
//reset expanded/collapsed rows
|
//reset expanded/collapsed rows
|
||||||
#warning redo to not require storing an indexset?
|
|
||||||
if (groupRows && [fDisplayedTorrents count] > 0 && [NSApp isOnLeopardOrBetter])
|
if (groupRows && [fDisplayedTorrents count] > 0 && [NSApp isOnLeopardOrBetter])
|
||||||
{
|
{
|
||||||
NSIndexSet * collapsed = [fTableView collapsedGroupsIndexes];
|
|
||||||
enumerator = [fDisplayedTorrents objectEnumerator];
|
enumerator = [fDisplayedTorrents objectEnumerator];
|
||||||
NSDictionary * dict;
|
NSDictionary * dict;
|
||||||
while ((dict = [enumerator nextObject]))
|
while ((dict = [enumerator nextObject]))
|
||||||
{
|
{
|
||||||
int value = [[dict objectForKey: @"Group"] intValue];
|
if ([fTableView isGroupCollapsed: [[dict objectForKey: @"Group"] intValue]])
|
||||||
if ([collapsed containsIndex: value >= 0 ? value : INT_MAX])
|
|
||||||
[fTableView collapseItem: dict];
|
|
||||||
else
|
|
||||||
[fTableView expandItem: dict];
|
[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
|
- (void) setGroup: (id) sender
|
||||||
{
|
{
|
||||||
NSIndexSet * collapsedGroupsIndexes = [fTableView collapsedGroupsIndexes];
|
|
||||||
|
|
||||||
NSEnumerator * enumerator = [[fTableView selectedTorrents] objectEnumerator];
|
NSEnumerator * enumerator = [[fTableView selectedTorrents] objectEnumerator];
|
||||||
Torrent * torrent;
|
Torrent * torrent;
|
||||||
while ((torrent = [enumerator nextObject]))
|
while ((torrent = [enumerator nextObject]))
|
||||||
|
|
|
@ -459,8 +459,6 @@
|
||||||
|
|
||||||
BOOL minimal = [fDefaults boolForKey: @"SmallView"];
|
BOOL minimal = [fDefaults boolForKey: @"SmallView"];
|
||||||
|
|
||||||
#warning use inset instead of edges
|
|
||||||
|
|
||||||
//group coloring
|
//group coloring
|
||||||
NSRect iconRect = [self iconRectForBounds: cellFrame];
|
NSRect iconRect = [self iconRectForBounds: cellFrame];
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
NSTimer * fPiecesBarTimer;
|
NSTimer * fPiecesBarTimer;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSIndexSet *) collapsedGroupsIndexes;
|
- (BOOL) isGroupCollapsed: (int) value;
|
||||||
- (void) removeCollapsedGroup: (int) value;
|
- (void) removeCollapsedGroup: (int) value;
|
||||||
- (void) removeAllCollapsedGroups;
|
- (void) removeAllCollapsedGroups;
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#import "NSApplicationAdditions.h"
|
#import "NSApplicationAdditions.h"
|
||||||
#import "NSMenuAdditions.h"
|
#import "NSMenuAdditions.h"
|
||||||
|
|
||||||
|
#define MAX_GROUP (INT_MAX-100)
|
||||||
|
|
||||||
#define ACTION_MENU_GLOBAL_TAG 101
|
#define ACTION_MENU_GLOBAL_TAG 101
|
||||||
#define ACTION_MENU_UNLIMITED_TAG 102
|
#define ACTION_MENU_UNLIMITED_TAG 102
|
||||||
#define ACTION_MENU_LIMIT_TAG 103
|
#define ACTION_MENU_LIMIT_TAG 103
|
||||||
|
@ -90,15 +92,18 @@
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSIndexSet *) collapsedGroupsIndexes
|
- (BOOL) isGroupCollapsed: (int) value
|
||||||
{
|
{
|
||||||
return fCollapsedGroups;
|
if (value < 0)
|
||||||
|
value = MAX_GROUP;
|
||||||
|
|
||||||
|
return [fCollapsedGroups containsIndex: value];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) removeCollapsedGroup: (int) value
|
- (void) removeCollapsedGroup: (int) value
|
||||||
{
|
{
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
value = INT_MAX;
|
value = MAX_GROUP;
|
||||||
|
|
||||||
[fCollapsedGroups removeIndex: value];
|
[fCollapsedGroups removeIndex: value];
|
||||||
}
|
}
|
||||||
|
@ -270,7 +275,7 @@
|
||||||
- (void) outlineViewItemDidExpand: (NSNotification *) notification
|
- (void) outlineViewItemDidExpand: (NSNotification *) notification
|
||||||
{
|
{
|
||||||
int value = [[[[notification userInfo] objectForKey: @"NSObject"] objectForKey: @"Group"] intValue];
|
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];
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"OutlineExpandCollapse" object: self];
|
||||||
}
|
}
|
||||||
|
@ -278,7 +283,7 @@
|
||||||
- (void) outlineViewItemDidCollapse: (NSNotification *) notification
|
- (void) outlineViewItemDidCollapse: (NSNotification *) notification
|
||||||
{
|
{
|
||||||
int value = [[[[notification userInfo] objectForKey: @"NSObject"] objectForKey: @"Group"] intValue];
|
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];
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"OutlineExpandCollapse" object: self];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue