Spotlight search can now be limited to a path. Still quite buggy.
parent
ff8cd0d773
commit
4be43e5256
File diff suppressed because it is too large
Load Diff
|
@ -13,11 +13,13 @@
|
||||||
@interface SpotlightSearchController : NSObject {
|
@interface SpotlightSearchController : NSObject {
|
||||||
IBOutlet NSArrayController *playlistController;
|
IBOutlet NSArrayController *playlistController;
|
||||||
IBOutlet SpotlightWindowController *spotlightWindowController;
|
IBOutlet SpotlightWindowController *spotlightWindowController;
|
||||||
|
IBOutlet NSPathControl *pathControl;
|
||||||
NSMetadataQuery *query;
|
NSMetadataQuery *query;
|
||||||
NSString *searchString;
|
NSString *searchString;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)addToPlaylist:(id)sender;
|
- (IBAction)addToPlaylist:(id)sender;
|
||||||
|
- (IBAction)changeSearchPath:(id)sender;
|
||||||
|
|
||||||
- (void)performSearch;
|
- (void)performSearch;
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,20 @@ static NSPredicate * musicOnlyPredicate = nil;
|
||||||
return self;
|
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
|
- (void)performSearch
|
||||||
{
|
{
|
||||||
unsigned options = (NSCaseInsensitivePredicateOption|
|
unsigned options = (NSCaseInsensitivePredicateOption|
|
||||||
NSDiacriticInsensitivePredicateOption);
|
NSDiacriticInsensitivePredicateOption);
|
||||||
|
[self.query setSearchScopes:[NSArray arrayWithObjects:pathControl.URL, nil]];
|
||||||
NSString *processedKey = [NSString stringWithFormat: @"*%@*", self.searchString];
|
NSString *processedKey = [NSString stringWithFormat: @"*%@*", self.searchString];
|
||||||
|
|
||||||
NSPredicate *searchPredicate = [NSComparisonPredicate
|
NSPredicate *searchPredicate = [NSComparisonPredicate
|
||||||
|
@ -66,7 +76,15 @@ static NSPredicate * musicOnlyPredicate = nil;
|
||||||
[super dealloc];
|
[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];
|
[self.query disableUpdates];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue