mirror of
https://github.com/transmission/transmission
synced 2025-03-09 05:14:09 +00:00
hopefully function for getting priorities is a bit faster
This commit is contained in:
parent
5975ae7a59
commit
3440ad7ef3
4 changed files with 91 additions and 43 deletions
|
@ -105,18 +105,24 @@
|
||||||
NSDictionary * item = [self itemAtRow: row];
|
NSDictionary * item = [self itemAtRow: row];
|
||||||
Torrent * torrent = [(InfoWindowController *)[[self window] windowController] selectedTorrent];
|
Torrent * torrent = [(InfoWindowController *)[[self window] windowController] selectedTorrent];
|
||||||
|
|
||||||
NSIndexSet * indexSet = [item objectForKey: @"Indexes"];
|
if ([[item objectForKey: @"IsFolder"] boolValue])
|
||||||
if ([[item objectForKey: @"IsFolder"] boolValue] || ![torrent canChangeDownloadCheckForFiles: indexSet])
|
|
||||||
[fNormalColor set];
|
[fNormalColor set];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ([torrent hasFilePriority: TR_PRI_HIGH forIndexes: indexSet])
|
NSArray * priorities = [torrent filePrioritiesForIndexes: [item objectForKey: @"Indexes"]];
|
||||||
[fHighPriorityColor set];
|
if ([priorities count] == 0)
|
||||||
else if ([torrent hasFilePriority: TR_PRI_LOW forIndexes: indexSet])
|
[fNormalColor set];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int priority = [[priorities objectAtIndex: 0] intValue];
|
||||||
|
if (priority == TR_PRI_LOW)
|
||||||
[fLowPriorityColor set];
|
[fLowPriorityColor set];
|
||||||
|
else if (priority == TR_PRI_HIGH)
|
||||||
|
[fHighPriorityColor set];
|
||||||
else
|
else
|
||||||
[fNormalColor set];
|
[fNormalColor set];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NSRect rect = [self rectOfRow: row];
|
NSRect rect = [self rectOfRow: row];
|
||||||
rect.size.height -= 1.0;
|
rect.size.height -= 1.0;
|
||||||
|
@ -140,16 +146,16 @@
|
||||||
if ([self isRowSelected: i])
|
if ([self isRowSelected: i])
|
||||||
{
|
{
|
||||||
item = [self itemAtRow: i];
|
item = [self itemAtRow: i];
|
||||||
if ([[item objectForKey: @"IsFolder"] boolValue])
|
if (![[item objectForKey: @"IsFolder"] boolValue])
|
||||||
continue;
|
|
||||||
|
|
||||||
indexSet = [item objectForKey: @"Indexes"];
|
|
||||||
if ([torrent canChangeDownloadCheckForFiles: indexSet])
|
|
||||||
{
|
{
|
||||||
if ([torrent hasFilePriority: TR_PRI_HIGH forIndexes: indexSet])
|
NSArray * priorities = [torrent filePrioritiesForIndexes: [item objectForKey: @"Indexes"]];
|
||||||
[fHighPriorityColor set];
|
if ([priorities count] == 1)
|
||||||
else if ([torrent hasFilePriority: TR_PRI_LOW forIndexes: indexSet])
|
{
|
||||||
|
int priority = [[priorities objectAtIndex: 0] intValue];
|
||||||
|
if (priority == TR_PRI_LOW)
|
||||||
[fLowPriorityColor set];
|
[fLowPriorityColor set];
|
||||||
|
else if (priority == TR_PRI_HIGH)
|
||||||
|
[fHighPriorityColor set];
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -165,5 +171,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -932,24 +932,23 @@
|
||||||
}
|
}
|
||||||
else if ([ident isEqualToString: @"Priority"])
|
else if ([ident isEqualToString: @"Priority"])
|
||||||
{
|
{
|
||||||
Torrent * torrent = [fTorrents objectAtIndex: 0];
|
NSArray * priorities = [[fTorrents objectAtIndex: 0] filePrioritiesForIndexes: [item objectForKey: @"Indexes"]];
|
||||||
NSIndexSet * indexSet = [item objectForKey: @"Indexes"];
|
|
||||||
|
|
||||||
if (![torrent canChangeDownloadCheckForFiles: indexSet])
|
int count = [priorities count];
|
||||||
|
if (count == 0)
|
||||||
return NSLocalizedString(@"Priority Not Available", "Inspector -> files tab -> tooltip");
|
return NSLocalizedString(@"Priority Not Available", "Inspector -> files tab -> tooltip");
|
||||||
|
else if (count > 1)
|
||||||
BOOL low = [torrent hasFilePriority: TR_PRI_LOW forIndexes: indexSet],
|
return NSLocalizedString(@"Multiple Priorities", "Inspector -> files tab -> tooltip");
|
||||||
normal = [torrent hasFilePriority: TR_PRI_NORMAL forIndexes: indexSet],
|
else
|
||||||
high = [torrent hasFilePriority: TR_PRI_HIGH forIndexes: indexSet];
|
{
|
||||||
|
int priority = [[priorities objectAtIndex: 0] intValue];
|
||||||
if (low && !normal && !high)
|
if (priority == TR_PRI_LOW)
|
||||||
return NSLocalizedString(@"Low Priority", "Inspector -> files tab -> tooltip");
|
return NSLocalizedString(@"Low Priority", "Inspector -> files tab -> tooltip");
|
||||||
else if (!low && normal && !high)
|
else if (priority == TR_PRI_HIGH)
|
||||||
return NSLocalizedString(@"Normal Priority", "Inspector -> files tab -> tooltip");
|
|
||||||
else if (!low && !normal && high)
|
|
||||||
return NSLocalizedString(@"High Priority", "Inspector -> files tab -> tooltip");
|
return NSLocalizedString(@"High Priority", "Inspector -> files tab -> tooltip");
|
||||||
else
|
else
|
||||||
return NSLocalizedString(@"Multiple Priorities", "Inspector -> files tab -> tooltip");
|
return NSLocalizedString(@"Normal Priority", "Inspector -> files tab -> tooltip");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return nil;
|
return nil;
|
||||||
|
|
|
@ -206,6 +206,7 @@
|
||||||
- (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet;
|
- (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet;
|
||||||
- (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
|
- (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
|
||||||
- (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
|
- (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
|
||||||
|
- (NSArray *) filePrioritiesForIndexes: (NSIndexSet *) indexSet;
|
||||||
|
|
||||||
- (NSDate *) dateAdded;
|
- (NSDate *) dateAdded;
|
||||||
- (NSDate *) dateCompleted;
|
- (NSDate *) dateCompleted;
|
||||||
|
|
|
@ -1314,12 +1314,12 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
{
|
{
|
||||||
int count = [indexSet count], i = 0, index;
|
int count = [indexSet count], i = 0, index;
|
||||||
int * files = malloc(count * sizeof(int));
|
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])
|
||||||
{
|
{
|
||||||
files[i] = index;
|
files[i] = index;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr_torrentSetFileDLs(fHandle, files, count, state != NSOffState);
|
tr_torrentSetFileDLs(fHandle, files, count, state != NSOffState);
|
||||||
free(files);
|
free(files);
|
||||||
|
|
||||||
|
@ -1332,7 +1332,6 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
{
|
{
|
||||||
int count = [indexSet count], i = 0, index;
|
int count = [indexSet count], i = 0, index;
|
||||||
int * files = malloc(count * sizeof(int));
|
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])
|
||||||
{
|
{
|
||||||
files[i] = index;
|
files[i] = index;
|
||||||
|
@ -1353,6 +1352,48 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSArray *) filePrioritiesForIndexes: (NSIndexSet *) indexSet
|
||||||
|
{
|
||||||
|
BOOL low = NO, normal = NO, high = NO;
|
||||||
|
NSMutableArray * priorities = [NSMutableArray arrayWithCapacity: 3];
|
||||||
|
|
||||||
|
int index, priority;
|
||||||
|
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
|
||||||
|
{
|
||||||
|
if (![self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
priority = tr_torrentGetFilePriority(fHandle, index);
|
||||||
|
if (priority == TR_PRI_LOW)
|
||||||
|
{
|
||||||
|
if (!low)
|
||||||
|
low = YES;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (priority == TR_PRI_HIGH)
|
||||||
|
{
|
||||||
|
if (!high)
|
||||||
|
high = YES;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!normal)
|
||||||
|
normal = YES;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
[priorities addObject: [NSNumber numberWithInt: priority]];
|
||||||
|
|
||||||
|
if (low && normal && high)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return priorities;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSDate *) dateAdded
|
- (NSDate *) dateAdded
|
||||||
{
|
{
|
||||||
return fDateAdded;
|
return fDateAdded;
|
||||||
|
|
Loading…
Add table
Reference in a new issue