1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-20 13:16:53 +00:00

show individual file progress in inspector

This commit is contained in:
Mitchell Livingston 2007-02-23 13:40:30 +00:00
parent a0f7446a39
commit c21833ab06
4 changed files with 55 additions and 14 deletions

View file

@ -60,7 +60,9 @@
[NSFont messageFontOfSize: 9.0], NSFontAttributeName,
paragraphStyle, NSParagraphStyleAttributeName, nil];
NSString * statusString = [NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]];
NSString * statusString = [NSString stringWithFormat: @"%.2f%% of %@",
100.0 * [[item objectForKey: @"Progress"] floatValue],
[NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]]];
NSRect statusTextRect = nameTextRect;
statusTextRect.size.height = [statusString sizeWithAttributes: statusAttributes].height;

View file

@ -54,6 +54,7 @@
- (void) updateInfoGeneral;
- (void) updateInfoActivity;
- (void) updateInfoPeers;
- (void) updateInfoFiles;
- (void) updateInfoSettings;
- (void) setWindowForTab: (NSString *) identifier animate: (BOOL) animate;
@ -273,6 +274,8 @@
[fFiles release];
fFiles = [[torrent fileList] retain];
[self updateInfoFiles];
int fileCount = [torrent fileCount];
if (fileCount != 1)
[fFileTableStatusField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d files total",
@ -300,6 +303,8 @@
[self updateInfoPeers];
else if ([ident isEqualToString: TAB_INFO_IDENT])
[self updateInfoGeneral];
else if ([ident isEqualToString: TAB_FILES_IDENT])
[self updateInfoFiles];
else;
}
@ -389,6 +394,15 @@
[fPeerTable reloadData];
}
- (void) updateInfoFiles
{
if ([fTorrents count] != 1)
return;
[[fTorrents objectAtIndex: 0] updateFileProgress];
[fFileOutline reloadData];
}
- (void) updateInfoSettings
{
int numberSelected = [fTorrents count];

View file

@ -46,7 +46,7 @@
NSImage * fIcon, * fIconFlipped, * fIconSmall;
NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString;
NSArray * fFileList;
NSArray * fFileList, * fFileFlatList;
int fUploadLimit, fDownloadLimit;
float fRatioLimit;
@ -172,6 +172,8 @@
- (uint64_t) uploadedTotal;
- (float) swarmSpeed;
- (void) updateFileProgress;
- (NSNumber *) orderValue;
- (void) setOrderValue: (int) orderValue;

View file

@ -41,10 +41,10 @@
checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
- (NSArray *) createFileList;
- (void) createFileList;
- (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings
withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath
fileSize: (uint64_t) size state: (int) state;
fileSize: (uint64_t) size state: (int) state flatList: (NSMutableArray *) flatList;
- (NSImage *) advancedBar;
- (void) trashFile: (NSString *) path;
@ -195,6 +195,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[fRemainingTimeString release];
[fFileList release];
[fFileFlatList release];
[fBitmap release];
free(fPieces);
@ -1042,6 +1043,17 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
return fStat->swarmspeed;
}
- (void) updateFileProgress
{
float * progress = tr_torrentCompletion( fHandle );
int i, fileCount = [self fileCount];
for (i = 0; i < fileCount; i++)
[[fFileFlatList objectAtIndex: i] setObject: [NSNumber numberWithFloat: progress[i]] forKey: @"Progress"];
free(progress);
}
- (NSNumber *) orderValue
{
return [NSNumber numberWithInt: fOrderValue];
@ -1166,7 +1178,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
fShortStatusString = [[NSMutableString alloc] initWithCapacity: 30];
fRemainingTimeString = [[NSMutableString alloc] initWithCapacity: 30];
fFileList = [self createFileList];
[self createFileList];
//set up advanced bar
fBitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: nil
@ -1182,13 +1194,16 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
return self;
}
- (NSArray *) createFileList
- (void) createFileList
{
int count = [self fileCount], i;
tr_file_t * file;
NSMutableArray * files = [[NSMutableArray alloc] init], * pathComponents;
NSMutableArray * pathComponents;
NSString * path;
NSMutableArray * fileList = [[NSMutableArray alloc] init],
* fileFlatList = [[NSMutableArray alloc] initWithCapacity: count];
for (i = 0; i < count; i++)
{
file = &fInfo->files[i];
@ -1202,16 +1217,20 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
else
path = @"";
[self insertPath: pathComponents forSiblings: files withParent: nil previousPath: path
fileSize: file->length state: NSOnState];
[self insertPath: pathComponents forSiblings: fileList withParent: nil previousPath: path
fileSize: file->length state: NSOnState flatList: fileFlatList];
[pathComponents autorelease];
}
return files;
fFileList = [[NSArray alloc] initWithArray: fileList];
[fileList release];
fFileFlatList = [[NSArray alloc] initWithArray: fileFlatList];
[fileFlatList release];
}
- (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings
withParent: (NSMutableDictionary *) parent previousPath: (NSString *) previousPath
fileSize: (uint64_t) size state: (int) state
fileSize: (uint64_t) size state: (int) state flatList: (NSMutableArray *) flatList
{
NSString * name = [components objectAtIndex: 0];
BOOL isFolder = [components count] > 1;
@ -1233,16 +1252,20 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
dict = [NSMutableDictionary dictionaryWithObjectsAndKeys: name, @"Name",
[NSNumber numberWithBool: isFolder], @"IsFolder",
currentPath, @"Path", nil];
[siblings addObject: dict];
if (isFolder)
[dict setObject: [NSMutableArray array] forKey: @"Children"];
else
{
[flatList addObject: dict];
[dict setObject: [NSNumber numberWithUnsignedLongLong: size] forKey: @"Size"];
}
if (parent)
[dict setObject: parent forKey: @"Parent"];
[dict setObject: [NSNumber numberWithInt: state] forKey: @"Check"];
[siblings addObject: dict];
}
else
{
@ -1255,7 +1278,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
{
[components removeObjectAtIndex: 0];
[self insertPath: components forSiblings: [dict objectForKey: @"Children"]
withParent: dict previousPath: currentPath fileSize: size state: state];
withParent: dict previousPath: currentPath fileSize: size state: state flatList: flatList];
}
}