show file size in file table again

This commit is contained in:
Mitchell Livingston 2007-01-17 07:26:33 +00:00
parent 02274a0e60
commit 99c63daaea
3 changed files with 21 additions and 11 deletions

View File

@ -96,6 +96,7 @@
[browserCell setLeaf: YES];
[[fFileOutline tableColumnWithIdentifier: @"Name"] setDataCell: browserCell];
[fFileOutline setAutoresizesOutlineColumn: NO];
[fFileOutline setDoubleAction: @selector(revealFile:)];
//set blank inspector
@ -680,12 +681,19 @@
byItem: (id) item
{
NSString * ident = [tableColumn identifier];
return [item objectForKey: @"Name"];
if ([ident isEqualToString: @"Size"])
return ![[item objectForKey: @"IsFolder"] boolValue]
? [NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]] : @"";
else
return [item objectForKey: @"Name"];
}
- (void) outlineView: (NSOutlineView *) outlineView willDisplayCell: (id) cell
forTableColumn: (NSTableColumn *) tableColumn item:(id) item
{
if (![[tableColumn identifier] isEqualToString: @"Name"])
return;
NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFileType: ![[item objectForKey: @"IsFolder"] boolValue]
? [[item objectForKey: @"Name"] pathExtension] : NSFileTypeForHFSTypeCode('fldr')];
[icon setScalesWhenResized: YES];

View File

@ -43,7 +43,7 @@
checkDownload: (NSNumber *) checkDownload downloadLimit: (NSNumber *) downloadLimit
waitToStart: (NSNumber *) waitToStart orderValue: (NSNumber *) orderValue;
- (void) insertPath: (NSMutableArray *) components withParent: (NSMutableArray *) parent;
- (void) insertPath: (NSMutableArray *) components withParent: (NSMutableArray *) parent fileSize: (uint64_t) size;
- (NSImage *) advancedBar;
- (void) trashFile: (NSString *) path;
@ -1067,22 +1067,22 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
- (NSArray *) fileList
{
int count = [self fileCount], i;
tr_file_t file;
tr_file_t * file;
NSMutableArray * files = [NSMutableArray array], * pathComponents;
for (i = 0; i < count; i++)
{
file = fInfo->files[i];
file = &fInfo->files[i];
/*[files addObject: [NSDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithUTF8String: file.name], @"Name",
[NSNumber numberWithUnsignedLongLong: file.length], @"Size", nil]];*/
[NSString stringWithUTF8String: file->name], @"Name",
[NSNumber numberWithUnsignedLongLong: file->length], @"Size", nil]];*/
pathComponents = [[[NSString stringWithUTF8String: file.name] pathComponents] mutableCopy];
pathComponents = [[[NSString stringWithUTF8String: file->name] pathComponents] mutableCopy];
if (fInfo->multifile)
[pathComponents removeObjectAtIndex: 0];
[self insertPath: pathComponents withParent: files];
[self insertPath: pathComponents withParent: files fileSize: file->length];
[pathComponents autorelease];
}
return files;
@ -1216,7 +1216,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
return self;
}
- (void) insertPath: (NSMutableArray *) components withParent: (NSMutableArray *) parent
- (void) insertPath: (NSMutableArray *) components withParent: (NSMutableArray *) parent fileSize: (uint64_t) size
{
NSString * name = [components objectAtIndex: 0];
BOOL isFolder = [components count] > 1;
@ -1233,11 +1233,13 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
//create new folder or item if it doesn't already exist
if (!dict)
{
#warning put size and full path here for item later
#warning put full path for item
dict = [NSMutableDictionary dictionaryWithObjectsAndKeys: name, @"Name",
[NSNumber numberWithBool: isFolder], @"IsFolder", nil];
if (isFolder)
[dict setObject: [NSMutableArray array] forKey: @"Children"];
else
[dict setObject: [NSNumber numberWithUnsignedLongLong: size] forKey: @"Size"];
[parent addObject: dict];
}
@ -1245,7 +1247,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
if (isFolder)
{
[components removeObjectAtIndex: 0];
[self insertPath: components withParent: [dict objectForKey: @"Children"]];
[self insertPath: components withParent: [dict objectForKey: @"Children"] fileSize: size];
}
}