mirror of
https://github.com/transmission/transmission
synced 2025-02-03 04:53:27 +00:00
pass object instead of creating string
This commit is contained in:
parent
0a48921e19
commit
f55c1b05cd
2 changed files with 8 additions and 12 deletions
|
@ -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,7 +64,8 @@
|
|||
bottomTextRect.origin.y += textHeight;
|
||||
bottomTextRect.size.height = cellFrame.size.height - textHeight;
|
||||
|
||||
NSMutableAttributedString * bottomText = [[NSMutableAttributedString alloc] initWithString: [strings objectAtIndex: 1]
|
||||
NSMutableAttributedString * bottomText = [[NSMutableAttributedString alloc] initWithString:
|
||||
[NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]]
|
||||
attributes: statusAttributes];
|
||||
|
||||
[bottomText drawInRect: bottomTextRect];
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue