Fixed up smart folders.
parent
47582ae4f4
commit
3ef46a0c82
|
@ -21,8 +21,17 @@
|
|||
- (void)updatePath
|
||||
{
|
||||
NSArray *contents = [[[NSFileManager defaultManager] directoryContentsAtPath:path] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
|
||||
NSMutableArray *fullPaths = [[NSMutableArray alloc] init];
|
||||
NSString *s;
|
||||
NSEnumerator *e = [contents objectEnumerator];
|
||||
while (s = [e nextObject])
|
||||
{
|
||||
[fullPaths addObject:[path stringByAppendingPathComponent: s]];
|
||||
}
|
||||
|
||||
[self processPaths: contents];
|
||||
[self processPaths: fullPaths];
|
||||
|
||||
[fullPaths release];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -15,4 +15,15 @@
|
|||
return YES;
|
||||
}
|
||||
|
||||
//Disable watching for us, it doesn't matter.
|
||||
- (void)startWatching
|
||||
{
|
||||
}
|
||||
- (void)stopWatching
|
||||
{
|
||||
}
|
||||
- (void)updatePathNotification:(NSNotification *)notification
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -37,4 +37,8 @@
|
|||
|
||||
- (BOOL)isLeaf;
|
||||
|
||||
- (void)startWatching;
|
||||
- (void)stopWatching;
|
||||
- (void)updatePathNotification:(NSNotification *)notification;
|
||||
|
||||
@end
|
||||
|
|
|
@ -128,17 +128,17 @@
|
|||
}
|
||||
|
||||
PathNode *newNode;
|
||||
NSString *newSubpath = [path stringByAppendingPathComponent: s];
|
||||
|
||||
if ([[s pathExtension] caseInsensitiveCompare:@"savedSearch"] == NSOrderedSame)
|
||||
{
|
||||
newNode = [[SmartFolderNode alloc] initWithDataSource:dataSource path:newSubpath];
|
||||
NSLog(@"Smart folder!");
|
||||
newNode = [[SmartFolderNode alloc] initWithDataSource:dataSource path:s];
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOL isDir;
|
||||
|
||||
[[NSFileManager defaultManager] fileExistsAtPath:newSubpath isDirectory:&isDir];
|
||||
[[NSFileManager defaultManager] fileExistsAtPath:s isDirectory:&isDir];
|
||||
|
||||
if (!isDir && ![[AudioPlayer fileTypes] containsObject:[s pathExtension]])
|
||||
{
|
||||
|
@ -147,11 +147,11 @@
|
|||
|
||||
if (isDir)
|
||||
{
|
||||
newNode = [[DirectoryNode alloc] initWithDataSource:dataSource path: newSubpath];
|
||||
newNode = [[DirectoryNode alloc] initWithDataSource:dataSource path: s];
|
||||
}
|
||||
else
|
||||
{
|
||||
newNode = [[FileNode alloc] initWithDataSource:dataSource path: newSubpath];
|
||||
newNode = [[FileNode alloc] initWithDataSource:dataSource path: s];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#import "SmartFolderNode.h"
|
||||
#import "DirectoryNode.h"
|
||||
#import "FileNode.h"
|
||||
#import "FileTreeDataSource.h"
|
||||
|
||||
@implementation SmartFolderNode
|
||||
|
||||
|
@ -31,6 +32,7 @@
|
|||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryFinished:) name:(NSString*)kMDQueryDidFinishNotification object:(id)query];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryUpdate:) name:(NSString*)kMDQueryDidUpdateNotification object:(id)query];
|
||||
|
||||
NSLog(@"Making query!");
|
||||
MDQueryExecute(query, kMDQueryWantsUpdates);
|
||||
|
||||
//Note: This is asynchronous!
|
||||
|
@ -55,6 +57,7 @@
|
|||
|
||||
- (void)queryFinished:(NSNotification *)notification
|
||||
{
|
||||
NSLog(@"Query finished!");
|
||||
MDQueryRef query = (MDQueryRef)[notification object];
|
||||
|
||||
NSMutableArray *results = [NSMutableArray array];
|
||||
|
@ -68,7 +71,7 @@
|
|||
MDItemRef item = (MDItemRef)MDQueryGetResultAtIndex(query, i);
|
||||
|
||||
NSString *itemPath = (NSString*)MDItemCopyAttribute(item, kMDItemPath);
|
||||
|
||||
|
||||
[results addObject:itemPath];
|
||||
|
||||
[itemPath release];
|
||||
|
@ -76,13 +79,16 @@
|
|||
|
||||
MDQueryEnableUpdates(query);
|
||||
|
||||
[self processPaths:results];
|
||||
NSLog(@"Query update!");
|
||||
|
||||
[self processPaths:[results sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]];
|
||||
|
||||
[dataSource reloadPathNode:self];
|
||||
}
|
||||
|
||||
- (void)queryUpdate:(NSNotification *)notification
|
||||
{
|
||||
NSLog(@"Query update!");
|
||||
[self queryFinished: notification];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue