Changeset 5904


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

Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Transmission.xcodeproj/project.pbxproj

    r5898 r5904  
    143143                A26E75960CB6AB4800226674 /* InfoGeneral.png in Resources */ = {isa = PBXBuildFile; fileRef = A26E75950CB6AB4800226674 /* InfoGeneral.png */; };
    144144                A2710E770A86796000CE4F7D /* PrefsWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = A2710E750A86796000CE4F7D /* PrefsWindow.m */; };
     145                A2725B6E0DE5C4F5003445E7 /* FileListNode.m in Sources */ = {isa = PBXBuildFile; fileRef = A2725B6D0DE5C4F5003445E7 /* FileListNode.m */; };
    145146                A277DA0B0C693D9C00DA2CD4 /* ActionOn.png in Resources */ = {isa = PBXBuildFile; fileRef = A277DA090C693D9C00DA2CD4 /* ActionOn.png */; };
    146147                A29576030D11D63C0093B167 /* Creator.xib in Resources */ = {isa = PBXBuildFile; fileRef = A29576010D11D63C0093B167 /* Creator.xib */; };
     
    582583                A2710E740A86796000CE4F7D /* PrefsWindow.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PrefsWindow.h; path = macosx/PrefsWindow.h; sourceTree = "<group>"; };
    583584                A2710E750A86796000CE4F7D /* PrefsWindow.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = PrefsWindow.m; path = macosx/PrefsWindow.m; sourceTree = "<group>"; };
     585                A2725B6C0DE5C4F5003445E7 /* FileListNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileListNode.h; sourceTree = "<group>"; };
     586                A2725B6D0DE5C4F5003445E7 /* FileListNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FileListNode.m; sourceTree = "<group>"; };
    584587                A27476FF0CC38EE6003CC76D /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = macosx/es.lproj/InfoPlist.strings; sourceTree = "<group>"; };
    585588                A27477010CC38EE6003CC76D /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = macosx/es.lproj/Localizable.strings; sourceTree = "<group>"; };
     
    906909                                4DCCBB3D09C3D71100D3CABF /* TorrentCell.h */,
    907910                                4DCCBB3C09C3D71100D3CABF /* TorrentCell.m */,
     911                                A2725B6C0DE5C4F5003445E7 /* FileListNode.h */,
     912                                A2725B6D0DE5C4F5003445E7 /* FileListNode.m */,
    908913                                A25AFDE70D1038AD0092A1BA /* MenuLabel.h */,
    909914                                A25AFDE80D1038AD0092A1BA /* MenuLabel.m */,
     
    19982003                                A2D307A40D9EC6870051FD27 /* BlocklistDownloader.m in Sources */,
    19992004                                A2DF57740DE46A6A000795D5 /* QuickLookController.m in Sources */,
     2005                                A2725B6E0DE5C4F5003445E7 /* FileListNode.m in Sources */,
    20002006                        );
    20012007                        runOnlyForDeploymentPostprocessing = 0;
  • 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];
  • trunk/macosx/FileOutlineController.m

    r5872 r5904  
    2727#import "FileOutlineView.h"
    2828#import "FilePriorityCell.h"
     29#import "FileListNode.h"
    2930#import "QuickLookController.h"
    3031#import "NSApplicationAdditions.h"
     
    102103        return fTorrent ? [[fTorrent fileList] count] : 0;
    103104    else
    104         return [[item objectForKey: @"IsFolder"] boolValue] ? [[item objectForKey: @"Children"] count] : 0;
     105    {
     106        FileListNode * node = (FileListNode *)item;
     107        return [node isFolder] ? [[node children] count] : 0;
     108    }
    105109}
    106110
    107111- (BOOL) outlineView: (NSOutlineView *) outlineView isItemExpandable: (id) item
    108112{
    109     return [[item objectForKey: @"IsFolder"] boolValue];
     113    return [(FileListNode *)item isFolder];
    110114}
    111115
    112116- (id) outlineView: (NSOutlineView *) outlineView child: (int) index ofItem: (id) item
    113117{
    114     return [(item ? [item objectForKey: @"Children"] : [fTorrent fileList]) objectAtIndex: index];
     118    return [(item ? [(FileListNode *)item children] : [fTorrent fileList]) objectAtIndex: index];
    115119}
    116120
     
    118122{
    119123    if ([[tableColumn identifier] isEqualToString: @"Check"])
    120         return [NSNumber numberWithInt: [fTorrent checkForFiles: [item objectForKey: @"Indexes"]]];
     124        return [NSNumber numberWithInt: [fTorrent checkForFiles: [(FileListNode *)item indexes]]];
    121125    else
    122126        return item;
     
    128132    NSString * identifier = [tableColumn identifier];
    129133    if ([identifier isEqualToString: @"Check"])
    130         [cell setEnabled: [fTorrent canChangeDownloadCheckForFiles: [item objectForKey: @"Indexes"]]];
     134        [cell setEnabled: [fTorrent canChangeDownloadCheckForFiles: [(FileListNode *)item indexes]]];
    131135    else if ([identifier isEqualToString: @"Priority"])
    132136    {
     
    149153            indexSet = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fTorrent fileCount])];
    150154        else
    151             indexSet = [item objectForKey: @"Indexes"];
     155            indexSet = [(FileListNode *)item indexes];
    152156       
    153157        [fTorrent setFileCheckState: [object intValue] != NSOffState ? NSOnState : NSOffState forIndexes: indexSet];
     
    160164- (NSString *) outlineView: (NSOutlineView *) outlineView typeSelectStringForTableColumn: (NSTableColumn *) tableColumn item: (id) item
    161165{
    162     return [item objectForKey: @"Name"];
     166    return [(FileListNode *)item name];
    163167}
    164168
     
    168172    NSString * ident = [tableColumn identifier];
    169173    if ([ident isEqualToString: @"Name"])
    170         return [[fTorrent downloadFolder] stringByAppendingPathComponent: [item objectForKey: @"Path"]];
     174        return [[fTorrent downloadFolder] stringByAppendingPathComponent: [(FileListNode *)item fullPath]];
    171175    else if ([ident isEqualToString: @"Check"])
    172176    {
     
    183187    else if ([ident isEqualToString: @"Priority"])
    184188    {
    185         NSSet * priorities = [fTorrent filePrioritiesForIndexes: [item objectForKey: @"Indexes"]];
     189        NSSet * priorities = [fTorrent filePrioritiesForIndexes: [(FileListNode *)item indexes]];
    186190        switch ([priorities count])
    187191        {
     
    210214- (float) outlineView: (NSOutlineView *) outlineView heightOfRowByItem: (id) item
    211215{
    212     if ([[item objectForKey: @"IsFolder"] boolValue])
     216    if ([(FileListNode *)item isFolder])
    213217        return ROW_SMALL_HEIGHT;
    214218    else
     
    224228    int i;
    225229    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    226         [itemIndexes addIndexes: [[fOutline itemAtRow: i] objectForKey: @"Indexes"]];
     230        [itemIndexes addIndexes: [[fOutline itemAtRow: i] indexes]];
    227231   
    228232    [fTorrent setFileCheckState: state forIndexes: itemIndexes];
     
    236240    int i;
    237241    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    238         [itemIndexes addIndexes: [[fOutline itemAtRow: i] objectForKey: @"Indexes"]];
     242        [itemIndexes addIndexes: [[fOutline itemAtRow: i] indexes]];
    239243   
    240244    [fTorrent setFileCheckState: NSOnState forIndexes: itemIndexes];
     
    266270    int i;
    267271    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    268         [itemIndexes addIndexes: [[fOutline itemAtRow: i] objectForKey: @"Indexes"]];
     272        [itemIndexes addIndexes: [[fOutline itemAtRow: i] indexes]];
    269273   
    270274    [fTorrent setFilePriority: priority forIndexes: itemIndexes];
     
    279283    for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
    280284        [[NSWorkspace sharedWorkspace] selectFile: [folder stringByAppendingPathComponent:
    281                 [[fOutline itemAtRow: i] objectForKey: @"Path"]] inFileViewerRootedAtPath: nil];
     285            [[fOutline itemAtRow: i] fullPath]] inFileViewerRootedAtPath: nil];
    282286}
    283287
     
    297301        for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    298302            if ([[NSFileManager defaultManager] fileExistsAtPath:
    299                     [downloadFolder stringByAppendingPathComponent: [[[fTorrent fileList] objectAtIndex: i] objectForKey: @"Path"]]])
     303                    [downloadFolder stringByAppendingPathComponent: [[[fTorrent fileList] objectAtIndex: i] fullPath]]])
    300304                return YES;
    301305        return NO;
     
    311315        int i, state = ([menuItem tag] == FILE_CHECK_TAG) ? NSOnState : NSOffState;
    312316        for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    313             [itemIndexes addIndexes: [[fOutline itemAtRow: i] objectForKey: @"Indexes"]];
     317            [itemIndexes addIndexes: [[fOutline itemAtRow: i] indexes]];
    314318       
    315319        return [fTorrent checkForFiles: itemIndexes] != state && [fTorrent canChangeDownloadCheckForFiles: itemIndexes];
     
    325329        int i;
    326330        for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    327             [itemIndexes addIndexes: [[fOutline itemAtRow: i] objectForKey: @"Indexes"]];
     331            [itemIndexes addIndexes: [[fOutline itemAtRow: i] indexes]];
    328332           
    329333        return [fTorrent canChangeDownloadCheckForFiles: itemIndexes];
     
    358362        for (i = [indexSet firstIndex]; i != NSNotFound && (!current || !other); i = [indexSet indexGreaterThanIndex: i])
    359363        {
    360             fileIndexSet = [[fOutline itemAtRow: i] objectForKey: @"Indexes"];
     364            fileIndexSet = [[fOutline itemAtRow: i] indexes];
    361365            if (![fTorrent canChangeDownloadCheckForFiles: fileIndexSet])
    362366                continue;
  • trunk/macosx/FileOutlineView.m

    r5898 r5904  
    2727#import "FilePriorityCell.h"
    2828#import "Torrent.h"
     29#import "FileListNode.h"
    2930#import "QuickLookController.h"
    3031#import "CTGradient.h"
     
    180181    {
    181182        NSDictionary * item = [self itemAtRow: row];
    182         NSIndexSet * indexes = [item objectForKey: @"Indexes"];
     183        NSIndexSet * indexes = [(FileListNode *)item indexes];
    183184       
    184185        if ([fTorrent checkForFiles: indexes] != NSOffState)
  • trunk/macosx/FilePriorityCell.m

    r5382 r5904  
    2525#import "FilePriorityCell.h"
    2626#import "FileOutlineView.h"
     27#import "FileListNode.h"
    2728#import "Torrent.h"
    2829
     
    7475    FileOutlineView * controlView = (FileOutlineView *)[self controlView];
    7576    Torrent * torrent = [controlView torrent];
    76     [torrent setFilePriority: priority forIndexes: [[self representedObject] objectForKey: @"Indexes"]];
     77    [torrent setFilePriority: priority forIndexes: [(FileListNode *)[self representedObject] indexes]];
    7778    [controlView reloadData];
    7879}
     
    102103{
    103104    Torrent * torrent = [(FileOutlineView *)controlView torrent];
    104     NSDictionary * dict = [self representedObject];
    105     NSSet * priorities = [torrent filePrioritiesForIndexes: [dict objectForKey: @"Indexes"]];
     105    FileListNode * node = [self representedObject];
     106    NSSet * priorities = [torrent filePrioritiesForIndexes: [node indexes]];
    106107   
    107108    int count = [priorities count];
  • trunk/macosx/InfoWindowController.m

    r5898 r5904  
    2626#import "InfoTabButtonCell.h"
    2727#import "FileOutlineView.h"
     28#import "FileListNode.h"
    2829#import "QuickLookController.h"
    2930#import "NSApplicationAdditions.h"
     
    908909    for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
    909910    {
    910         NSDictionary * item = [fileOutlineView itemAtRow: i];
    911         if ([[item objectForKey: @"IsFolder"] boolValue] || [torrent fileProgress: [[item objectForKey: @"Indexes"] firstIndex]] == 1.0)
    912             [urlArray addObject: [NSURL fileURLWithPath: [folder stringByAppendingPathComponent: [item objectForKey: @"Path"]]]];
     911        FileListNode * item = [fileOutlineView itemAtRow: i];
     912        if ([item isFolder] || [torrent fileProgress: [[item indexes] firstIndex]] == 1.0)
     913            [urlArray addObject: [NSURL fileURLWithPath: [folder stringByAppendingPathComponent: [item fullPath]]]];
    913914    }
    914915   
     
    925926    for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
    926927    {
    927         NSDictionary * item = [fileOutlineView itemAtRow: i];
    928         if ([[item objectForKey: @"IsFolder"] boolValue] || [torrent fileProgress: [[item objectForKey: @"Indexes"] firstIndex]] == 1.0)
     928        FileListNode * item = [fileOutlineView itemAtRow: i];
     929        if ([item isFolder] || [torrent fileProgress: [[item indexes] firstIndex]] == 1.0)
    929930            return YES;
    930931    }
     
    944945    for (row = visibleRows.location; row < NSMaxRange(visibleRows); row++)
    945946    {
    946         id rowItem = [fileOutlineView itemAtRow: row];
    947         if ([[folder stringByAppendingPathComponent: [rowItem objectForKey: @"Path"]] isEqualToString: fullPath])
     947        FileListNode * rowItem = [fileOutlineView itemAtRow: row];
     948        if ([[folder stringByAppendingPathComponent: [rowItem fullPath]] isEqualToString: fullPath])
    948949        {
    949950            NSRect frame = [fileOutlineView iconRectForRow: row];
  • trunk/macosx/QuickLookController.h

    r5885 r5904  
    22 * $Id$
    33 *
    4  * Copyright (c) 2007-2008 Transmission authors and contributors
     4 * Copyright (c) 2008 Transmission authors and contributors
    55 *
    66 * Permission is hereby granted, free of charge, to any person obtaining a
  • trunk/macosx/QuickLookController.m

    r5885 r5904  
    22 * $Id$
    33 *
    4  * Copyright (c) 2007-2008 Transmission authors and contributors
     4 * Copyright (c) 2008 Transmission authors and contributors
    55 *
    66 * Permission is hereby granted, free of charge, to any person obtaining a
     
    5050}
    5151
    52 // This is the QuickLook delegate method
    53 // It should return the frame for the item represented by the URL
    54 // If an empty frame is returned then the panel will fade in/out instead
     52//QuickLook delegate method
     53//returns the frame for the item represented by the URL, or an empty frame to fade in/out instead
    5554- (NSRect) previewPanel: (NSPanel *) panel frameForURL: (NSURL *) url
    5655{
     
    6665        return NO;
    6766   
    68     NSArray * urlArray = nil;
    69    
     67    NSArray * urlArray;
    7068    if ([fInfoController shouldQuickLookFileView])
    7169        urlArray = [fInfoController quickLookURLs];
     
    7573    if (urlArray && [urlArray count] > 0)
    7674    {
    77         [[QLPreviewPanel sharedPreviewPanel] setURLs: urlArray currentIndex: 0 preservingDisplayState: YES];
     75        [[QLPreviewPanel sharedPreviewPanel] setURLs: urlArray];
    7876        return YES;
    7977    }
     
    8482- (BOOL) canQuickLook
    8583{
     84    if (!fQuickLookAvailable)
     85        return NO;
     86   
    8687    if ([fInfoController shouldQuickLookFileView])
    8788        return [fInfoController canQuickLook];
  • trunk/macosx/Torrent.m

    r5902 r5904  
    2525#import "Torrent.h"
    2626#import "GroupsController.h"
     27#import "FileListNode.h"
    2728#import "NSApplicationAdditions.h"
    2829#import "NSStringAdditions.h"
     
    4445
    4546- (void) createFileList;
    46 - (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings previousPath: (NSString *) previousPath
    47             fileSize: (uint64_t) size index: (int) index;
     47- (void) insertPath: (NSMutableArray *) components forParent: (FileListNode *) parent fileSize: (uint64_t) size index: (int) index;
    4848
    4949- (void) completenessChange: (NSNumber *) status;
     
    16491649- (void) createFileList
    16501650{
    1651     int count = [self fileCount], i;
    1652     NSMutableArray * fileList = [[NSMutableArray alloc] initWithCapacity: count];
    1653    
    1654     for (i = 0; i < count; i++)
    1655     {
    1656         tr_file * file = &fInfo->files[i];
    1657        
    1658         NSMutableArray * pathComponents = [[[NSString stringWithUTF8String: file->name] pathComponents] mutableCopy];
    1659         NSString * path;
    1660         if ([self folder])
    1661         {
    1662             path = [pathComponents objectAtIndex: 0];
    1663             [pathComponents removeObjectAtIndex: 0];
    1664         }
    1665         else
    1666             path = @"";
    1667        
    1668         [self insertPath: pathComponents forSiblings: fileList previousPath: path fileSize: file->length index: i];
    1669         [pathComponents release];
    1670     }
    1671    
    1672     fFileList = [[NSArray alloc] initWithArray: fileList];
    1673     [fileList release];
    1674 }
    1675 
    1676 - (void) insertPath: (NSMutableArray *) components forSiblings: (NSMutableArray *) siblings previousPath: (NSString *) previousPath
    1677             fileSize: (uint64_t) size index: (int) index
     1651    if ([self folder])
     1652    {
     1653        int count = [self fileCount], i;
     1654        NSMutableArray * fileList = [[NSMutableArray alloc] initWithCapacity: count];
     1655       
     1656        for (i = 0; i < count; i++)
     1657        {
     1658            tr_file * file = &fInfo->files[i];
     1659           
     1660            NSMutableArray * pathComponents = [[[NSString stringWithUTF8String: file->name] pathComponents] mutableCopy];
     1661            NSString * path = [pathComponents objectAtIndex: 0];
     1662            NSString * name = [pathComponents objectAtIndex: 1];
     1663            [pathComponents removeObjectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, 2)]];
     1664           
     1665            if ([pathComponents count] > 0)
     1666            {
     1667                //determine if node already exists
     1668                NSEnumerator * enumerator = [fileList objectEnumerator];
     1669                FileListNode * node;
     1670                while ((node = [enumerator nextObject]))
     1671                    if ([[node name] isEqualToString: name])
     1672                        break;
     1673               
     1674                if (!node)
     1675                {
     1676                    node = [[FileListNode alloc] initWithFolderName: name path: path];
     1677                    [fileList addObject: node];
     1678                    [node release];
     1679                }
     1680               
     1681                [self insertPath: pathComponents forParent: node fileSize: file->length index: i];
     1682            }
     1683            else
     1684            {
     1685                FileListNode * node = [[FileListNode alloc] initWithFileName: name path: path size: file->length index: i];
     1686                [fileList addObject: node];
     1687                [node release];
     1688            }
     1689           
     1690            [pathComponents release];
     1691        }
     1692       
     1693        fFileList = [[NSArray alloc] initWithArray: fileList];
     1694        [fileList release];
     1695    }
     1696    else
     1697    {
     1698        FileListNode * node = [[FileListNode alloc] initWithFileName: [self name] path: @"" size: [self size] index: 0];
     1699        fFileList = [[NSArray arrayWithObject: node] retain];
     1700        [node release];
     1701    }
     1702}
     1703
     1704- (void) insertPath: (NSMutableArray *) components forParent: (FileListNode *) parent fileSize: (uint64_t) size index: (int) index
    16781705{
    16791706    NSString * name = [components objectAtIndex: 0];
    16801707    BOOL isFolder = [components count] > 1;
    16811708   
    1682     NSMutableDictionary * dict = nil;
     1709    FileListNode * node = nil;
    16831710    if (isFolder)
    16841711    {
    1685         NSEnumerator * enumerator = [siblings objectEnumerator];
    1686         while ((dict = [enumerator nextObject]))
    1687             if ([[dict objectForKey: @"Name"] isEqualToString: name] && [[dict objectForKey: @"IsFolder"] boolValue])
     1712        NSEnumerator * enumerator = [[parent children] objectEnumerator];
     1713        while ((node = [enumerator nextObject]))
     1714            if ([[node name] isEqualToString: name] && [node isFolder])
    16881715                break;
    16891716    }
    16901717   
    1691     NSString * currentPath = [previousPath stringByAppendingPathComponent: name];
    1692    
    1693     //create new folder or item if it doesn't already exist
    1694     if (!dict)
    1695     {
    1696         dict = [NSMutableDictionary dictionaryWithObjectsAndKeys: name, @"Name",
    1697                 [NSNumber numberWithBool: isFolder], @"IsFolder", currentPath, @"Path", nil];
    1698         [siblings addObject: dict];
    1699        
     1718    //create new folder or file if it doesn't already exist
     1719    if (!node)
     1720    {
    17001721        if (isFolder)
    1701         {
    1702             [dict setObject: [NSMutableArray array] forKey: @"Children"];
    1703             [dict setObject: [NSMutableIndexSet indexSetWithIndex: index] forKey: @"Indexes"];
    1704         }
     1722            node = [[FileListNode alloc] initWithFolderName: name path: [parent fullPath]];
    17051723        else
    1706         {
    1707             [dict setObject: [NSIndexSet indexSetWithIndex: index] forKey: @"Indexes"];
    1708             [dict setObject: [NSNumber numberWithUnsignedLongLong: size] forKey: @"Size"];
    1709            
    1710             NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFileType: [name pathExtension]];
    1711             [icon setFlipped: YES];
    1712             [dict setObject: icon forKey: @"Icon"];
    1713         }
    1714     }
    1715     else
    1716         [[dict objectForKey: @"Indexes"] addIndex: index];
     1724            node = [[FileListNode alloc] initWithFileName: name path: [parent fullPath] size: size index: index];
     1725       
     1726        [parent insertChild: node];
     1727    }
    17171728   
    17181729    if (isFolder)
    17191730    {
     1731        [node insertIndex: index];
     1732       
    17201733        [components removeObjectAtIndex: 0];
    1721         [self insertPath: components forSiblings: [dict objectForKey: @"Children"] previousPath: currentPath fileSize: size
    1722                 index: index];
     1734        [self insertPath: components forParent: node fileSize: size index: index];
    17231735    }
    17241736}
Note: See TracChangeset for help on using the changeset viewer.