1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-09 13:50:00 +00:00

layout changes to the sorting code

This commit is contained in:
Mitchell Livingston 2008-01-31 00:40:37 +00:00
parent f77717cffa
commit 008ce2fcfe

View file

@ -1668,80 +1668,71 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
NSArray * descriptors;
if ([sortType isEqualToString: SORT_ORDER])
descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
else if ([sortType isEqualToString: SORT_NAME])
{
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: asc
selector: @selector(caseInsensitiveCompare:)] autorelease];
descriptors = [[NSArray alloc] initWithObjects: nameDescriptor, orderDescriptor, nil];
}
else if ([sortType isEqualToString: SORT_STATE])
{
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: asc
selector: @selector(caseInsensitiveCompare:)] autorelease],
* stateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"stateSortKey" ascending: !asc] autorelease],
* progressDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"progress" ascending: !asc] autorelease],
* ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"ratio" ascending: !asc] autorelease];
descriptors = [[NSArray alloc] initWithObjects: stateDescriptor, progressDescriptor, ratioDescriptor,
nameDescriptor, orderDescriptor, nil];
}
else if ([sortType isEqualToString: SORT_PROGRESS])
{
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: asc
selector: @selector(caseInsensitiveCompare:)] autorelease],
* progressDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"progress" ascending: asc] autorelease],
* ratioProgressDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"progressStopRatio"
ascending: asc] autorelease],
* ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"ratio" ascending: asc] autorelease];
descriptors = [[NSArray alloc] initWithObjects: progressDescriptor, ratioProgressDescriptor, ratioDescriptor,
nameDescriptor, orderDescriptor, nil];
}
else if ([sortType isEqualToString: SORT_TRACKER])
{
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: asc
selector: @selector(caseInsensitiveCompare:)] autorelease],
* trackerDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"trackerAddress" ascending: asc
selector: @selector(caseInsensitiveCompare:)] autorelease];
descriptors = [[NSArray alloc] initWithObjects: trackerDescriptor, nameDescriptor, orderDescriptor, nil];
}
else if ([sortType isEqualToString: SORT_ACTIVITY])
{
NSSortDescriptor * rateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"totalRate" ascending: !asc] autorelease];
NSSortDescriptor * activityDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"dateActivityOrAdd" ascending: !asc]
autorelease];
descriptors = [[NSArray alloc] initWithObjects: rateDescriptor, activityDescriptor, orderDescriptor, nil];
}
else
{
if ([sortType isEqualToString: SORT_NAME])
{
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: asc
selector: @selector(caseInsensitiveCompare:)] autorelease];
descriptors = [[NSArray alloc] initWithObjects: nameDescriptor, orderDescriptor, nil];
}
else if ([sortType isEqualToString: SORT_STATE])
{
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: asc
selector: @selector(caseInsensitiveCompare:)] autorelease],
* stateDescriptor = [[[NSSortDescriptor alloc] initWithKey:
@"stateSortKey" ascending: !asc] autorelease],
* progressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
@"progress" ascending: !asc] autorelease],
* ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey:
@"ratio" ascending: !asc] autorelease];
descriptors = [[NSArray alloc] initWithObjects: stateDescriptor, progressDescriptor, ratioDescriptor,
nameDescriptor, orderDescriptor, nil];
}
else if ([sortType isEqualToString: SORT_PROGRESS])
{
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: asc
selector: @selector(caseInsensitiveCompare:)] autorelease],
* progressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
@"progress" ascending: asc] autorelease],
* ratioProgressDescriptor = [[[NSSortDescriptor alloc] initWithKey:
@"progressStopRatio" ascending: asc] autorelease],
* ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey:
@"ratio" ascending: asc] autorelease];
descriptors = [[NSArray alloc] initWithObjects: progressDescriptor, ratioProgressDescriptor, ratioDescriptor,
nameDescriptor, orderDescriptor, nil];
}
else if ([sortType isEqualToString: SORT_TRACKER])
{
NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: asc
selector: @selector(caseInsensitiveCompare:)] autorelease],
* trackerDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"trackerAddress"
ascending: asc selector: @selector(caseInsensitiveCompare:)] autorelease];
descriptors = [[NSArray alloc] initWithObjects: trackerDescriptor, nameDescriptor, orderDescriptor, nil];
}
else if ([sortType isEqualToString: SORT_ACTIVITY])
{
NSSortDescriptor * rateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"totalRate" ascending: !asc]
autorelease];
NSSortDescriptor * activityDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"dateActivityOrAdd" ascending: !asc]
autorelease];
descriptors = [[NSArray alloc] initWithObjects: rateDescriptor, activityDescriptor, orderDescriptor, nil];
}
else
{
NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"dateAdded" ascending: asc] autorelease];
NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"dateAdded" ascending: asc] autorelease];
descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, orderDescriptor, nil];
}
//on Tiger add the group sort descriptor to the front
if (![NSApp isOnLeopardOrBetter] && [fDefaults boolForKey: @"SortByGroup"])
{
NSSortDescriptor * groupDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"groupOrderValue" ascending: YES] autorelease];
descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, orderDescriptor, nil];
}
NSMutableArray * temp = [[NSMutableArray alloc] initWithCapacity: [descriptors count]+1];
[temp addObject: groupDescriptor];
[temp addObjectsFromArray: descriptors];
if (![NSApp isOnLeopardOrBetter] && [fDefaults boolForKey: @"SortByGroup"])
{
NSSortDescriptor * groupDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"groupOrderValue"
ascending: YES] autorelease];
NSMutableArray * temp = [[NSMutableArray alloc] initWithCapacity: [descriptors count]+1];
[temp addObject: groupDescriptor];
[temp addObjectsFromArray: descriptors];
[descriptors release];
descriptors = temp;
}
[descriptors release];
descriptors = temp;
}
//actually sort