Changeset 5904
- Timestamp:
- May 22, 2008, 6:39:49 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Transmission.xcodeproj/project.pbxproj
r5898 r5904 143 143 A26E75960CB6AB4800226674 /* InfoGeneral.png in Resources */ = {isa = PBXBuildFile; fileRef = A26E75950CB6AB4800226674 /* InfoGeneral.png */; }; 144 144 A2710E770A86796000CE4F7D /* PrefsWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = A2710E750A86796000CE4F7D /* PrefsWindow.m */; }; 145 A2725B6E0DE5C4F5003445E7 /* FileListNode.m in Sources */ = {isa = PBXBuildFile; fileRef = A2725B6D0DE5C4F5003445E7 /* FileListNode.m */; }; 145 146 A277DA0B0C693D9C00DA2CD4 /* ActionOn.png in Resources */ = {isa = PBXBuildFile; fileRef = A277DA090C693D9C00DA2CD4 /* ActionOn.png */; }; 146 147 A29576030D11D63C0093B167 /* Creator.xib in Resources */ = {isa = PBXBuildFile; fileRef = A29576010D11D63C0093B167 /* Creator.xib */; }; … … 582 583 A2710E740A86796000CE4F7D /* PrefsWindow.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PrefsWindow.h; path = macosx/PrefsWindow.h; sourceTree = "<group>"; }; 583 584 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>"; }; 584 587 A27476FF0CC38EE6003CC76D /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = macosx/es.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 585 588 A27477010CC38EE6003CC76D /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = macosx/es.lproj/Localizable.strings; sourceTree = "<group>"; }; … … 906 909 4DCCBB3D09C3D71100D3CABF /* TorrentCell.h */, 907 910 4DCCBB3C09C3D71100D3CABF /* TorrentCell.m */, 911 A2725B6C0DE5C4F5003445E7 /* FileListNode.h */, 912 A2725B6D0DE5C4F5003445E7 /* FileListNode.m */, 908 913 A25AFDE70D1038AD0092A1BA /* MenuLabel.h */, 909 914 A25AFDE80D1038AD0092A1BA /* MenuLabel.m */, … … 1998 2003 A2D307A40D9EC6870051FD27 /* BlocklistDownloader.m in Sources */, 1999 2004 A2DF57740DE46A6A000795D5 /* QuickLookController.m in Sources */, 2005 A2725B6E0DE5C4F5003445E7 /* FileListNode.m in Sources */, 2000 2006 ); 2001 2007 runOnlyForDeploymentPostprocessing = 0; -
trunk/macosx/FileNameCell.m
r5581 r5904 26 26 #import "FileOutlineView.h" 27 27 #import "Torrent.h" 28 #import "FileListNode.h" 28 29 #import "NSApplicationAdditions.h" 29 30 #import "NSStringAdditions.h" … … 92 93 - (NSImage *) image 93 94 { 94 NSImage * image = [[self objectValue] objectForKey: @"Icon"]; 95 if (!image) 95 FileListNode * node = (FileListNode *)[self objectValue]; 96 NSImage * image; 97 if ([node isFolder]) 96 98 { 97 99 if (!fFolderImage) … … 102 104 image = fFolderImage; 103 105 } 106 else 107 image = [node icon]; 108 104 109 return image; 105 110 } … … 111 116 result.origin.x += PADDING_HORIZONAL; 112 117 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; 114 119 result.origin.y += (result.size.height - IMAGE_SIZE) * 0.5; 115 120 result.size = NSMakeSize(IMAGE_SIZE, IMAGE_SIZE); … … 139 144 specialColor = [NSColor whiteColor]; 140 145 else if ([[(FileOutlineView *)[self controlView] torrent] checkForFiles: 141 [ [self objectValue] objectForKey: @"Indexes"]] == NSOffState)146 [(FileListNode *)[self objectValue] indexes]] == NSOffState) 142 147 specialColor = [NSColor disabledControlTextColor]; 143 148 else; … … 148 153 149 154 //status 150 if (![ [[self objectValue] objectForKey: @"IsFolder"] boolValue])155 if (![(FileListNode *)[self objectValue] isFolder]) 151 156 { 152 157 NSAttributedString * statusString = [self attributedStatusWithColor: specialColor ? specialColor : [NSColor darkGrayColor]]; … … 166 171 NSRect result = bounds; 167 172 168 if (![ [[self objectValue] objectForKey: @"IsFolder"] boolValue])173 if (![(FileListNode *)[self objectValue] isFolder]) 169 174 { 170 175 result.origin.x += PADDING_HORIZONAL + IMAGE_ICON_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE; … … 184 189 - (NSRect) rectForStatusWithString: (NSAttributedString *) string inBounds: (NSRect) bounds 185 190 { 186 if ([ [[self objectValue] objectForKey: @"IsFolder"] boolValue])191 if ([(FileListNode *)[self objectValue] isFolder]) 187 192 return NSZeroRect; 188 193 … … 205 210 [fTitleAttributes setObject: color forKey: NSForegroundColorAttributeName]; 206 211 207 NSString * title = [ [self objectValue] objectForKey: @"Name"];212 NSString * title = [(FileListNode *)[self objectValue] name]; 208 213 return [[[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes] autorelease]; 209 214 } … … 215 220 216 221 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; 218 224 219 225 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]]]; 222 227 223 228 return [[[NSAttributedString alloc] initWithString: status attributes: fStatusAttributes] autorelease]; -
trunk/macosx/FileOutlineController.m
r5872 r5904 27 27 #import "FileOutlineView.h" 28 28 #import "FilePriorityCell.h" 29 #import "FileListNode.h" 29 30 #import "QuickLookController.h" 30 31 #import "NSApplicationAdditions.h" … … 102 103 return fTorrent ? [[fTorrent fileList] count] : 0; 103 104 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 } 105 109 } 106 110 107 111 - (BOOL) outlineView: (NSOutlineView *) outlineView isItemExpandable: (id) item 108 112 { 109 return [ [item objectForKey: @"IsFolder"] boolValue];113 return [(FileListNode *)item isFolder]; 110 114 } 111 115 112 116 - (id) outlineView: (NSOutlineView *) outlineView child: (int) index ofItem: (id) item 113 117 { 114 return [(item ? [ item objectForKey: @"Children"] : [fTorrent fileList]) objectAtIndex: index];118 return [(item ? [(FileListNode *)item children] : [fTorrent fileList]) objectAtIndex: index]; 115 119 } 116 120 … … 118 122 { 119 123 if ([[tableColumn identifier] isEqualToString: @"Check"]) 120 return [NSNumber numberWithInt: [fTorrent checkForFiles: [ item objectForKey: @"Indexes"]]];124 return [NSNumber numberWithInt: [fTorrent checkForFiles: [(FileListNode *)item indexes]]]; 121 125 else 122 126 return item; … … 128 132 NSString * identifier = [tableColumn identifier]; 129 133 if ([identifier isEqualToString: @"Check"]) 130 [cell setEnabled: [fTorrent canChangeDownloadCheckForFiles: [ item objectForKey: @"Indexes"]]];134 [cell setEnabled: [fTorrent canChangeDownloadCheckForFiles: [(FileListNode *)item indexes]]]; 131 135 else if ([identifier isEqualToString: @"Priority"]) 132 136 { … … 149 153 indexSet = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fTorrent fileCount])]; 150 154 else 151 indexSet = [ item objectForKey: @"Indexes"];155 indexSet = [(FileListNode *)item indexes]; 152 156 153 157 [fTorrent setFileCheckState: [object intValue] != NSOffState ? NSOnState : NSOffState forIndexes: indexSet]; … … 160 164 - (NSString *) outlineView: (NSOutlineView *) outlineView typeSelectStringForTableColumn: (NSTableColumn *) tableColumn item: (id) item 161 165 { 162 return [ item objectForKey: @"Name"];166 return [(FileListNode *)item name]; 163 167 } 164 168 … … 168 172 NSString * ident = [tableColumn identifier]; 169 173 if ([ident isEqualToString: @"Name"]) 170 return [[fTorrent downloadFolder] stringByAppendingPathComponent: [ item objectForKey: @"Path"]];174 return [[fTorrent downloadFolder] stringByAppendingPathComponent: [(FileListNode *)item fullPath]]; 171 175 else if ([ident isEqualToString: @"Check"]) 172 176 { … … 183 187 else if ([ident isEqualToString: @"Priority"]) 184 188 { 185 NSSet * priorities = [fTorrent filePrioritiesForIndexes: [ item objectForKey: @"Indexes"]];189 NSSet * priorities = [fTorrent filePrioritiesForIndexes: [(FileListNode *)item indexes]]; 186 190 switch ([priorities count]) 187 191 { … … 210 214 - (float) outlineView: (NSOutlineView *) outlineView heightOfRowByItem: (id) item 211 215 { 212 if ([ [item objectForKey: @"IsFolder"] boolValue])216 if ([(FileListNode *)item isFolder]) 213 217 return ROW_SMALL_HEIGHT; 214 218 else … … 224 228 int i; 225 229 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]]; 227 231 228 232 [fTorrent setFileCheckState: state forIndexes: itemIndexes]; … … 236 240 int i; 237 241 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]]; 239 243 240 244 [fTorrent setFileCheckState: NSOnState forIndexes: itemIndexes]; … … 266 270 int i; 267 271 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]]; 269 273 270 274 [fTorrent setFilePriority: priority forIndexes: itemIndexes]; … … 279 283 for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i]) 280 284 [[NSWorkspace sharedWorkspace] selectFile: [folder stringByAppendingPathComponent: 281 [[fOutline itemAtRow: i] objectForKey: @"Path"]] inFileViewerRootedAtPath: nil];285 [[fOutline itemAtRow: i] fullPath]] inFileViewerRootedAtPath: nil]; 282 286 } 283 287 … … 297 301 for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i]) 298 302 if ([[NSFileManager defaultManager] fileExistsAtPath: 299 [downloadFolder stringByAppendingPathComponent: [[[fTorrent fileList] objectAtIndex: i] objectForKey: @"Path"]]])303 [downloadFolder stringByAppendingPathComponent: [[[fTorrent fileList] objectAtIndex: i] fullPath]]]) 300 304 return YES; 301 305 return NO; … … 311 315 int i, state = ([menuItem tag] == FILE_CHECK_TAG) ? NSOnState : NSOffState; 312 316 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]]; 314 318 315 319 return [fTorrent checkForFiles: itemIndexes] != state && [fTorrent canChangeDownloadCheckForFiles: itemIndexes]; … … 325 329 int i; 326 330 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]]; 328 332 329 333 return [fTorrent canChangeDownloadCheckForFiles: itemIndexes]; … … 358 362 for (i = [indexSet firstIndex]; i != NSNotFound && (!current || !other); i = [indexSet indexGreaterThanIndex: i]) 359 363 { 360 fileIndexSet = [[fOutline itemAtRow: i] objectForKey: @"Indexes"];364 fileIndexSet = [[fOutline itemAtRow: i] indexes]; 361 365 if (![fTorrent canChangeDownloadCheckForFiles: fileIndexSet]) 362 366 continue; -
trunk/macosx/FileOutlineView.m
r5898 r5904 27 27 #import "FilePriorityCell.h" 28 28 #import "Torrent.h" 29 #import "FileListNode.h" 29 30 #import "QuickLookController.h" 30 31 #import "CTGradient.h" … … 180 181 { 181 182 NSDictionary * item = [self itemAtRow: row]; 182 NSIndexSet * indexes = [ item objectForKey: @"Indexes"];183 NSIndexSet * indexes = [(FileListNode *)item indexes]; 183 184 184 185 if ([fTorrent checkForFiles: indexes] != NSOffState) -
trunk/macosx/FilePriorityCell.m
r5382 r5904 25 25 #import "FilePriorityCell.h" 26 26 #import "FileOutlineView.h" 27 #import "FileListNode.h" 27 28 #import "Torrent.h" 28 29 … … 74 75 FileOutlineView * controlView = (FileOutlineView *)[self controlView]; 75 76 Torrent * torrent = [controlView torrent]; 76 [torrent setFilePriority: priority forIndexes: [ [self representedObject] objectForKey: @"Indexes"]];77 [torrent setFilePriority: priority forIndexes: [(FileListNode *)[self representedObject] indexes]]; 77 78 [controlView reloadData]; 78 79 } … … 102 103 { 103 104 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]]; 106 107 107 108 int count = [priorities count]; -
trunk/macosx/InfoWindowController.m
r5898 r5904 26 26 #import "InfoTabButtonCell.h" 27 27 #import "FileOutlineView.h" 28 #import "FileListNode.h" 28 29 #import "QuickLookController.h" 29 30 #import "NSApplicationAdditions.h" … … 908 909 for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i]) 909 910 { 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]]]]; 913 914 } 914 915 … … 925 926 for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i]) 926 927 { 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) 929 930 return YES; 930 931 } … … 944 945 for (row = visibleRows.location; row < NSMaxRange(visibleRows); row++) 945 946 { 946 idrowItem = [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]) 948 949 { 949 950 NSRect frame = [fileOutlineView iconRectForRow: row]; -
trunk/macosx/QuickLookController.h
r5885 r5904 2 2 * $Id$ 3 3 * 4 * Copyright (c) 200 7-2008 Transmission authors and contributors4 * Copyright (c) 2008 Transmission authors and contributors 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a -
trunk/macosx/QuickLookController.m
r5885 r5904 2 2 * $Id$ 3 3 * 4 * Copyright (c) 200 7-2008 Transmission authors and contributors4 * Copyright (c) 2008 Transmission authors and contributors 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a … … 50 50 } 51 51 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 55 54 - (NSRect) previewPanel: (NSPanel *) panel frameForURL: (NSURL *) url 56 55 { … … 66 65 return NO; 67 66 68 NSArray * urlArray = nil; 69 67 NSArray * urlArray; 70 68 if ([fInfoController shouldQuickLookFileView]) 71 69 urlArray = [fInfoController quickLookURLs]; … … 75 73 if (urlArray && [urlArray count] > 0) 76 74 { 77 [[QLPreviewPanel sharedPreviewPanel] setURLs: urlArray currentIndex: 0 preservingDisplayState: YES];75 [[QLPreviewPanel sharedPreviewPanel] setURLs: urlArray]; 78 76 return YES; 79 77 } … … 84 82 - (BOOL) canQuickLook 85 83 { 84 if (!fQuickLookAvailable) 85 return NO; 86 86 87 if ([fInfoController shouldQuickLookFileView]) 87 88 return [fInfoController canQuickLook]; -
trunk/macosx/Torrent.m
r5902 r5904 25 25 #import "Torrent.h" 26 26 #import "GroupsController.h" 27 #import "FileListNode.h" 27 28 #import "NSApplicationAdditions.h" 28 29 #import "NSStringAdditions.h" … … 44 45 45 46 - (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; 48 48 49 49 - (void) completenessChange: (NSNumber *) status; … … 1649 1649 - (void) createFileList 1650 1650 { 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 1678 1705 { 1679 1706 NSString * name = [components objectAtIndex: 0]; 1680 1707 BOOL isFolder = [components count] > 1; 1681 1708 1682 NSMutableDictionary * dict= nil;1709 FileListNode * node = nil; 1683 1710 if (isFolder) 1684 1711 { 1685 NSEnumerator * enumerator = [ siblingsobjectEnumerator];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]) 1688 1715 break; 1689 1716 } 1690 1717 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 { 1700 1721 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]]; 1705 1723 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 } 1717 1728 1718 1729 if (isFolder) 1719 1730 { 1731 [node insertIndex: index]; 1732 1720 1733 [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]; 1723 1735 } 1724 1736 }
Note: See TracChangeset
for help on using the changeset viewer.