diff --git a/macosx/Controller.m b/macosx/Controller.m index 9dfab4f4b..bfc996d3f 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1304,17 +1304,22 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy NSSortDescriptor * stateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"stateSortKey" ascending: NO] autorelease], * progressDescriptor = [[[NSSortDescriptor alloc] initWithKey: - @"progressSortKey" ascending: NO] autorelease]; + @"progressSortKey" ascending: NO] autorelease], + * ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey: + @"ratioSortKey" ascending: NO] autorelease]; - descriptors = [[NSArray alloc] initWithObjects: stateDescriptor, progressDescriptor, + descriptors = [[NSArray alloc] initWithObjects: stateDescriptor, progressDescriptor, ratioDescriptor, nameDescriptor, orderDescriptor, nil]; } else if ([fSortType isEqualToString: @"Progress"]) { NSSortDescriptor * progressDescriptor = [[[NSSortDescriptor alloc] initWithKey: - @"progressSortKey" ascending: YES] autorelease]; + @"progressSortKey" ascending: YES] autorelease], + * ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey: + @"ratioSortKey" ascending: YES] autorelease]; - descriptors = [[NSArray alloc] initWithObjects: progressDescriptor, nameDescriptor, orderDescriptor, nil]; + descriptors = [[NSArray alloc] initWithObjects: progressDescriptor, ratioDescriptor, + nameDescriptor, orderDescriptor, nil]; } else if ([fSortType isEqualToString: @"Date"]) { diff --git a/macosx/Torrent.h b/macosx/Torrent.h index e0ff0226e..1e2deca3a 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -184,5 +184,6 @@ - (NSDate *) date; - (NSNumber *) stateSortKey; - (NSNumber *) progressSortKey; +- (NSNumber *) ratioSortKey; @end diff --git a/macosx/Torrent.m b/macosx/Torrent.m index e1bda0904..9641b630d 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -1097,9 +1097,16 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 - (NSNumber *) progressSortKey { - //if finished downloading sort by ratio instead of progress - float progress = [self progress]; - return [NSNumber numberWithFloat: ![self allDownloaded] ? progress : 100.0 + [self ratio]]; + return [NSNumber numberWithFloat: [self progress]]; +} + +- (NSNumber *) ratioSortKey +{ + float ratio = [self ratio]; + if (ratio == TR_RATIO_INF) + return [NSNumber numberWithInt: 999999999]; //this should hopefully be big enough + else + return [NSNumber numberWithFloat: [self ratio]]; } @end