1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

sort groups by their order in the table

This commit is contained in:
Mitchell Livingston 2007-12-17 20:10:51 +00:00
parent 17682552ec
commit 0fc13c3d6a
5 changed files with 22 additions and 1 deletions

View file

@ -1741,7 +1741,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
if (!sortByOrder && [fDefaults boolForKey: @"SortByGroup"]) if (!sortByOrder && [fDefaults boolForKey: @"SortByGroup"])
{ {
NSSortDescriptor * groupDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"groupValue" ascending: asc] autorelease]; NSSortDescriptor * groupDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"groupOrderValue" ascending: asc] autorelease];
NSMutableArray * temp = [[NSMutableArray alloc] initWithCapacity: [descriptors count]+1]; NSMutableArray * temp = [[NSMutableArray alloc] initWithCapacity: [descriptors count]+1];
[temp addObject: groupDescriptor]; [temp addObject: groupDescriptor];

View file

@ -39,6 +39,8 @@
+ (GroupsWindowController *) groupsController; + (GroupsWindowController *) groupsController;
- (CTGradient *) gradientForIndex: (int) index; - (CTGradient *) gradientForIndex: (int) index;
- (int) orderValueForIndex: (int) index;
- (void) addRemoveGroup: (id) sender; - (void) addRemoveGroup: (id) sender;
- (NSMenu *) groupMenuWithTarget: (id) target action: (SEL) action; - (NSMenu *) groupMenuWithTarget: (id) target action: (SEL) action;

View file

@ -138,6 +138,18 @@ GroupsWindowController * fGroupsWindowInstance = nil;
return nil; return nil;
} }
- (int) orderValueForIndex: (int) index
{
if (index != -1)
{
int i;
for (i = 0; i < [fGroups count]; i++)
if (index == [[[fGroups objectAtIndex: i] objectForKey: @"Index"] intValue])
return i;
}
return -1;
}
- (NSInteger) numberOfRowsInTableView: (NSTableView *) tableview - (NSInteger) numberOfRowsInTableView: (NSTableView *) tableview
{ {
return [fGroups count]; return [fGroups count];

View file

@ -210,6 +210,7 @@ typedef enum
- (int) groupValue; - (int) groupValue;
- (void) setGroupValue: (int) groupValue; - (void) setGroupValue: (int) groupValue;
- (int) groupOrderValue;
- (void) checkGroupValue: (NSNotification *) notification; - (void) checkGroupValue: (NSNotification *) notification;
- (NSArray *) fileList; - (NSArray *) fileList;

View file

@ -23,6 +23,7 @@
*****************************************************************************/ *****************************************************************************/
#import "Torrent.h" #import "Torrent.h"
#import "GroupsWindowController.h"
#import "NSApplicationAdditions.h" #import "NSApplicationAdditions.h"
#import "NSStringAdditions.h" #import "NSStringAdditions.h"
@ -1196,6 +1197,11 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
fGroupValue = goupValue; fGroupValue = goupValue;
} }
- (int) groupOrderValue
{
return [[GroupsWindowController groupsController] orderValueForIndex: fGroupValue];
}
- (void) checkGroupValue: (NSNotification *) notification - (void) checkGroupValue: (NSNotification *) notification
{ {
if (fGroupValue != -1 && [[[notification userInfo] objectForKey: @"Indexes"] containsIndex: fGroupValue]) if (fGroupValue != -1 && [[[notification userInfo] objectForKey: @"Indexes"] containsIndex: fGroupValue])