From f55c1b05cdec48f95bd43649bc2bbc7c60801d3b Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 18 Jan 2007 22:53:27 +0000 Subject: [PATCH] pass object instead of creating string --- macosx/FileBrowserCell.m | 12 +++++++----- macosx/InfoWindowController.m | 8 +------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/macosx/FileBrowserCell.m b/macosx/FileBrowserCell.m index 695e6cb73..20ea20cb3 100644 --- a/macosx/FileBrowserCell.m +++ b/macosx/FileBrowserCell.m @@ -1,4 +1,5 @@ #import "FileBrowserCell.h" +#import "StringAdditions.h" #define SPACE 2.0 @@ -30,7 +31,7 @@ [image drawInRect: imageRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0]; //text - NSArray * strings = [[self stringValue] componentsSeparatedByString: @"\n"]; + NSMutableDictionary * item = [self objectValue]; NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; [paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail]; @@ -46,13 +47,13 @@ NSRect textRect = NSMakeRect(NSMaxX(imageRect) + SPACE, cellFrame.origin.y + 1.0, NSMaxX(cellFrame) - NSMaxX(imageRect) - 2.0 * SPACE, textHeight); - NSAttributedString * text = [[NSAttributedString alloc] initWithString: [strings objectAtIndex: 0] + NSAttributedString * text = [[NSAttributedString alloc] initWithString: [item objectForKey: @"Name"] attributes: nameAttributes]; [text drawInRect: textRect]; [text release]; //bottomText - if ([strings count] > 1) + if (![[item objectForKey: @"IsFolder"] boolValue]) { NSDictionary * statusAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: highlighted ? [NSColor whiteColor] : [NSColor darkGrayColor], NSForegroundColorAttributeName, @@ -63,8 +64,9 @@ bottomTextRect.origin.y += textHeight; bottomTextRect.size.height = cellFrame.size.height - textHeight; - NSMutableAttributedString * bottomText = [[NSMutableAttributedString alloc] initWithString: [strings objectAtIndex: 1] - attributes: statusAttributes]; + NSMutableAttributedString * bottomText = [[NSMutableAttributedString alloc] initWithString: + [NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]] + attributes: statusAttributes]; [bottomText drawInRect: bottomTextRect]; [bottomText release]; diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index e5f287f4b..24ac442a4 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -681,13 +681,7 @@ if ([[tableColumn identifier] isEqualToString: @"Check"]) return [item objectForKey: @"Check"]; else - { - if ([[item objectForKey: @"IsFolder"] boolValue]) - return [item objectForKey: @"Name"]; - else - return [NSString stringWithFormat: @"%@\n%@", [item objectForKey: @"Name"], - [NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]]]; - } + return item; } - (void) outlineView: (NSOutlineView *) outlineView setObjectValue: (id) object