Started cleanup of file drawer. Still needs to handle updating.
parent
40b5de5279
commit
27d9ff122a
|
@ -25,6 +25,8 @@
|
|||
1766C8970B912FB4004A7AE4 /* repeat_on.png in Resources */ = {isa = PBXBuildFile; fileRef = 1766C88F0B912FB4004A7AE4 /* repeat_on.png */; };
|
||||
1766C8980B912FB4004A7AE4 /* shuffle_off.png in Resources */ = {isa = PBXBuildFile; fileRef = 1766C8900B912FB4004A7AE4 /* shuffle_off.png */; };
|
||||
1766C8990B912FB4004A7AE4 /* shuffle_on.png in Resources */ = {isa = PBXBuildFile; fileRef = 1766C8910B912FB4004A7AE4 /* shuffle_on.png */; };
|
||||
1769D7D10CC2BFF7003F455B /* FileTreeDataSource.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1769D7CF0CC2BFF7003F455B /* FileTreeDataSource.h */; };
|
||||
1769D7D20CC2BFF7003F455B /* FileTreeDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 1769D7D00CC2BFF7003F455B /* FileTreeDataSource.m */; };
|
||||
1770429C0B8BC53600B86321 /* AppController.m in Sources */ = {isa = PBXBuildFile; fileRef = 177042980B8BC53600B86321 /* AppController.m */; };
|
||||
1770429E0B8BC53600B86321 /* PlaybackController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1770429A0B8BC53600B86321 /* PlaybackController.m */; };
|
||||
177EBF9E0B8BC2A70000BC8C /* AMRemovableColumnsTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 177EBF7A0B8BC2A70000BC8C /* AMRemovableColumnsTableView.m */; };
|
||||
|
@ -121,9 +123,7 @@
|
|||
8EFFCD610AA093AF00C458A5 /* FileIconCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD450AA093AF00C458A5 /* FileIconCell.m */; };
|
||||
8EFFCD630AA093AF00C458A5 /* FileNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD470AA093AF00C458A5 /* FileNode.m */; };
|
||||
8EFFCD650AA093AF00C458A5 /* FileOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD490AA093AF00C458A5 /* FileOutlineView.m */; };
|
||||
8EFFCD670AA093AF00C458A5 /* FileTreeController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD4B0AA093AF00C458A5 /* FileTreeController.m */; };
|
||||
8EFFCD690AA093AF00C458A5 /* FileTreeWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD4D0AA093AF00C458A5 /* FileTreeWatcher.m */; };
|
||||
8EFFCD6D0AA093AF00C458A5 /* PathIcon.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD510AA093AF00C458A5 /* PathIcon.m */; };
|
||||
8EFFCD6F0AA093AF00C458A5 /* PathNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD530AA093AF00C458A5 /* PathNode.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
@ -418,6 +418,7 @@
|
|||
170680840B950164006BA573 /* Growl.framework in CopyFiles */,
|
||||
17F94CCD0B8D090800A34E87 /* Sparkle.framework in CopyFiles */,
|
||||
1791FF8F0CB43A2C0070BC5C /* MediaKeysApplication.h in CopyFiles */,
|
||||
1769D7D10CC2BFF7003F455B /* FileTreeDataSource.h in CopyFiles */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -465,6 +466,8 @@
|
|||
1766C88F0B912FB4004A7AE4 /* repeat_on.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = repeat_on.png; path = Images/repeat_on.png; sourceTree = "<group>"; };
|
||||
1766C8900B912FB4004A7AE4 /* shuffle_off.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = shuffle_off.png; path = Images/shuffle_off.png; sourceTree = "<group>"; };
|
||||
1766C8910B912FB4004A7AE4 /* shuffle_on.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = shuffle_on.png; path = Images/shuffle_on.png; sourceTree = "<group>"; };
|
||||
1769D7CF0CC2BFF7003F455B /* FileTreeDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileTreeDataSource.h; sourceTree = "<group>"; };
|
||||
1769D7D00CC2BFF7003F455B /* FileTreeDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FileTreeDataSource.m; sourceTree = "<group>"; };
|
||||
1770424E0B8BC41800B86321 /* Cog.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Cog.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
177042970B8BC53600B86321 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = "<group>"; };
|
||||
177042980B8BC53600B86321 /* AppController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = AppController.m; sourceTree = "<group>"; };
|
||||
|
@ -614,8 +617,6 @@
|
|||
8EFFCD4B0AA093AF00C458A5 /* FileTreeController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FileTreeController.m; sourceTree = "<group>"; };
|
||||
8EFFCD4C0AA093AF00C458A5 /* FileTreeWatcher.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FileTreeWatcher.h; sourceTree = "<group>"; };
|
||||
8EFFCD4D0AA093AF00C458A5 /* FileTreeWatcher.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FileTreeWatcher.m; sourceTree = "<group>"; };
|
||||
8EFFCD500AA093AF00C458A5 /* PathIcon.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PathIcon.h; sourceTree = "<group>"; };
|
||||
8EFFCD510AA093AF00C458A5 /* PathIcon.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = PathIcon.m; sourceTree = "<group>"; };
|
||||
8EFFCD520AA093AF00C458A5 /* PathNode.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PathNode.h; sourceTree = "<group>"; };
|
||||
8EFFCD530AA093AF00C458A5 /* PathNode.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = PathNode.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
@ -1146,10 +1147,10 @@
|
|||
children = (
|
||||
8EFFCD440AA093AF00C458A5 /* FileIconCell.h */,
|
||||
8EFFCD450AA093AF00C458A5 /* FileIconCell.m */,
|
||||
8EFFCD500AA093AF00C458A5 /* PathIcon.h */,
|
||||
8EFFCD510AA093AF00C458A5 /* PathIcon.m */,
|
||||
8EFFCD480AA093AF00C458A5 /* FileOutlineView.h */,
|
||||
8EFFCD490AA093AF00C458A5 /* FileOutlineView.m */,
|
||||
1769D7CF0CC2BFF7003F455B /* FileTreeDataSource.h */,
|
||||
1769D7D00CC2BFF7003F455B /* FileTreeDataSource.m */,
|
||||
8EFFCD4A0AA093AF00C458A5 /* FileTreeController.h */,
|
||||
8EFFCD4B0AA093AF00C458A5 /* FileTreeController.m */,
|
||||
8EFFCD4C0AA093AF00C458A5 /* FileTreeWatcher.h */,
|
||||
|
@ -1506,9 +1507,7 @@
|
|||
8EFFCD610AA093AF00C458A5 /* FileIconCell.m in Sources */,
|
||||
8EFFCD630AA093AF00C458A5 /* FileNode.m in Sources */,
|
||||
8EFFCD650AA093AF00C458A5 /* FileOutlineView.m in Sources */,
|
||||
8EFFCD670AA093AF00C458A5 /* FileTreeController.m in Sources */,
|
||||
8EFFCD690AA093AF00C458A5 /* FileTreeWatcher.m in Sources */,
|
||||
8EFFCD6D0AA093AF00C458A5 /* PathIcon.m in Sources */,
|
||||
8EFFCD6F0AA093AF00C458A5 /* PathNode.m in Sources */,
|
||||
8E07AAF30AAC910500A4B32F /* SS_PrefsController.m in Sources */,
|
||||
8E07AB790AAC930B00A4B32F /* PreferencesController.m in Sources */,
|
||||
|
@ -1539,6 +1538,7 @@
|
|||
8E9A30160BA792DC0091081B /* NSFileHandle+CreateFile.m in Sources */,
|
||||
179790E10C087AB7001D6996 /* OpenURLPanel.m in Sources */,
|
||||
1791FF900CB43A2C0070BC5C /* MediaKeysApplication.m in Sources */,
|
||||
1769D7D20CC2BFF7003F455B /* FileTreeDataSource.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<key>29</key>
|
||||
<string>157 976 383 44 0 0 1680 1028 </string>
|
||||
<key>463</key>
|
||||
<string>669 640 341 145 0 0 1680 1028 </string>
|
||||
<string>669 639 341 145 0 0 1680 1028 </string>
|
||||
<key>513</key>
|
||||
<string>379 636 131 168 0 0 1680 1028 </string>
|
||||
</dict>
|
||||
|
@ -34,14 +34,14 @@
|
|||
<integer>4</integer>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>463</integer>
|
||||
<integer>29</integer>
|
||||
<integer>1324</integer>
|
||||
<integer>1063</integer>
|
||||
<integer>268</integer>
|
||||
<integer>29</integer>
|
||||
<integer>21</integer>
|
||||
<integer>1156</integer>
|
||||
<integer>1324</integer>
|
||||
<integer>513</integer>
|
||||
<integer>463</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>8R2218</string>
|
||||
|
|
Binary file not shown.
|
@ -11,11 +11,6 @@
|
|||
|
||||
@interface DirectoryNode : PathNode
|
||||
{
|
||||
NSMutableArray *subpaths;
|
||||
id controller;
|
||||
}
|
||||
|
||||
-(id)initWithPath:(NSString *)p controller:(id) c;
|
||||
- (NSArray *)subpaths;
|
||||
|
||||
@end
|
||||
|
|
|
@ -7,109 +7,33 @@
|
|||
//
|
||||
|
||||
#import "DirectoryNode.h"
|
||||
|
||||
#import "FileNode.h"
|
||||
#import "SmartFolderNode.h"
|
||||
|
||||
#import "FileTreeController.h"
|
||||
#import "FileTreeWatcher.h"
|
||||
|
||||
@implementation DirectoryNode
|
||||
|
||||
-(id)initWithPath:(NSString *)p controller:(id) c
|
||||
{
|
||||
self = [super initWithPath:p];
|
||||
if (self)
|
||||
{
|
||||
controller = [c retain];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[[controller watcher] removePath:[self path]];
|
||||
|
||||
if (subpaths)
|
||||
[subpaths release];
|
||||
|
||||
[controller release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL)isLeaf
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)processContents: (NSArray *)contents
|
||||
{
|
||||
NSEnumerator *e = [contents objectEnumerator];
|
||||
NSString *s;
|
||||
while ((s = [e nextObject]))
|
||||
{
|
||||
if ([s characterAtIndex:0] == '.')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
PathNode *newNode;
|
||||
NSString *newSubpath = [path stringByAppendingPathComponent: s];
|
||||
|
||||
if ([[s pathExtension] caseInsensitiveCompare:@"savedSearch"] == NSOrderedSame)
|
||||
{
|
||||
newNode = [[SmartFolderNode alloc] initWithPath:newSubpath controller:controller];
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOL isDir;
|
||||
|
||||
[[NSFileManager defaultManager] fileExistsAtPath:newSubpath isDirectory:&isDir];
|
||||
|
||||
if (!isDir && ![[controller acceptableFileTypes] containsObject:[s pathExtension]])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isDir)
|
||||
newNode = [[DirectoryNode alloc] initWithPath: newSubpath controller:controller];
|
||||
else
|
||||
newNode = [[FileNode alloc] initWithPath: newSubpath];
|
||||
}
|
||||
|
||||
[subpaths addObject:newNode];
|
||||
|
||||
[newNode release];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)subpaths
|
||||
{
|
||||
if (subpaths == nil)
|
||||
{
|
||||
subpaths = [[NSMutableArray alloc] init];
|
||||
NSArray *contents = [[[NSFileManager defaultManager] directoryContentsAtPath:path] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
|
||||
NSLog(@"Contents: %@", contents);
|
||||
[self processPaths: contents];
|
||||
|
||||
[self processContents: contents];
|
||||
|
||||
[[controller watcher] addPath:[self path]];
|
||||
// [[controller watcher] addPath:[self path]];
|
||||
}
|
||||
|
||||
return subpaths;
|
||||
}
|
||||
|
||||
- (void)setSubpaths:(id)s
|
||||
{
|
||||
[s retain];
|
||||
[subpaths release];
|
||||
subpaths = s;
|
||||
}
|
||||
|
||||
- (unsigned int)countOfSubpaths
|
||||
{
|
||||
return [[self subpaths] count];
|
||||
}
|
||||
|
||||
- (PathNode *)objectInSubpathsAtIndex:(unsigned int)index
|
||||
{
|
||||
return [[self subpaths] objectAtIndex:index];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -8,9 +8,12 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class FileTreeDataSource;
|
||||
|
||||
@interface FileOutlineView : NSOutlineView {
|
||||
IBOutlet NSDrawer *fileDrawer;
|
||||
|
||||
FileTreeDataSource *dataSource;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -8,10 +8,13 @@
|
|||
|
||||
#import "FileOutlineView.h"
|
||||
#import "FileIconCell.h"
|
||||
#import "FileTreeDataSource.h"
|
||||
|
||||
|
||||
@interface FileOutlineView (KFTypeSelectTableViewSupport)
|
||||
- (void)findPrevious:(id)sender;
|
||||
- (void)findNext:(id)sender;
|
||||
- (void)kfResetSearch;
|
||||
@end
|
||||
|
||||
@implementation FileOutlineView
|
||||
|
@ -22,13 +25,15 @@
|
|||
id c;
|
||||
while ((c = [e nextObject]))
|
||||
{
|
||||
// id headerCell = [[ImageTextCell alloc] init];
|
||||
id dataCell = [[FileIconCell alloc] init];
|
||||
|
||||
[dataCell setLineBreakMode:NSLineBreakByTruncatingTail];
|
||||
// [c setHeaderCell: headerCell];
|
||||
[c setDataCell: dataCell];
|
||||
NSLog(@"Setting data cell!");
|
||||
}
|
||||
|
||||
dataSource = [[FileTreeDataSource alloc] initWithRoot: [[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"fileDrawerRootPath"] ];
|
||||
[self setDataSource: dataSource];
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,7 +64,7 @@
|
|||
[self kfResetSearch];
|
||||
} else if (pressedChar == NSCarriageReturnCharacter || pressedChar == NSEnterCharacter) { //Enter or return
|
||||
//Add songs to list
|
||||
[[self delegate] addSelectedToPlaylist];
|
||||
//[[self delegate] addSelectedToPlaylist];
|
||||
|
||||
[fileDrawer close];
|
||||
} else if (pressedChar == 0x1b) {//Escape
|
||||
|
|
|
@ -20,8 +20,11 @@
|
|||
FileTreeWatcher *watcher;
|
||||
}
|
||||
|
||||
- (FileTreeWatcher *)watcher;
|
||||
|
||||
- (id)rootPath;
|
||||
- (void)setRootPath:(id)r;
|
||||
- (void) refreshRoot;
|
||||
- (void)refreshRoot;
|
||||
- (NSArray *)acceptableFileTypes;
|
||||
|
||||
@end
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
- (void) refreshRoot
|
||||
{
|
||||
DirectoryNode *base = [[DirectoryNode alloc] initWithPath:rootPath controller:self];
|
||||
[self setContent: [base subpaths]];
|
||||
// [self setContent: [base subpaths]];
|
||||
|
||||
[base release];
|
||||
|
||||
|
@ -122,7 +122,7 @@
|
|||
|
||||
while (p = [e nextObject]) {
|
||||
int i;
|
||||
PathNode *n = nil;
|
||||
id n = nil;
|
||||
NSIndexPath *ip = [p indexPath];
|
||||
|
||||
for (i = 0; i < [ip length]; i++)
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "UKKQueue.h"
|
||||
|
||||
@class UKKQueue;
|
||||
|
||||
@interface FileTreeWatcher : NSObject {
|
||||
UKKQueue *kqueue;
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#import "FileTreeWatcher.h"
|
||||
|
||||
#import "UKKQueue.h"
|
||||
|
||||
@implementation FileTreeWatcher
|
||||
|
||||
- (id)init
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
//
|
||||
// FileIcon.h
|
||||
// Cog
|
||||
//
|
||||
// Created by Vincent Spader on 8/20/06.
|
||||
// Copyright 2006 Vincent Spader. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
@interface PathIcon : NSObject {
|
||||
NSString *path;
|
||||
NSImage *icon;
|
||||
}
|
||||
|
||||
-(id)initWithPath:(NSString *)p;
|
||||
|
||||
@end
|
|
@ -1,44 +0,0 @@
|
|||
//
|
||||
// FileIcon.m
|
||||
// Cog
|
||||
//
|
||||
// Created by Vincent Spader on 8/20/06.
|
||||
// Copyright 2006 Vincent Spader. All rights reserved.
|
||||
//
|
||||
|
||||
#import "PathIcon.h"
|
||||
|
||||
|
||||
@implementation PathIcon
|
||||
|
||||
-(id)initWithPath:(NSString *)p
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
path = [p retain];
|
||||
icon = [[[NSWorkspace sharedWorkspace] iconForFile:path] retain];
|
||||
|
||||
[icon setSize: NSMakeSize(16.0, 16.0)];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[path release];
|
||||
[icon release];
|
||||
}
|
||||
|
||||
- (NSString *) path
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
- (NSImage *) icon
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
@end
|
|
@ -7,17 +7,27 @@
|
|||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "PathIcon.h"
|
||||
|
||||
@interface PathNode : NSObject
|
||||
{
|
||||
NSString *path;
|
||||
PathIcon *pathIcon;
|
||||
NSImage *icon;
|
||||
|
||||
NSArray *subpaths;
|
||||
}
|
||||
|
||||
- (id)initWithPath:(NSString *)p;
|
||||
|
||||
- (id)pathIcon;
|
||||
- (void)setPathIcon:(id)pi;
|
||||
- (NSString *)path;
|
||||
- (void)setPath:(NSString *)p;
|
||||
|
||||
- (void)processPaths: (NSArray *)contents;
|
||||
|
||||
- (NSArray *)subpaths;
|
||||
- (void)setSubpaths:(NSArray *)s;
|
||||
|
||||
- (NSImage *)icon;
|
||||
|
||||
- (BOOL)isLeaf;
|
||||
|
||||
@end
|
||||
|
|
|
@ -8,6 +8,12 @@
|
|||
|
||||
#import "PathNode.h"
|
||||
|
||||
#import "CogAudio/AudioPlayer.h"
|
||||
|
||||
@class FileNode;
|
||||
@class DirectoryNode;
|
||||
@class SmartFolderNode;
|
||||
|
||||
@implementation PathNode
|
||||
|
||||
- (id)initWithPath:(NSString *)p
|
||||
|
@ -16,8 +22,7 @@
|
|||
|
||||
if (self)
|
||||
{
|
||||
path = [p retain];
|
||||
[self setPathIcon:[[PathIcon alloc] initWithPath:path]];
|
||||
[self setPath: p];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -26,26 +31,105 @@
|
|||
- (void)dealloc
|
||||
{
|
||||
[path release];
|
||||
[pathIcon release];
|
||||
|
||||
[icon release];
|
||||
|
||||
if (subpaths) {
|
||||
[subpaths release];
|
||||
subpaths = nil;
|
||||
}
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)setPath:(NSString *)p
|
||||
{
|
||||
[p retain];
|
||||
[path release];
|
||||
|
||||
path = p;
|
||||
|
||||
[icon release];
|
||||
icon = [[NSWorkspace sharedWorkspace] iconForFile:path];
|
||||
[icon retain];
|
||||
|
||||
[icon setSize: NSMakeSize(16.0, 16.0)];
|
||||
}
|
||||
|
||||
- (NSString *)path
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
- (id)pathIcon
|
||||
- (void)processPaths: (NSArray *)contents
|
||||
{
|
||||
return pathIcon;
|
||||
NSMutableArray *newSubpaths = [[NSMutableArray alloc] init];
|
||||
|
||||
NSEnumerator *e = [contents objectEnumerator];
|
||||
NSString *s;
|
||||
while ((s = [e nextObject]))
|
||||
{
|
||||
if ([s characterAtIndex:0] == '.')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
PathNode *newNode;
|
||||
NSString *newSubpath = [path stringByAppendingPathComponent: s];
|
||||
|
||||
if ([[s pathExtension] caseInsensitiveCompare:@"savedSearch"] == NSOrderedSame)
|
||||
{
|
||||
newNode = [[SmartFolderNode alloc] initWithPath:newSubpath];
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOL isDir;
|
||||
|
||||
[[NSFileManager defaultManager] fileExistsAtPath:newSubpath isDirectory:&isDir];
|
||||
|
||||
if (!isDir && ![[AudioPlayer fileTypes] containsObject:[s pathExtension]])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isDir)
|
||||
newNode = [[DirectoryNode alloc] initWithPath: newSubpath];
|
||||
else
|
||||
newNode = [[FileNode alloc] initWithPath: newSubpath];
|
||||
}
|
||||
|
||||
[newSubpaths addObject:newNode];
|
||||
|
||||
[newNode release];
|
||||
}
|
||||
|
||||
[self setSubpaths:[[newSubpaths copy] autorelease]];
|
||||
|
||||
[newSubpaths release];
|
||||
}
|
||||
|
||||
- (void)setPathIcon:(id)pi
|
||||
- (NSArray *)subpaths
|
||||
{
|
||||
[pi retain];
|
||||
[pathIcon release];
|
||||
pathIcon = pi;
|
||||
return subpaths;
|
||||
}
|
||||
|
||||
- (void)setSubpaths:(NSArray *)s
|
||||
{
|
||||
[s retain];
|
||||
[subpaths release];
|
||||
subpaths = s;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)isLeaf
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
- (NSImage *)icon
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#import "PathNode.h"
|
||||
|
||||
@interface SmartFolderNode : PathNode {
|
||||
NSMutableArray *subpaths;
|
||||
id controller;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -12,77 +12,15 @@
|
|||
|
||||
@implementation SmartFolderNode
|
||||
|
||||
-(id)initWithPath:(NSString *)p controller:(id) c
|
||||
{
|
||||
self = [super initWithPath:p];
|
||||
if (self)
|
||||
{
|
||||
controller = [c retain];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
if (subpaths)
|
||||
[subpaths release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)isLeaf
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
//need to merge this and directorynode
|
||||
- (void)processContents: (NSArray *)contents
|
||||
{
|
||||
NSEnumerator *e = [contents objectEnumerator];
|
||||
NSString *s;
|
||||
|
||||
while (s = [e nextObject])
|
||||
{
|
||||
/* if ([s characterAtIndex:0] == '.')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
PathNode *newNode;
|
||||
// NSString *newSubpath = [path stringByAppendingPathComponent: s];
|
||||
|
||||
if ([[s pathExtension] caseInsensitiveCompare:@"savedSearch"] == NSOrderedSame)
|
||||
{
|
||||
newNode = [[SmartFolderNode alloc] initWithPath:s controller:controller];
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOL isDir;
|
||||
|
||||
[[NSFileManager defaultManager] fileExistsAtPath:s isDirectory:&isDir];
|
||||
|
||||
if (!isDir && ![[controller acceptableFileTypes] containsObject:[s pathExtension]])
|
||||
continue;
|
||||
|
||||
if (isDir)
|
||||
newNode = [[DirectoryNode alloc] initWithPath: s controller:controller];
|
||||
else
|
||||
newNode = [[FileNode alloc] initWithPath: s];
|
||||
}
|
||||
|
||||
[subpaths addObject:newNode];
|
||||
|
||||
[newNode release];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray *)subpaths
|
||||
{
|
||||
if (subpaths == nil)
|
||||
{
|
||||
subpaths = [[NSMutableArray alloc] init];
|
||||
|
||||
NSDictionary *doc = [NSDictionary dictionaryWithContentsOfFile:path];
|
||||
NSString *rawQuery = [doc objectForKey:@"RawQuery"];
|
||||
NSArray *searchPaths = [[doc objectForKey:@"SearchCriteria"] objectForKey:@"CurrentFolderPath"];
|
||||
|
@ -120,7 +58,7 @@
|
|||
|
||||
- (void)queryFinished:(NSNotification *)notification
|
||||
{
|
||||
MDQueryRef query = [notification object];
|
||||
MDQueryRef query = (MDQueryRef)[notification object];
|
||||
|
||||
NSMutableArray *results = [NSMutableArray array];
|
||||
|
||||
|
@ -141,13 +79,11 @@
|
|||
|
||||
MDQueryEnableUpdates(query);
|
||||
|
||||
[self processContents:results];
|
||||
[self setSubpaths:subpaths];
|
||||
[self processPaths:results];
|
||||
}
|
||||
|
||||
- (void)queryUpdate:(NSNotification *)notification
|
||||
{
|
||||
[subpaths removeAllObjects];
|
||||
[self queryFinished: notification];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue