1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-07 06:54:40 +00:00

calculate the message attributes when opening the window, to avoid constant checking for nil

This commit is contained in:
Mitchell Livingston 2009-12-10 05:16:30 +00:00
parent 9fb6c5b1c4
commit 9888043e13

View file

@ -110,6 +110,9 @@
clearButtonFrame.origin.x -= clearButtonFrame.size.width - oldClearButtonWidth;
[fClearButton setFrame: clearButtonFrame];
fAttributes = [[[[[fMessageTable tableColumnWithIdentifier: @"Message"] dataCell] attributedStringValue]
attributesAtIndex: 0 effectiveRange: NULL] retain];
//select proper level in popup button
switch ([[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"])
{
@ -250,12 +253,9 @@
#warning don't cut off end
- (CGFloat) tableView: (NSTableView *) tableView heightOfRow: (NSInteger) row
{
NSTableColumn * column = [tableView tableColumnWithIdentifier: @"Message"];
if (!fAttributes)
fAttributes = [[[[column dataCell] attributedStringValue] attributesAtIndex: 0 effectiveRange: NULL] retain];
NSString * message = [[fDisplayedMessages objectAtIndex: row] objectForKey: @"Message"];
NSTableColumn * column = [tableView tableColumnWithIdentifier: @"Message"];
const CGFloat count = floorf([message sizeWithAttributes: fAttributes].width / [column width]);
return [tableView rowHeight] * (count + 1.0);
}