~ubuntu-branches/ubuntu/maverick/transmission/maverick

« back to all changes in this revision

Viewing changes to macosx/MessageWindowController.m

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Klimonda
  • Date: 2009-05-22 21:57:30 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (2.1.18 sid) (1.3.8 upstream)
  • mto: This revision was merged to the branch mainline in revision 36.
  • Revision ID: james.westby@ubuntu.com-20090522215730-ly5kgv5aw9ig2u82
Tags: upstream-1.61
ImportĀ upstreamĀ versionĀ 1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: MessageWindowController.m 7018 2008-11-02 14:04:57Z livings124 $
 
2
 * $Id: MessageWindowController.m 7802 2009-01-26 02:16:03Z livings124 $
3
3
 *
4
 
 * Copyright (c) 2006-2008 Transmission authors and contributors
 
4
 * Copyright (c) 2006-2009 Transmission authors and contributors
5
5
 *
6
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
7
 * copy of this software and associated documentation files (the "Software"),
24
24
 
25
25
#import "MessageWindowController.h"
26
26
#import "NSStringAdditions.h"
27
 
#import "NSApplicationAdditions.h"
28
27
#import <transmission.h>
29
28
 
30
29
#define LEVEL_ERROR 0
67
66
    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(resizeColumn)
68
67
        name: @"NSTableViewColumnDidResizeNotification" object: fMessageTable];
69
68
    
70
 
    if ([NSApp isOnLeopardOrBetter])
71
 
        [window setContentBorderThickness: [[fMessageTable enclosingScrollView] frame].origin.y forEdge: NSMinYEdge];
 
69
    [window setContentBorderThickness: [[fMessageTable enclosingScrollView] frame].origin.y forEdge: NSMinYEdge];
72
70
    
73
71
    //initially sort peer table by date
74
72
    if ([[fMessageTable sortDescriptors] count] == 0)
160
158
        NSDictionary * message  = [NSDictionary dictionaryWithObjectsAndKeys:
161
159
                                    [NSString stringWithUTF8String: currentMessage->message], @"Message",
162
160
                                    [NSDate dateWithTimeIntervalSince1970: currentMessage->when], @"Date",
163
 
                                    [NSNumber numberWithUnsignedInt: fIndex], @"Index", //more accurate when sorting by date
 
161
                                    [NSNumber numberWithUnsignedInt: fIndex++], @"Index", //more accurate when sorting by date
164
162
                                    [NSNumber numberWithInt: currentMessage->level], @"Level",
165
163
                                    name, @"Name",
166
164
                                    [NSString stringWithUTF8String: currentMessage->file], @"File",
167
165
                                    [NSNumber numberWithInt: currentMessage->line], @"Line", nil];
168
166
                                
169
167
        [fMessages addObject: message];
170
 
        fIndex++;
171
168
    }
172
169
    
173
170
    tr_freeMessageList(messages);
235
232
    if (!fAttributes)
236
233
        fAttributes = [[[[column dataCell] attributedStringValue] attributesAtIndex: 0 effectiveRange: NULL] retain];
237
234
    
238
 
    CGFloat count = floorf([[[fMessages objectAtIndex: row] objectForKey: @"Message"] sizeWithAttributes: fAttributes].width
239
 
                            / [column width]);
240
 
    return [tableView rowHeight] * (count + 1.0f);
 
235
    const CGFloat count = floorf([[[fMessages objectAtIndex: row] objectForKey: @"Message"] sizeWithAttributes: fAttributes].width
 
236
                                / [column width]);
 
237
    return [tableView rowHeight] * (count + 1.0);
241
238
}
242
239
 
243
240
- (void) tableView: (NSTableView *) tableView sortDescriptorsDidChange: (NSArray *) oldDescriptors
261
258
    NSIndexSet * indexes = [fMessageTable selectedRowIndexes];
262
259
    NSMutableArray * messageStrings = [NSMutableArray arrayWithCapacity: [indexes count]];
263
260
    
264
 
    NSEnumerator * enumerator = [[fMessages objectsAtIndexes: indexes] objectEnumerator];
265
 
    NSDictionary * message;
266
 
    while ((message = [enumerator nextObject]))
 
261
    for (NSDictionary * message in [fMessages objectsAtIndexes: indexes])
267
262
        [messageStrings addObject: [self stringForMessage: message]];
268
263
    
269
264
    [pb setString: [messageStrings componentsJoinedByString: @"\n"] forType: NSStringPboardType];
317
312
    
318
313
    //create the text to output
319
314
    NSMutableArray * messageStrings = [NSMutableArray arrayWithCapacity: [fMessages count]];
320
 
    NSEnumerator * enumerator = [sortedMessages objectEnumerator];
321
 
    NSDictionary * message;
322
 
    while ((message = [enumerator nextObject]))
 
315
    for (NSDictionary * message in sortedMessages)
323
316
        [messageStrings addObject: [self stringForMessage: message]];
324
317
    
325
318
    NSString * fileString = [[messageStrings componentsJoinedByString: @"\n"] retain];