diff --git a/macosx/Controller.m b/macosx/Controller.m index 8abbde99d..74d22e0b5 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1741,7 +1741,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi 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]; [temp addObject: groupDescriptor]; diff --git a/macosx/GroupsWindowController.h b/macosx/GroupsWindowController.h index 83fbba092..5cc7d9526 100644 --- a/macosx/GroupsWindowController.h +++ b/macosx/GroupsWindowController.h @@ -39,6 +39,8 @@ + (GroupsWindowController *) groupsController; - (CTGradient *) gradientForIndex: (int) index; +- (int) orderValueForIndex: (int) index; + - (void) addRemoveGroup: (id) sender; - (NSMenu *) groupMenuWithTarget: (id) target action: (SEL) action; diff --git a/macosx/GroupsWindowController.m b/macosx/GroupsWindowController.m index e91cd88e2..64aed7420 100644 --- a/macosx/GroupsWindowController.m +++ b/macosx/GroupsWindowController.m @@ -138,6 +138,18 @@ GroupsWindowController * fGroupsWindowInstance = 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 { return [fGroups count]; diff --git a/macosx/Torrent.h b/macosx/Torrent.h index 451aca247..935d6df91 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -210,6 +210,7 @@ typedef enum - (int) groupValue; - (void) setGroupValue: (int) groupValue; +- (int) groupOrderValue; - (void) checkGroupValue: (NSNotification *) notification; - (NSArray *) fileList; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 406dcc4c8..33dd9ea9c 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -23,6 +23,7 @@ *****************************************************************************/ #import "Torrent.h" +#import "GroupsWindowController.h" #import "NSApplicationAdditions.h" #import "NSStringAdditions.h" @@ -1196,6 +1197,11 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void * fGroupValue = goupValue; } +- (int) groupOrderValue +{ + return [[GroupsWindowController groupsController] orderValueForIndex: fGroupValue]; +} + - (void) checkGroupValue: (NSNotification *) notification { if (fGroupValue != -1 && [[[notification userInfo] objectForKey: @"Indexes"] containsIndex: fGroupValue])