sort ratio separate from progress

This commit is contained in:
Mitchell Livingston 2007-01-15 04:41:01 +00:00
parent a7c4c4474b
commit 29bf2677ec
3 changed files with 20 additions and 7 deletions

View File

@ -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"])
{

View File

@ -184,5 +184,6 @@
- (NSDate *) date;
- (NSNumber *) stateSortKey;
- (NSNumber *) progressSortKey;
- (NSNumber *) ratioSortKey;
@end

View File

@ -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