small efficiency change and some improvements for the invisible file checkboxes
This commit is contained in:
parent
74d2eefac4
commit
16cd689de2
|
@ -107,12 +107,18 @@
|
||||||
//set file table
|
//set file table
|
||||||
[fFileOutline setDoubleAction: @selector(revealFile:)];
|
[fFileOutline setDoubleAction: @selector(revealFile:)];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||||
|
selector: @selector(fileFinished:) name: @"FileFinished" object: nil];
|
||||||
|
|
||||||
//set blank inspector
|
//set blank inspector
|
||||||
[self updateInfoForTorrents: [NSArray array]];
|
[self updateInfoForTorrents: [NSArray array]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
|
|
||||||
|
if (fTorrents)
|
||||||
[fTorrents release];
|
[fTorrents release];
|
||||||
if (fPeers)
|
if (fPeers)
|
||||||
[fPeers release];
|
[fPeers release];
|
||||||
|
@ -399,7 +405,7 @@
|
||||||
if ([fTorrents count] != 1)
|
if ([fTorrents count] != 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[[fTorrents objectAtIndex: 0] updateFileProgress];
|
if ([[fTorrents objectAtIndex: 0] updateFileProgress])
|
||||||
[fFileOutline reloadData];
|
[fFileOutline reloadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,8 +729,16 @@
|
||||||
}
|
}
|
||||||
else if ([[tableColumn identifier] isEqualToString: @"Check"])
|
else if ([[tableColumn identifier] isEqualToString: @"Check"])
|
||||||
{
|
{
|
||||||
/*[(NSButtonCell *)cell setImagePosition: item ? NSImageOnly : NSNoImage];
|
/*if (!item)
|
||||||
[cell setEnabled: NO];*/
|
{
|
||||||
|
[(NSButtonCell *)cell setImagePosition: NSNoImage];
|
||||||
|
[cell setEnabled: NO];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[(NSButtonCell *)cell setImagePosition: NSImageOnly];
|
||||||
|
[cell setEnabled: [[item objectForKey: @"IsFolder"] boolValue] ? [[item objectForKey: @"Remaining"] intValue] > 0
|
||||||
|
: [[item objectForKey: @"Progress"] floatValue] < 1.0];*/
|
||||||
[(NSButtonCell *)cell setImagePosition: NSNoImage];
|
[(NSButtonCell *)cell setImagePosition: NSNoImage];
|
||||||
}
|
}
|
||||||
else;
|
else;
|
||||||
|
@ -741,6 +755,16 @@
|
||||||
[fFileOutline reloadItem: topItem reloadChildren: YES];
|
[fFileOutline reloadItem: topItem reloadChildren: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) fileFinished: (NSNotification *) notification
|
||||||
|
{
|
||||||
|
NSMutableDictionary * item = [notification object];
|
||||||
|
|
||||||
|
[item setObject: [NSNumber numberWithInt: NSOnState] forKey: @"Check"];
|
||||||
|
NSMutableDictionary * topItem = [self resetFileCheckStateForItemParent: item];
|
||||||
|
|
||||||
|
[fFileOutline reloadItem: topItem reloadChildren: YES];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setFileCheckState: (int) state forItem: (NSMutableDictionary *) item
|
- (void) setFileCheckState: (int) state forItem: (NSMutableDictionary *) item
|
||||||
{
|
{
|
||||||
[item setObject: [NSNumber numberWithInt: state] forKey: @"Check"];
|
[item setObject: [NSNumber numberWithInt: state] forKey: @"Check"];
|
||||||
|
|
|
@ -172,7 +172,7 @@
|
||||||
- (uint64_t) uploadedTotal;
|
- (uint64_t) uploadedTotal;
|
||||||
- (float) swarmSpeed;
|
- (float) swarmSpeed;
|
||||||
|
|
||||||
- (void) updateFileProgress;
|
- (BOOL) updateFileProgress;
|
||||||
|
|
||||||
- (NSNumber *) orderValue;
|
- (NSNumber *) orderValue;
|
||||||
- (void) setOrderValue: (int) orderValue;
|
- (void) setOrderValue: (int) orderValue;
|
||||||
|
|
|
@ -1043,15 +1043,38 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
return fStat->swarmspeed;
|
return fStat->swarmspeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) updateFileProgress
|
- (BOOL) updateFileProgress
|
||||||
{
|
{
|
||||||
|
BOOL change = NO;
|
||||||
float * progress = tr_torrentCompletion(fHandle);
|
float * progress = tr_torrentCompletion(fHandle);
|
||||||
|
NSNumber * progressNum;
|
||||||
|
NSMutableDictionary * item, * dict;
|
||||||
|
|
||||||
int i, fileCount = [self fileCount];
|
int i, fileCount = [self fileCount];
|
||||||
for (i = 0; i < fileCount; i++)
|
for (i = 0; i < fileCount; i++)
|
||||||
[[fFileFlatList objectAtIndex: i] setObject: [NSNumber numberWithFloat: progress[i]] forKey: @"Progress"];
|
{
|
||||||
|
if (!(progressNum = [[fFileFlatList objectAtIndex: i] objectForKey: @"Progress"])
|
||||||
|
|| [progressNum floatValue] != progress[i])
|
||||||
|
{
|
||||||
|
item = [fFileFlatList objectAtIndex: i];
|
||||||
|
[item setObject: [NSNumber numberWithFloat: progress[i]] forKey: @"Progress"];
|
||||||
|
change = YES;
|
||||||
|
|
||||||
|
if (progress[i] == 1.0)
|
||||||
|
{
|
||||||
|
dict = item;
|
||||||
|
while ((dict = [dict objectForKey: @"Parent"]))
|
||||||
|
[dict setObject: [NSNumber numberWithInt: [[dict objectForKey: @"Remaining"] intValue]-1]
|
||||||
|
forKey: @"Remaining"];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"FileFinished" object: item];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
free(progress);
|
free(progress);
|
||||||
|
|
||||||
|
return change;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSNumber *) orderValue
|
- (NSNumber *) orderValue
|
||||||
|
@ -1256,7 +1279,10 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
[siblings addObject: dict];
|
[siblings addObject: dict];
|
||||||
|
|
||||||
if (isFolder)
|
if (isFolder)
|
||||||
|
{
|
||||||
[dict setObject: [NSMutableArray array] forKey: @"Children"];
|
[dict setObject: [NSMutableArray array] forKey: @"Children"];
|
||||||
|
[dict setObject: [NSNumber numberWithInt: 1] forKey: @"Remaining"];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[flatList addObject: dict];
|
[flatList addObject: dict];
|
||||||
|
@ -1269,6 +1295,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (isFolder)
|
||||||
|
[dict setObject: [NSNumber numberWithInt: [[dict objectForKey: @"Remaining"] intValue]+1] forKey: @"Remaining"];
|
||||||
|
|
||||||
int dictState = [[dict objectForKey: @"Check"] intValue];
|
int dictState = [[dict objectForKey: @"Check"] intValue];
|
||||||
if (dictState != NSMixedState && dictState != state)
|
if (dictState != NSMixedState && dictState != state)
|
||||||
[dict setObject: [NSNumber numberWithInt: NSMixedState] forKey: @"Check"];
|
[dict setObject: [NSNumber numberWithInt: NSMixedState] forKey: @"Check"];
|
||||||
|
|
Loading…
Reference in New Issue