Ignore:
Timestamp:
May 22, 2008, 6:39:49 PM (14 years ago)
Author:
livings124
Message:

use a custom class instead of a dictionary for holding a torrent's file structure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/FileNameCell.m

    r5581 r5904  
    2626#import "FileOutlineView.h"
    2727#import "Torrent.h"
     28#import "FileListNode.h"
    2829#import "NSApplicationAdditions.h"
    2930#import "NSStringAdditions.h"
     
    9293- (NSImage *) image
    9394{
    94     NSImage * image = [[self objectValue] objectForKey: @"Icon"];
    95     if (!image)
     95    FileListNode * node = (FileListNode *)[self objectValue];
     96    NSImage * image;
     97    if ([node isFolder])
    9698    {
    9799        if (!fFolderImage)
     
    102104        image = fFolderImage;
    103105    }
     106    else
     107        image = [node icon];
     108   
    104109    return image;
    105110}
     
    111116    result.origin.x += PADDING_HORIZONAL;
    112117   
    113     const float IMAGE_SIZE = [[[self objectValue] objectForKey: @"IsFolder"] boolValue] ? IMAGE_FOLDER_SIZE : IMAGE_ICON_SIZE;
     118    const float IMAGE_SIZE = [(FileListNode *)[self objectValue] isFolder] ? IMAGE_FOLDER_SIZE : IMAGE_ICON_SIZE;
    114119    result.origin.y += (result.size.height - IMAGE_SIZE) * 0.5;
    115120    result.size = NSMakeSize(IMAGE_SIZE, IMAGE_SIZE);
     
    139144        specialColor = [NSColor whiteColor];
    140145    else if ([[(FileOutlineView *)[self controlView] torrent] checkForFiles:
    141                     [[self objectValue] objectForKey: @"Indexes"]] == NSOffState)
     146                    [(FileListNode *)[self objectValue] indexes]] == NSOffState)
    142147        specialColor = [NSColor disabledControlTextColor];
    143148    else;
     
    148153   
    149154    //status
    150     if (![[[self objectValue] objectForKey: @"IsFolder"] boolValue])
     155    if (![(FileListNode *)[self objectValue] isFolder])
    151156    {
    152157        NSAttributedString * statusString = [self attributedStatusWithColor: specialColor ? specialColor : [NSColor darkGrayColor]];
     
    166171    NSRect result = bounds;
    167172   
    168     if (![[[self objectValue] objectForKey: @"IsFolder"] boolValue])
     173    if (![(FileListNode *)[self objectValue] isFolder])
    169174    {
    170175        result.origin.x += PADDING_HORIZONAL + IMAGE_ICON_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
     
    184189- (NSRect) rectForStatusWithString: (NSAttributedString *) string inBounds: (NSRect) bounds
    185190{
    186     if ([[[self objectValue] objectForKey: @"IsFolder"] boolValue])
     191    if ([(FileListNode *)[self objectValue] isFolder])
    187192        return NSZeroRect;
    188193   
     
    205210        [fTitleAttributes setObject: color forKey: NSForegroundColorAttributeName];
    206211       
    207     NSString * title = [[self objectValue] objectForKey: @"Name"];
     212    NSString * title = [(FileListNode *)[self objectValue] name];
    208213    return [[[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes] autorelease];
    209214}
     
    215220   
    216221    Torrent * torrent = [(FileOutlineView *)[self controlView] torrent];
    217     float percent = [torrent fileProgress: [[[self objectValue] objectForKey: @"Indexes"] firstIndex]] * 100.0;
     222    FileListNode * node = (FileListNode *)[self objectValue];
     223    float percent = [torrent fileProgress: [[node indexes] firstIndex]] * 100.0;
    218224   
    219225    NSString * status = [NSString localizedStringWithFormat: NSLocalizedString(@"%.2f%% of %@",
    220                             "Inspector -> Files tab -> file status string"), percent,
    221                             [NSString stringForFileSize: [[[self objectValue] objectForKey: @"Size"] unsignedLongLongValue]]];
     226                            "Inspector -> Files tab -> file status string"), percent, [NSString stringForFileSize: [node size]]];
    222227   
    223228    return [[[NSAttributedString alloc] initWithString: status attributes: fStatusAttributes] autorelease];
Note: See TracChangeset for help on using the changeset viewer.