sort ratio separate from progress
This commit is contained in:
parent
a7c4c4474b
commit
29bf2677ec
|
@ -1304,17 +1304,22 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
NSSortDescriptor * stateDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
NSSortDescriptor * stateDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
||||||
@"stateSortKey" ascending: NO] autorelease],
|
@"stateSortKey" ascending: NO] autorelease],
|
||||||
* progressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
* 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];
|
nameDescriptor, orderDescriptor, nil];
|
||||||
}
|
}
|
||||||
else if ([fSortType isEqualToString: @"Progress"])
|
else if ([fSortType isEqualToString: @"Progress"])
|
||||||
{
|
{
|
||||||
NSSortDescriptor * progressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
|
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"])
|
else if ([fSortType isEqualToString: @"Date"])
|
||||||
{
|
{
|
||||||
|
|
|
@ -184,5 +184,6 @@
|
||||||
- (NSDate *) date;
|
- (NSDate *) date;
|
||||||
- (NSNumber *) stateSortKey;
|
- (NSNumber *) stateSortKey;
|
||||||
- (NSNumber *) progressSortKey;
|
- (NSNumber *) progressSortKey;
|
||||||
|
- (NSNumber *) ratioSortKey;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -1097,9 +1097,16 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
|
|
||||||
- (NSNumber *) progressSortKey
|
- (NSNumber *) progressSortKey
|
||||||
{
|
{
|
||||||
//if finished downloading sort by ratio instead of progress
|
return [NSNumber numberWithFloat: [self progress]];
|
||||||
float progress = [self progress];
|
}
|
||||||
return [NSNumber numberWithFloat: ![self allDownloaded] ? progress : 100.0 + [self ratio]];
|
|
||||||
|
- (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
|
@end
|
||||||
|
|
Loading…
Reference in New Issue