Ignore:
Timestamp:
Sep 11, 2006, 11:52:03 PM (16 years ago)
Author:
livings124
Message:

Use tableView:objectValueForTableColumn:row: instead of tableView:willDisplayCell:...

This required passing in a dictionary of values to display, but should make it 10.5 compatible and potentially a little more efficient. Those using Leopard please report any issues, because I don't have it to test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/TorrentCell.m

    r844 r855  
    3333- (void) placeBar: (NSImage *) barImage width: (float) width point: (NSPoint) point;
    3434- (void) buildSimpleBar: (float) width point: (NSPoint) point;
    35 - (void) buildAdvancedBar: (float) widthFloat point: (NSPoint) point;
     35//- (void) buildAdvancedBar: (float) widthFloat point: (NSPoint) point;
    3636
    3737@end
     
    102102}
    103103
    104 - (void) setTorrent: (Torrent *) torrent
    105 {
    106     fTorrent = torrent;
    107 }
    108 
    109104- (void) placeBar: (NSImage *) barImage width: (float) width point: (NSPoint) point
    110105{
     
    117112- (void) buildSimpleBar: (float) width point: (NSPoint) point
    118113{
     114    NSDictionary * info = [self objectValue];
     115
    119116    width -= 2.0;
    120     if ([fTorrent isSeeding])
     117    if ([[info objectForKey: @"Seeding"] boolValue])
    121118    {
    122119        [fProgressEndGreen compositeToPoint: point operation: NSCompositeSourceOver];
     
    130127    else
    131128    {
    132         float completedWidth = [fTorrent progress] * width,
     129        float completedWidth = [[info objectForKey: @"Progress"] floatValue] * width,
    133130                remainingWidth = width - completedWidth;
    134         BOOL isActive = [fTorrent isActive];
     131        BOOL isActive = [[info objectForKey: @"Active"] boolValue];
    135132       
    136133        //left end
     
    167164}
    168165
    169 - (void) buildAdvancedBar: (float) widthFloat point: (NSPoint) point
     166/*- (void) buildAdvancedBar: (float) widthFloat point: (NSPoint) point
    170167{
    171168    //if seeding, there's no need for the advanced bar
     
    271268    point.x += widthFloat;
    272269    [fProgressEndAdvanced compositeToPoint: point operation: NSCompositeSourceOver];
    273 }
     270}*/
    274271
    275272- (void) toggleMinimalStatus
     
    292289    NSPoint pen = cellFrame.origin;
    293290    const float PADDING = 3.0, LINE_PADDING = 2.0, EXTRA_NAME_SHIFT = 1.0;
    294 
     291   
     292    NSDictionary * info = [self objectValue];
     293   
    295294    if (![fDefaults boolForKey: @"SmallView"]) //regular size
    296295    {
    297296        //icon
    298         NSImage * icon = [fTorrent iconFlipped];
     297        NSImage * icon = [info objectForKey: @"Icon"];
    299298        NSSize iconSize = [icon size];
    300299       
     
    306305       
    307306        //error badge
    308         if ([fTorrent isError])
     307        if ([[info objectForKey: @"Error"] boolValue])
    309308        {
    310309            NSSize errorIconSize = [fErrorImage size];
     
    320319        pen.x += iconSize.width + PADDING + EXTRA_NAME_SHIFT;
    321320        pen.y = cellFrame.origin.y + PADDING;
    322         NSAttributedString * nameString = [[fTorrent name] attributedStringFittingInWidth: mainWidth
     321        NSAttributedString * nameString = [[info objectForKey: @"Name"] attributedStringFittingInWidth: mainWidth
    323322                                                attributes: nameAttributes];
    324323        [nameString drawAtPoint: pen];
     
    327326        pen.y += [nameString size].height + LINE_PADDING - 1.0;
    328327       
    329         NSAttributedString * progressString = [[fTorrent progressString]
     328        NSAttributedString * progressString = [[info objectForKey: @"ProgressString"]
    330329            attributedStringFittingInWidth: mainWidth attributes: statusAttributes];
    331330        [progressString drawAtPoint: pen];
     
    337336        float barWidth = mainWidth + EXTRA_NAME_SHIFT - BUTTONS_TOTAL_WIDTH + PADDING;
    338337       
    339         if ([fDefaults boolForKey: @"UseAdvancedBar"])
     338        /*if ([fDefaults boolForKey: @"UseAdvancedBar"])
    340339            [self buildAdvancedBar: barWidth point: pen];
    341         else
     340        else*/
    342341            [self buildSimpleBar: barWidth point: pen];
    343342
     
    345344        pen.x += EXTRA_NAME_SHIFT;
    346345        pen.y += LINE_PADDING;
    347         NSAttributedString * statusString = [[fTorrent statusString]
     346        NSAttributedString * statusString = [[info objectForKey: @"StatusString"]
    348347            attributedStringFittingInWidth: mainWidth attributes: statusAttributes];
    349348        [statusString drawAtPoint: pen];
     
    352351    {
    353352        //icon
    354         NSImage * icon = ![fTorrent isError] ? [fTorrent iconSmall] : fErrorImage;
     353        NSImage * icon = ![[info objectForKey: @"Error"] boolValue] ? [info objectForKey: @"Icon"] : fErrorImage;
    355354        NSSize iconSize = [icon size];
    356355       
     
    364363        float mainWidth = cellFrame.size.width - iconSize.width - 3.0 * PADDING - EXTRA_NAME_SHIFT;
    365364       
    366         NSString * realStatusString = !fStatusRegular && [fTorrent isActive] ? [fTorrent remainingTimeString]
    367                                                                             : [fTorrent shortStatusString];
     365        NSString * realStatusString = !fStatusRegular && [[info objectForKey: @"Active"] boolValue]
     366                                        ? [info objectForKey: @"RemainingTimeString"]
     367                                        : [info objectForKey: @"ShortStatusString"];
    368368       
    369369        NSAttributedString * statusString = [[[NSAttributedString alloc] initWithString: realStatusString
    370370                                                    attributes: statusAttributes] autorelease];
    371         NSAttributedString * nameString = [[fTorrent name] attributedStringFittingInWidth:
     371        NSAttributedString * nameString = [[info objectForKey: @"Name"] attributedStringFittingInWidth:
    372372                                mainWidth - [statusString size].width - LINE_PADDING attributes: nameAttributes];
    373373                     
     
    390390        float barWidth = mainWidth + EXTRA_NAME_SHIFT - BUTTONS_TOTAL_WIDTH + PADDING;
    391391       
    392         if ([fDefaults boolForKey: @"UseAdvancedBar"])
     392        /*if ([fDefaults boolForKey: @"UseAdvancedBar"])
    393393            [self buildAdvancedBar: barWidth point: pen];
    394         else
     394        else*/
    395395            [self buildSimpleBar: barWidth point: pen];
    396396    }
Note: See TracChangeset for help on using the changeset viewer.