pass object instead of creating string
This commit is contained in:
parent
0a48921e19
commit
f55c1b05cd
|
@ -1,4 +1,5 @@
|
||||||
#import "FileBrowserCell.h"
|
#import "FileBrowserCell.h"
|
||||||
|
#import "StringAdditions.h"
|
||||||
|
|
||||||
#define SPACE 2.0
|
#define SPACE 2.0
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@
|
||||||
[image drawInRect: imageRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
|
[image drawInRect: imageRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
|
||||||
|
|
||||||
//text
|
//text
|
||||||
NSArray * strings = [[self stringValue] componentsSeparatedByString: @"\n"];
|
NSMutableDictionary * item = [self objectValue];
|
||||||
|
|
||||||
NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||||
[paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail];
|
[paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail];
|
||||||
|
@ -46,13 +47,13 @@
|
||||||
NSRect textRect = NSMakeRect(NSMaxX(imageRect) + SPACE, cellFrame.origin.y + 1.0,
|
NSRect textRect = NSMakeRect(NSMaxX(imageRect) + SPACE, cellFrame.origin.y + 1.0,
|
||||||
NSMaxX(cellFrame) - NSMaxX(imageRect) - 2.0 * SPACE, textHeight);
|
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];
|
attributes: nameAttributes];
|
||||||
[text drawInRect: textRect];
|
[text drawInRect: textRect];
|
||||||
[text release];
|
[text release];
|
||||||
|
|
||||||
//bottomText
|
//bottomText
|
||||||
if ([strings count] > 1)
|
if (![[item objectForKey: @"IsFolder"] boolValue])
|
||||||
{
|
{
|
||||||
NSDictionary * statusAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
|
NSDictionary * statusAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||||
highlighted ? [NSColor whiteColor] : [NSColor darkGrayColor], NSForegroundColorAttributeName,
|
highlighted ? [NSColor whiteColor] : [NSColor darkGrayColor], NSForegroundColorAttributeName,
|
||||||
|
@ -63,8 +64,9 @@
|
||||||
bottomTextRect.origin.y += textHeight;
|
bottomTextRect.origin.y += textHeight;
|
||||||
bottomTextRect.size.height = cellFrame.size.height - textHeight;
|
bottomTextRect.size.height = cellFrame.size.height - textHeight;
|
||||||
|
|
||||||
NSMutableAttributedString * bottomText = [[NSMutableAttributedString alloc] initWithString: [strings objectAtIndex: 1]
|
NSMutableAttributedString * bottomText = [[NSMutableAttributedString alloc] initWithString:
|
||||||
attributes: statusAttributes];
|
[NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]]
|
||||||
|
attributes: statusAttributes];
|
||||||
|
|
||||||
[bottomText drawInRect: bottomTextRect];
|
[bottomText drawInRect: bottomTextRect];
|
||||||
[bottomText release];
|
[bottomText release];
|
||||||
|
|
|
@ -681,13 +681,7 @@
|
||||||
if ([[tableColumn identifier] isEqualToString: @"Check"])
|
if ([[tableColumn identifier] isEqualToString: @"Check"])
|
||||||
return [item objectForKey: @"Check"];
|
return [item objectForKey: @"Check"];
|
||||||
else
|
else
|
||||||
{
|
return item;
|
||||||
if ([[item objectForKey: @"IsFolder"] boolValue])
|
|
||||||
return [item objectForKey: @"Name"];
|
|
||||||
else
|
|
||||||
return [NSString stringWithFormat: @"%@\n%@", [item objectForKey: @"Name"],
|
|
||||||
[NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) outlineView: (NSOutlineView *) outlineView setObjectValue: (id) object
|
- (void) outlineView: (NSOutlineView *) outlineView setObjectValue: (id) object
|
||||||
|
|
Loading…
Reference in New Issue