From 1043035ce4d2ae8f3006bf91623d85b0dc3d1d65 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Mon, 14 Aug 2006 23:18:49 +0000 Subject: [PATCH] Peer table always sorts by ip address after sorting by whatever column is selected. --- macosx/InfoWindowController.h | 2 ++ macosx/InfoWindowController.m | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/macosx/InfoWindowController.h b/macosx/InfoWindowController.h index ad85999bc..cd324843d 100644 --- a/macosx/InfoWindowController.h +++ b/macosx/InfoWindowController.h @@ -66,4 +66,6 @@ - (void) setWaitToStart: (id) sender; +- (NSArray *) peerSortDescriptors; + @end diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index ffd859ad7..e6f0bbb1f 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -265,7 +265,7 @@ if (numberSelected == 1) { [fPeers setArray: [[fTorrents objectAtIndex: 0] peers]]; - [fPeers sortUsingDescriptors: [fPeerTable sortDescriptors]]; + [fPeers sortUsingDescriptors: [self peerSortDescriptors]]; } else [fPeers removeAllObjects]; @@ -470,7 +470,7 @@ { if (tableView == fPeerTable) { - [fPeers sortUsingDescriptors: [tableView sortDescriptors]]; + [fPeers sortUsingDescriptors: [self peerSortDescriptors]]; [tableView reloadData]; } } @@ -488,6 +488,20 @@ return tableView == fFileTable ? [fFiles objectAtIndex: row] : nil; } +- (NSArray *) peerSortDescriptors +{ + NSMutableArray * descriptors = [NSMutableArray array]; + + NSArray * oldDescriptors = [fPeerTable sortDescriptors]; + if ([oldDescriptors count] > 0) + [descriptors addObject: [oldDescriptors objectAtIndex: 0]]; + + [descriptors addObject: [[[fPeerTable tableColumns] objectAtIndex: [fPeerTable columnWithIdentifier: @"IP"]] + sortDescriptorPrototype]]; + + return descriptors; +} + - (void) revealFile: (id) sender { NSIndexSet * indexSet = [fFileTable selectedRowIndexes];