Changeset 12483


Ignore:
Timestamp:
May 31, 2011, 10:26:04 PM (10 years ago)
Author:
livings124
Message:

have FileListNodes? store their corresponding torrents, allowing the removal of this functionality from the file outline view

Location:
trunk/macosx
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/FileListNode.h

    r12453 r12483  
    2525#import <Cocoa/Cocoa.h>
    2626
     27@class Torrent;
     28
    2729@interface FileListNode : NSObject <NSCopying>
    2830{
     
    3537   
    3638    NSMutableArray * fChildren;
     39   
     40    Torrent * fTorrent;
    3741}
    3842
    39 - (id) initWithFolderName: (NSString *) name path: (NSString *) path;
    40 - (id) initWithFileName: (NSString *) name path: (NSString *) path size: (uint64_t) size index: (NSUInteger) index;
     43- (id) initWithFolderName: (NSString *) name path: (NSString *) path torrent: (Torrent *) torrent;
     44- (id) initWithFileName: (NSString *) name path: (NSString *) path size: (uint64_t) size index: (NSUInteger) index torrent: (Torrent *) torrent;
    4145
    4246- (void) insertChild: (FileListNode *) child;
     
    5559- (NSMutableArray *) children;
    5660
     61- (Torrent *) torrent;
     62
    5763@end
  • trunk/macosx/FileListNode.m

    r12453 r12483  
    2727@interface FileListNode (Private)
    2828
    29 - (id) initWithFolder: (BOOL) isFolder name: (NSString *) name path: (NSString *) path;
     29- (id) initWithFolder: (BOOL) isFolder name: (NSString *) name path: (NSString *) path torrent: (Torrent *) torrent;
    3030
    3131@end
     
    3333@implementation FileListNode
    3434
    35 - (id) initWithFolderName: (NSString *) name path: (NSString *) path
     35- (id) initWithFolderName: (NSString *) name path: (NSString *) path torrent: (Torrent *) torrent
    3636{
    37     if ((self = [self initWithFolder: YES name: name path: path]))
     37    if ((self = [self initWithFolder: YES name: name path: path torrent: torrent]))
    3838    {
    3939        fChildren = [[NSMutableArray alloc] init];
     
    4444}
    4545
    46 - (id) initWithFileName: (NSString *) name path: (NSString *) path size: (uint64_t) size index: (NSUInteger) index
     46- (id) initWithFileName: (NSString *) name path: (NSString *) path size: (uint64_t) size index: (NSUInteger) index torrent: (Torrent *) torrent
    4747{
    48     if ((self = [self initWithFolder: NO name: name path: path]))
     48    if ((self = [self initWithFolder: NO name: name path: path torrent: torrent]))
    4949    {
    5050        fSize = size;
     
    137137}
    138138
     139- (Torrent *) torrent
     140{
     141    return fTorrent;
     142}
     143
    139144@end
    140145
    141146@implementation FileListNode (Private)
    142147
    143 - (id) initWithFolder: (BOOL) isFolder name: (NSString *) name path: (NSString *) path
     148- (id) initWithFolder: (BOOL) isFolder name: (NSString *) name path: (NSString *) path torrent: (Torrent *) torrent
    144149{
    145150    if ((self = [super init]))
     
    150155       
    151156        fIndexes = [[NSMutableIndexSet alloc] init];
     157       
     158        fTorrent = torrent;
    152159    }
    153160   
  • trunk/macosx/FileNameCell.m

    r11617 r12483  
    130130    if ([self backgroundStyle] == NSBackgroundStyleDark)
    131131        titleColor = statusColor = [NSColor whiteColor];
    132     else if ([[(FileOutlineView *)[self controlView] torrent] checkForFiles: [(FileListNode *)[self objectValue] indexes]] == NSOffState)
     132    else if ([[(FileListNode *)[self objectValue] torrent] checkForFiles: [(FileListNode *)[self objectValue] indexes]] == NSOffState)
    133133        titleColor = statusColor = [NSColor disabledControlTextColor];
    134134    else
     
    208208- (NSAttributedString *) attributedStatus
    209209{
    210     Torrent * torrent = [(FileOutlineView *)[self controlView] torrent];
    211210    FileListNode * node = (FileListNode *)[self objectValue];
     211    Torrent * torrent = [node torrent];
    212212   
    213213    const CGFloat progress = [torrent fileProgress: node];
  • trunk/macosx/FileOutlineController.m

    r12433 r12483  
    8585{
    8686    fTorrent = torrent;
    87     [fOutline setTorrent: fTorrent];
    8887   
    8988    [fFileList release];
  • trunk/macosx/FileOutlineView.h

    r12474 r12483  
    2929@interface FileOutlineView : NSOutlineView
    3030{
    31     Torrent * fTorrent;
    32    
    3331    NSInteger fMouseRow;
    3432}
    35 
    36 - (void) setTorrent: (Torrent *) torrent;
    37 - (Torrent *) torrent;
    3833
    3934- (NSRect) iconRectForRow: (int) row;
  • trunk/macosx/FileOutlineView.m

    r12474 r12483  
    5353{
    5454    [super dealloc];
    55 }
    56 
    57 #warning needed?
    58 - (void) setTorrent: (Torrent *) torrent
    59 {
    60     fTorrent = torrent;
    61 }
    62 
    63 - (Torrent *) torrent
    64 {
    65     return fTorrent;
    6655}
    6756
  • trunk/macosx/FilePriorityCell.m

    r12473 r12483  
    8282    }
    8383   
     84    Torrent * torrent = [(FileListNode *)[self representedObject] torrent];
     85    [torrent setFilePriority: priority forIndexes: [(FileListNode *)[self representedObject] indexes]];
     86   
    8487    FileOutlineView * controlView = (FileOutlineView *)[self controlView];
    85     Torrent * torrent = [controlView torrent];
    86     [torrent setFilePriority: priority forIndexes: [(FileListNode *)[self representedObject] indexes]];
    8788    [controlView reloadData];
    8889}
     
    111112- (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) controlView
    112113{
    113     Torrent * torrent = [(FileOutlineView *)controlView torrent];
    114114    FileListNode * node = [self representedObject];
     115    Torrent * torrent = [node torrent];
    115116    NSSet * priorities = [torrent filePrioritiesForIndexes: [node indexes]];
    116117   
  • trunk/macosx/Torrent.m

    r12325 r12483  
    17191719                if (!node)
    17201720                {
    1721                     node = [[FileListNode alloc] initWithFolderName: name path: path];
     1721                    node = [[FileListNode alloc] initWithFolderName: name path: path torrent: self];
    17221722                    [fileList addObject: node];
    17231723                    [node release];
     
    17321732            else
    17331733            {
    1734                 FileListNode * node = [[FileListNode alloc] initWithFileName: name path: path size: file->length index: i];
     1734                FileListNode * node = [[FileListNode alloc] initWithFileName: name path: path size: file->length index: i torrent: self];
    17351735                [fileList addObject: node];
    17361736                [flatFileList addObject: node];
     
    17471747    else
    17481748    {
    1749         FileListNode * node = [[FileListNode alloc] initWithFileName: [self name] path: @"" size: [self size] index: 0];
     1749        FileListNode * node = [[FileListNode alloc] initWithFileName: [self name] path: @"" size: [self size] index: 0 torrent: self];
    17501750        fFileList = [[NSArray arrayWithObject: node] retain];
    17511751        fFlatFileList = [fFileList retain];
     
    17731773        NSString * path = [[parent path] stringByAppendingPathComponent: [parent name]];
    17741774        if (isFolder)
    1775             node = [[FileListNode alloc] initWithFolderName: name path: path];
     1775            node = [[FileListNode alloc] initWithFolderName: name path: path torrent: self];
    17761776        else
    17771777        {
    1778             node = [[FileListNode alloc] initWithFileName: name path: path size: size index: index];
     1778            node = [[FileListNode alloc] initWithFileName: name path: path size: size index: index torrent: self];
    17791779            [flatFileList addObject: node];
    17801780        }
Note: See TracChangeset for help on using the changeset viewer.