1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +00:00

use new functions for setting multiple file dl/priorities

This commit is contained in:
Mitchell Livingston 2007-07-13 02:57:20 +00:00
parent e6e6d574db
commit 35dc48dc1d
2 changed files with 22 additions and 11 deletions

View file

@ -105,12 +105,11 @@
NSDictionary * item = [self itemAtRow: row]; NSDictionary * item = [self itemAtRow: row];
Torrent * torrent = [(InfoWindowController *)[[self window] windowController] selectedTorrent]; Torrent * torrent = [(InfoWindowController *)[[self window] windowController] selectedTorrent];
if ([[item objectForKey: @"IsFolder"] boolValue] NSIndexSet * indexSet = [item objectForKey: @"Indexes"];
|| ![torrent canChangeDownloadCheckForFiles: [item objectForKey: @"Indexes"]]) if ([[item objectForKey: @"IsFolder"] boolValue] || ![torrent canChangeDownloadCheckForFiles: indexSet])
[fNormalColor set]; [fNormalColor set];
else else
{ {
NSIndexSet * indexSet = [item objectForKey: @"Indexes"];
if ([torrent hasFilePriority: TR_PRI_HIGH forIndexes: indexSet]) if ([torrent hasFilePriority: TR_PRI_HIGH forIndexes: indexSet])
[fHighPriorityColor set]; [fHighPriorityColor set];
else if ([torrent hasFilePriority: TR_PRI_LOW forIndexes: indexSet]) else if ([torrent hasFilePriority: TR_PRI_LOW forIndexes: indexSet])

View file

@ -147,8 +147,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[NSNumber numberWithInt: fCheckDownload], @"CheckDownload", [NSNumber numberWithInt: fCheckDownload], @"CheckDownload",
[NSNumber numberWithInt: fDownloadLimit], @"DownloadLimit", [NSNumber numberWithInt: fDownloadLimit], @"DownloadLimit",
[NSNumber numberWithBool: fWaitToStart], @"WaitToStart", [NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
[self orderValue], @"OrderValue", [self orderValue], @"OrderValue", nil];
nil];
if (fIncompleteFolder) if (fIncompleteFolder)
[history setObject: fIncompleteFolder forKey: @"IncompleteFolder"]; [history setObject: fIncompleteFolder forKey: @"IncompleteFolder"];
@ -1313,10 +1312,16 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
- (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet - (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet
{ {
#warning multiples int count = [indexSet count], i = 0, index;
int index; int * files = malloc(count * sizeof(int));
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index]) for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
tr_torrentSetFileDL(fHandle, index, state != NSOffState); {
files[i] = index;
i++;
}
tr_torrentSetFileDLs(fHandle, files, count, state != NSOffState);
free(files);
[self update]; [self update];
if ([self isPaused]) if ([self isPaused])
@ -1325,10 +1330,17 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
- (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet - (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet
{ {
#warning multiples int count = [indexSet count], i = 0, index;
int index; int * files = malloc(count * sizeof(int));
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index]) for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
tr_torrentSetFilePriority(fHandle, index, priority); {
files[i] = index;
i++;
}
tr_torrentSetFilePriorities(fHandle, files, count, priority);
free(files);
} }
- (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet - (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet