Spotlight search can now be limited to a path. Still quite buggy.

CQTexperiment
matthewleon 2008-02-11 10:29:21 +00:00
parent ff8cd0d773
commit 4be43e5256
3 changed files with 799 additions and 610 deletions

File diff suppressed because it is too large Load Diff

View File

@ -13,11 +13,13 @@
@interface SpotlightSearchController : NSObject {
IBOutlet NSArrayController *playlistController;
IBOutlet SpotlightWindowController *spotlightWindowController;
IBOutlet NSPathControl *pathControl;
NSMetadataQuery *query;
NSString *searchString;
}
- (IBAction)addToPlaylist:(id)sender;
- (IBAction)changeSearchPath:(id)sender;
- (void)performSearch;

View File

@ -30,10 +30,20 @@ static NSPredicate * musicOnlyPredicate = nil;
return self;
}
- (void)awakeFromNib
{
// Will replace this with userdefaults, but for now just start in
// the home directory.
NSString *homeDirectory = @"~";
homeDirectory = [homeDirectory stringByExpandingTildeInPath];
[pathControl setURL:[NSURL fileURLWithPath:homeDirectory isDirectory:YES]];
}
- (void)performSearch
{
unsigned options = (NSCaseInsensitivePredicateOption|
NSDiacriticInsensitivePredicateOption);
[self.query setSearchScopes:[NSArray arrayWithObjects:pathControl.URL, nil]];
NSString *processedKey = [NSString stringWithFormat: @"*%@*", self.searchString];
NSPredicate *searchPredicate = [NSComparisonPredicate
@ -66,7 +76,15 @@ static NSPredicate * musicOnlyPredicate = nil;
[super dealloc];
}
- (IBAction)addToPlaylist:(id)sender;
- (IBAction)changeSearchPath:(id)sender
{
// When the search path is changed, restart search
if([self.query isStarted]) {
[self performSearch];
}
}
- (IBAction)addToPlaylist:(id)sender
{
[self.query disableUpdates];