1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-03 21:12:05 +00:00

add a second file completion method for single files

This commit is contained in:
Mitchell Livingston 2007-07-15 22:14:03 +00:00
parent 04f0761d71
commit e0c0fd2a88
2 changed files with 23 additions and 18 deletions

View file

@ -206,8 +206,9 @@
//methods require fileStats to have been updated recently to be accurate
- (float) fileProgress: (int) index;
- (int) checkForFiles: (NSIndexSet *) indexSet;
- (BOOL) canChangeDownloadCheckForFile: (int) index;
- (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet;
- (int) checkForFiles: (NSIndexSet *) indexSet;
- (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet;
- (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
- (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;

View file

@ -1301,21 +1301,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
return fileStat[index].progress;
}
- (int) checkForFiles: (NSIndexSet *) indexSet
- (BOOL) canChangeDownloadCheckForFile: (int) index
{
BOOL onState = NO, offState = NO;
int index;
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
{
if (tr_torrentGetFileDL(fHandle, index) || ![self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]])
onState = YES;
else
offState = YES;
if (onState == offState)
return NSMixedState;
}
return onState ? NSOnState : NSOffState;
return [self fileCount] > 1 && fileStat[index].completionStatus != TR_CP_COMPLETE;
}
- (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet
@ -1333,6 +1321,23 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
return NO;
}
- (int) checkForFiles: (NSIndexSet *) indexSet
{
BOOL onState = NO, offState = NO;
int index;
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
{
if (tr_torrentGetFileDL(fHandle, index) || ![self canChangeDownloadCheckForFile: index])
onState = YES;
else
offState = YES;
if (onState == offState)
return NSMixedState;
}
return onState ? NSOnState : NSOffState;
}
- (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet
{
int count = [indexSet count], i = 0, index;
@ -1369,8 +1374,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
{
int index;
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
if (priority == tr_torrentGetFilePriority(fHandle, index)
&& [self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]])
if (priority == tr_torrentGetFilePriority(fHandle, index) && [self canChangeDownloadCheckForFile: index])
return YES;
return NO;
}
@ -1383,7 +1387,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
int index, priority;
for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
{
if (![self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]])
if (![self canChangeDownloadCheckForFile: index])
continue;
priority = tr_torrentGetFilePriority(fHandle, index);