hopefully function for getting priorities is a bit faster
This commit is contained in:
parent
5975ae7a59
commit
3440ad7ef3
|
@ -105,17 +105,23 @@
|
||||||
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])
|
|
||||||
[fLowPriorityColor set];
|
|
||||||
else
|
|
||||||
[fNormalColor set];
|
[fNormalColor set];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int priority = [[priorities objectAtIndex: 0] intValue];
|
||||||
|
if (priority == TR_PRI_LOW)
|
||||||
|
[fLowPriorityColor set];
|
||||||
|
else if (priority == TR_PRI_HIGH)
|
||||||
|
[fHighPriorityColor set];
|
||||||
|
else
|
||||||
|
[fNormalColor set];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NSRect rect = [self rectOfRow: row];
|
NSRect rect = [self rectOfRow: row];
|
||||||
|
@ -140,27 +146,28 @@
|
||||||
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])
|
{
|
||||||
[fLowPriorityColor set];
|
int priority = [[priorities objectAtIndex: 0] intValue];
|
||||||
else
|
if (priority == TR_PRI_LOW)
|
||||||
continue;
|
[fLowPriorityColor set];
|
||||||
|
else if (priority == TR_PRI_HIGH)
|
||||||
|
[fHighPriorityColor set];
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
|
||||||
NSRect rect = [self rectOfRow: i];
|
NSRect rect = [self rectOfRow: i];
|
||||||
float width = 14.0;
|
float width = 14.0;
|
||||||
rect.origin.y += (rect.size.height - width) * 0.5;
|
rect.origin.y += (rect.size.height - width) * 0.5;
|
||||||
rect.origin.x += 3.0;
|
rect.origin.x += 3.0;
|
||||||
rect.size.width = width;
|
rect.size.width = width;
|
||||||
rect.size.height = width;
|
rect.size.height = width;
|
||||||
|
|
||||||
[[NSBezierPath bezierPathWithOvalInRect: rect] fill];
|
[[NSBezierPath bezierPathWithOvalInRect: rect] fill];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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],
|
|
||||||
normal = [torrent hasFilePriority: TR_PRI_NORMAL forIndexes: indexSet],
|
|
||||||
high = [torrent hasFilePriority: TR_PRI_HIGH forIndexes: indexSet];
|
|
||||||
|
|
||||||
if (low && !normal && !high)
|
|
||||||
return NSLocalizedString(@"Low Priority", "Inspector -> files tab -> tooltip");
|
|
||||||
else if (!low && normal && !high)
|
|
||||||
return NSLocalizedString(@"Normal Priority", "Inspector -> files tab -> tooltip");
|
|
||||||
else if (!low && !normal && high)
|
|
||||||
return NSLocalizedString(@"High Priority", "Inspector -> files tab -> tooltip");
|
|
||||||
else
|
|
||||||
return NSLocalizedString(@"Multiple Priorities", "Inspector -> files tab -> tooltip");
|
return NSLocalizedString(@"Multiple Priorities", "Inspector -> files tab -> tooltip");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int priority = [[priorities objectAtIndex: 0] intValue];
|
||||||
|
if (priority == TR_PRI_LOW)
|
||||||
|
return NSLocalizedString(@"Low Priority", "Inspector -> files tab -> tooltip");
|
||||||
|
else if (priority == TR_PRI_HIGH)
|
||||||
|
return NSLocalizedString(@"High Priority", "Inspector -> files tab -> tooltip");
|
||||||
|
else
|
||||||
|
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…
Reference in New Issue