Fixed up smart folders.
This commit is contained in:
parent
47582ae4f4
commit
3ef46a0c82
5 changed files with 38 additions and 8 deletions
|
@ -21,8 +21,17 @@
|
||||||
- (void)updatePath
|
- (void)updatePath
|
||||||
{
|
{
|
||||||
NSArray *contents = [[[NSFileManager defaultManager] directoryContentsAtPath:path] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
|
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
|
@end
|
||||||
|
|
|
@ -15,4 +15,15 @@
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Disable watching for us, it doesn't matter.
|
||||||
|
- (void)startWatching
|
||||||
|
{
|
||||||
|
}
|
||||||
|
- (void)stopWatching
|
||||||
|
{
|
||||||
|
}
|
||||||
|
- (void)updatePathNotification:(NSNotification *)notification
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -37,4 +37,8 @@
|
||||||
|
|
||||||
- (BOOL)isLeaf;
|
- (BOOL)isLeaf;
|
||||||
|
|
||||||
|
- (void)startWatching;
|
||||||
|
- (void)stopWatching;
|
||||||
|
- (void)updatePathNotification:(NSNotification *)notification;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -128,17 +128,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
PathNode *newNode;
|
PathNode *newNode;
|
||||||
NSString *newSubpath = [path stringByAppendingPathComponent: s];
|
|
||||||
|
|
||||||
if ([[s pathExtension] caseInsensitiveCompare:@"savedSearch"] == NSOrderedSame)
|
if ([[s pathExtension] caseInsensitiveCompare:@"savedSearch"] == NSOrderedSame)
|
||||||
{
|
{
|
||||||
newNode = [[SmartFolderNode alloc] initWithDataSource:dataSource path:newSubpath];
|
NSLog(@"Smart folder!");
|
||||||
|
newNode = [[SmartFolderNode alloc] initWithDataSource:dataSource path:s];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BOOL isDir;
|
BOOL isDir;
|
||||||
|
|
||||||
[[NSFileManager defaultManager] fileExistsAtPath:newSubpath isDirectory:&isDir];
|
[[NSFileManager defaultManager] fileExistsAtPath:s isDirectory:&isDir];
|
||||||
|
|
||||||
if (!isDir && ![[AudioPlayer fileTypes] containsObject:[s pathExtension]])
|
if (!isDir && ![[AudioPlayer fileTypes] containsObject:[s pathExtension]])
|
||||||
{
|
{
|
||||||
|
@ -147,11 +147,11 @@
|
||||||
|
|
||||||
if (isDir)
|
if (isDir)
|
||||||
{
|
{
|
||||||
newNode = [[DirectoryNode alloc] initWithDataSource:dataSource path: newSubpath];
|
newNode = [[DirectoryNode alloc] initWithDataSource:dataSource path: s];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newNode = [[FileNode alloc] initWithDataSource:dataSource path: newSubpath];
|
newNode = [[FileNode alloc] initWithDataSource:dataSource path: s];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#import "SmartFolderNode.h"
|
#import "SmartFolderNode.h"
|
||||||
#import "DirectoryNode.h"
|
#import "DirectoryNode.h"
|
||||||
#import "FileNode.h"
|
#import "FileNode.h"
|
||||||
|
#import "FileTreeDataSource.h"
|
||||||
|
|
||||||
@implementation SmartFolderNode
|
@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(queryFinished:) name:(NSString*)kMDQueryDidFinishNotification object:(id)query];
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryUpdate:) name:(NSString*)kMDQueryDidUpdateNotification object:(id)query];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(queryUpdate:) name:(NSString*)kMDQueryDidUpdateNotification object:(id)query];
|
||||||
|
|
||||||
|
NSLog(@"Making query!");
|
||||||
MDQueryExecute(query, kMDQueryWantsUpdates);
|
MDQueryExecute(query, kMDQueryWantsUpdates);
|
||||||
|
|
||||||
//Note: This is asynchronous!
|
//Note: This is asynchronous!
|
||||||
|
@ -55,6 +57,7 @@
|
||||||
|
|
||||||
- (void)queryFinished:(NSNotification *)notification
|
- (void)queryFinished:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
|
NSLog(@"Query finished!");
|
||||||
MDQueryRef query = (MDQueryRef)[notification object];
|
MDQueryRef query = (MDQueryRef)[notification object];
|
||||||
|
|
||||||
NSMutableArray *results = [NSMutableArray array];
|
NSMutableArray *results = [NSMutableArray array];
|
||||||
|
@ -76,13 +79,16 @@
|
||||||
|
|
||||||
MDQueryEnableUpdates(query);
|
MDQueryEnableUpdates(query);
|
||||||
|
|
||||||
[self processPaths:results];
|
NSLog(@"Query update!");
|
||||||
|
|
||||||
|
[self processPaths:[results sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]];
|
||||||
|
|
||||||
[dataSource reloadPathNode:self];
|
[dataSource reloadPathNode:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)queryUpdate:(NSNotification *)notification
|
- (void)queryUpdate:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
|
NSLog(@"Query update!");
|
||||||
[self queryFinished: notification];
|
[self queryFinished: notification];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue