no need to check and set selected twice

This commit is contained in:
Mitchell Livingston 2006-07-13 00:39:46 +00:00
parent 19336396f3
commit 3a1621cf84
2 changed files with 13 additions and 4 deletions

View File

@ -126,6 +126,7 @@
- (void) updateTorrentHistory;
- (void) sortTorrents;
- (void) sortTorrentsChangeSelected: (BOOL) changeSelected;
- (void) setSort: (id) sender;
- (void) applyFilter;
- (void) setFilter: (id) sender;

View File

@ -855,12 +855,20 @@ static void sleepCallBack(void * controller, io_service_t y,
}
- (void) sortTorrents
{
[self sortTorrentsChangeSelected: YES];
}
- (void) sortTorrentsChangeSelected: (BOOL) changeSelected
{
//remember selected rows if needed
NSArray * selectedTorrents = nil;
int numSelected = [fTableView numberOfSelectedRows];
if (numSelected > 0 && numSelected < [fFilteredTorrents count])
selectedTorrents = [self torrentsAtIndexes: [fTableView selectedRowIndexes]];
if (changeSelected)
{
int numSelected = [fTableView numberOfSelectedRows];
if (numSelected > 0 && numSelected < [fFilteredTorrents count])
selectedTorrents = [self torrentsAtIndexes: [fTableView selectedRowIndexes]];
}
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey:
@"name" ascending: YES] autorelease],
@ -994,7 +1002,7 @@ static void sleepCallBack(void * controller, io_service_t y,
[fFilteredTorrents setArray: tempTorrents];
[tempTorrents release];
[self sortTorrents];
[self sortTorrentsChangeSelected: NO];
//set selected rows if needed...this selecting is more accurate than sort's
if (selectedTorrents)