From 02710f8092c4fc87ccd27601d0d6a6dfd51c1f16 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Fri, 11 May 2007 00:03:05 +0000 Subject: [PATCH] have the secondary sort alternate ascending/descending when the primary does --- macosx/InfoWindowController.m | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index 088796a02..4b907ef2a 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -869,10 +869,25 @@ NSMutableArray * descriptors = [NSMutableArray array]; NSArray * oldDescriptors = [fPeerTable sortDescriptors]; + BOOL useSecond = YES, asc = YES; if ([oldDescriptors count] > 0) - [descriptors addObject: [oldDescriptors objectAtIndex: 0]]; + { + NSSortDescriptor * descriptor = [oldDescriptors objectAtIndex: 0]; + [descriptors addObject: descriptor]; + + useSecond = ![[descriptor key] isEqualToString: @"IP"]; + asc = [descriptor ascending]; + } - [descriptors addObject: [[fPeerTable tableColumnWithIdentifier: @"IP"] sortDescriptorPrototype]]; + //sort by IP after primary sort + if (useSecond) + { + #warning different for different sorts + NSSortDescriptor * secondDescriptor = [[NSSortDescriptor alloc] initWithKey: @"IP" ascending: asc + selector: @selector(compareIP:)]; + [descriptors addObject: secondDescriptor]; + [secondDescriptor release]; + } return descriptors; }