Changeset 5815
- Timestamp:
- May 12, 2008, 1:37:38 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.m
r5814 r5815 1540 1540 1541 1541 //sort torrents by order value 1542 NSArray * sortedTorrents;1543 1542 if ([fTorrents count] > 1 && (desiredDownloadActive > 0 || desiredSeedActive > 0)) 1544 1543 { 1545 1544 NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"orderValue" ascending: YES] autorelease]; 1546 sortedTorrents = [fTorrents sortedArrayUsingDescriptors: [NSArray arrayWithObject: orderDescriptor]]; 1547 } 1548 else 1549 sortedTorrents = fTorrents; 1545 [fTorrents sortUsingDescriptors: [NSArray arrayWithObject: orderDescriptor]]; 1546 } 1550 1547 1551 1548 Torrent * torrent; 1552 NSEnumerator * enumerator = [ sortedTorrents objectEnumerator];1549 NSEnumerator * enumerator = [fTorrents objectEnumerator]; 1553 1550 while ((torrent = [enumerator nextObject])) 1554 1551 { … … 2691 2688 //get all torrents to reorder 2692 2689 NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"orderValue" ascending: YES] autorelease]; 2693 NSMutableArray * sortedTorrents = [[fTorrents sortedArrayUsingDescriptors: 2694 [NSArray arrayWithObject: orderDescriptor]] mutableCopy]; 2690 [fTorrents sortUsingDescriptors: [NSArray arrayWithObject: orderDescriptor]]; 2695 2691 2696 2692 //remove objects to reinsert 2697 [ sortedTorrents removeObjectsInArray: movingTorrents];2693 [fTorrents removeObjectsInArray: movingTorrents]; 2698 2694 2699 2695 //insert objects at new location 2700 int insertIndex = topTorrent ? [ sortedTorrents indexOfObject: topTorrent] + 1 : 0;2696 int insertIndex = topTorrent ? [fTorrents indexOfObject: topTorrent] + 1 : 0; 2701 2697 for (i = 0; i < [movingTorrents count]; i++) 2702 [ sortedTorrents insertObject: [movingTorrents objectAtIndex: i] atIndex: insertIndex + i];2698 [fTorrents insertObject: [movingTorrents objectAtIndex: i] atIndex: insertIndex + i]; 2703 2699 2704 2700 //redo order values 2705 for (i = 0; i < [sortedTorrents count]; i++) 2706 [[sortedTorrents objectAtIndex: i] setOrderValue: i]; 2707 2708 [sortedTorrents release]; 2701 for (i = 0; i < [fTorrents count]; i++) 2702 [[fTorrents objectAtIndex: i] setOrderValue: i]; 2709 2703 2710 2704 [self applyFilter: nil];
Note: See TracChangeset
for help on using the changeset viewer.