Changeset 7794
- Timestamp:
- Jan 24, 2009, 7:07:25 PM (12 years ago)
- Location:
- trunk/macosx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.m
r7757 r7794 842 842 if (add) 843 843 { 844 [torrent setOrderValue: [fTorrents count]]; //ensure that queue order is always sequential845 846 844 [torrent update]; 847 845 [fTorrents addObject: torrent]; … … 1217 1215 [fTorrents removeObjectsInArray: torrents]; 1218 1216 1219 NSInteger lowestOrderValue = NSIntegerMax;1220 1217 for (Torrent * torrent in torrents) 1221 1218 { … … 1228 1225 [torrent trashTorrent]; 1229 1226 1230 lowestOrderValue = MIN(lowestOrderValue, [torrent orderValue]);1231 1232 1227 [torrent closeRemoveTorrent]; 1233 1228 } 1234 1229 1235 1230 [torrents release]; 1236 1237 //reset the order values if necessary1238 if (lowestOrderValue < [fTorrents count])1239 {1240 for (NSInteger i = lowestOrderValue; i < [fTorrents count]; i++)1241 [[fTorrents objectAtIndex: i] setOrderValue: i];1242 }1243 1231 1244 1232 [fTableView deselectAll: nil]; … … 1723 1711 { 1724 1712 NSMutableArray * history = [NSMutableArray arrayWithCapacity: [fTorrents count]]; 1725 1713 1726 1714 for (Torrent * torrent in fTorrents) 1727 1715 [history addObject: [torrent history]]; 1728 1716 1729 1717 [history writeToFile: [NSHomeDirectory() stringByAppendingPathComponent: SUPPORT_FOLDER] atomically: YES]; 1730 1718 } … … 1797 1785 const BOOL asc = ![fDefaults boolForKey: @"SortReverse"]; 1798 1786 1799 NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"orderValue" ascending: asc] autorelease]; 1800 1801 NSArray * descriptors; 1802 if ([sortType isEqualToString: SORT_ORDER]) 1803 descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil]; 1804 else if ([sortType isEqualToString: SORT_NAME]) 1787 NSArray * descriptors = nil; 1788 if ([sortType isEqualToString: SORT_NAME]) 1805 1789 { 1806 1790 NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: asc 1807 1791 selector: @selector(compareFinder:)] autorelease]; 1808 1792 1809 descriptors = [[NSArray alloc] initWithObjects: nameDescriptor, orderDescriptor,nil];1793 descriptors = [[NSArray alloc] initWithObjects: nameDescriptor, nil]; 1810 1794 } 1811 1795 else if ([sortType isEqualToString: SORT_STATE]) … … 1818 1802 1819 1803 descriptors = [[NSArray alloc] initWithObjects: stateDescriptor, progressDescriptor, ratioDescriptor, 1820 nameDescriptor, orderDescriptor,nil];1804 nameDescriptor, nil]; 1821 1805 } 1822 1806 else if ([sortType isEqualToString: SORT_PROGRESS]) … … 1830 1814 1831 1815 descriptors = [[NSArray alloc] initWithObjects: progressDescriptor, ratioProgressDescriptor, ratioDescriptor, 1832 nameDescriptor, orderDescriptor,nil];1816 nameDescriptor, nil]; 1833 1817 } 1834 1818 else if ([sortType isEqualToString: SORT_TRACKER]) … … 1839 1823 selector: @selector(localizedCaseInsensitiveCompare:)] autorelease]; 1840 1824 1841 descriptors = [[NSArray alloc] initWithObjects: trackerDescriptor, nameDescriptor, orderDescriptor,nil];1825 descriptors = [[NSArray alloc] initWithObjects: trackerDescriptor, nameDescriptor, nil]; 1842 1826 } 1843 1827 else if ([sortType isEqualToString: SORT_ACTIVITY]) … … 1847 1831 autorelease]; 1848 1832 1849 descriptors = [[NSArray alloc] initWithObjects: rateDescriptor, activityDescriptor, orderDescriptor,nil];1850 } 1851 else 1833 descriptors = [[NSArray alloc] initWithObjects: rateDescriptor, activityDescriptor, nil]; 1834 } 1835 else if ([sortType isEqualToString: SORT_DATE]) 1852 1836 { 1853 1837 NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"dateAdded" ascending: asc] autorelease]; 1854 1838 1855 descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, orderDescriptor, nil]; 1856 } 1839 descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, nil]; 1840 } 1841 else; //no need to sort by queue order 1857 1842 1858 1843 //actually sort 1859 if ([fDefaults boolForKey: @"SortByGroup"]) 1860 { 1861 for (TorrentGroup * group in fDisplayedTorrents) 1862 [[group torrents] sortUsingDescriptors: descriptors]; 1863 } 1864 else 1865 [fDisplayedTorrents sortUsingDescriptors: descriptors]; 1866 1867 [descriptors release]; 1844 if (descriptors) 1845 { 1846 if ([fDefaults boolForKey: @"SortByGroup"]) 1847 { 1848 for (TorrentGroup * group in fDisplayedTorrents) 1849 [[group torrents] sortUsingDescriptors: descriptors]; 1850 } 1851 else 1852 [fDisplayedTorrents sortUsingDescriptors: descriptors]; 1853 1854 [descriptors release]; 1855 } 1868 1856 1869 1857 [fTableView reloadData]; … … 2719 2707 NSIndexSet * insertIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(insertIndex, [movingTorrents count])]; 2720 2708 [fTorrents insertObjects: movingTorrents atIndexes: insertIndexes]; 2721 2722 //redo order values2723 for (NSInteger i = 0; i < [fTorrents count]; i++)2724 [[fTorrents objectAtIndex: i] setOrderValue: i];2725 2709 } 2726 2710 -
trunk/macosx/Torrent.h
r7659 r7794 70 70 BOOL fFinishedSeeding, fWaitToStart, fStalled; 71 71 72 NSInteger f OrderValue, fGroupValue;72 NSInteger fGroupValue; 73 73 74 74 BOOL fAddedTrackers; … … 231 231 - (CGFloat) swarmSpeed; 232 232 233 - (NSInteger) orderValue;234 - (void) setOrderValue: (NSInteger) orderValue;235 236 233 - (NSInteger) groupValue; 237 234 - (void) setGroupValue: (NSInteger) groupValue; -
trunk/macosx/Torrent.m
r7659 r7794 37 37 ratioSetting: (NSNumber *) ratioSetting ratioLimit: (NSNumber *) ratioLimit 38 38 waitToStart: (NSNumber *) waitToStart 39 orderValue: (NSNumber *) orderValuegroupValue: (NSNumber *) groupValue addedTrackers: (NSNumber *) addedTrackers;39 groupValue: (NSNumber *) groupValue addedTrackers: (NSNumber *) addedTrackers; 40 40 41 41 - (BOOL) shouldUseIncompleteFolderForName: (NSString *) name; … … 83 83 useIncompleteFolder: nil incompleteFolder: nil 84 84 ratioSetting: nil ratioLimit: nil 85 waitToStart: nil orderValue: nilgroupValue: nil addedTrackers: nil];85 waitToStart: nil groupValue: nil addedTrackers: nil]; 86 86 87 87 if (self) … … 108 108 useIncompleteFolder: nil incompleteFolder: nil 109 109 ratioSetting: nil ratioLimit: nil 110 waitToStart: nil orderValue: nilgroupValue: nil addedTrackers: nil];110 waitToStart: nil groupValue: nil addedTrackers: nil]; 111 111 112 112 return self; … … 124 124 ratioLimit: [history objectForKey: @"RatioLimit"] 125 125 waitToStart: [history objectForKey: @"WaitToStart"] 126 orderValue: [history objectForKey: @"OrderValue"]127 126 groupValue: [history objectForKey: @"GroupValue"] 128 127 addedTrackers: [history objectForKey: @"AddedTrackers"]]; … … 161 160 [NSNumber numberWithFloat: fRatioLimit], @"RatioLimit", 162 161 [NSNumber numberWithBool: fWaitToStart], @"WaitToStart", 163 [NSNumber numberWithInt: fOrderValue], @"OrderValue",164 162 [NSNumber numberWithInt: fGroupValue], @"GroupValue", 165 163 [NSNumber numberWithBool: fAddedTrackers], @"AddedTrackers", nil]; … … 1366 1364 } 1367 1365 1368 - (NSInteger) orderValue1369 {1370 return fOrderValue;1371 }1372 1373 - (void) setOrderValue: (NSInteger) orderValue1374 {1375 fOrderValue = orderValue;1376 }1377 1378 1366 - (NSInteger) groupValue 1379 1367 { … … 1617 1605 ratioSetting: (NSNumber *) ratioSetting ratioLimit: (NSNumber *) ratioLimit 1618 1606 waitToStart: (NSNumber *) waitToStart 1619 orderValue: (NSNumber *) orderValuegroupValue: (NSNumber *) groupValue addedTrackers: (NSNumber *) addedTrackers1607 groupValue: (NSNumber *) groupValue addedTrackers: (NSNumber *) addedTrackers 1620 1608 { 1621 1609 if (!(self = [super init])) … … 1708 1696 [self createFileList]; 1709 1697 1710 fOrderValue = orderValue ? [orderValue intValue] : tr_sessionCountTorrents(lib) - 1;1711 1698 fGroupValue = groupValue ? [groupValue intValue] : [[GroupsController groups] groupIndexForTorrent: self]; 1712 1699
Note: See TracChangeset
for help on using the changeset viewer.