Cleaned up Spotlight update code.
parent
b5c46a0b3a
commit
e0a937b3e5
|
@ -10,8 +10,11 @@
|
|||
#import "PlaylistController.h"
|
||||
|
||||
@interface SpotlightPlaylistController : PlaylistController {
|
||||
NSArray *oldObjects;
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard*)pboard;
|
||||
|
||||
@property(retain) NSArray *oldObjects;
|
||||
|
||||
@end
|
||||
|
|
|
@ -11,6 +11,15 @@
|
|||
|
||||
@implementation SpotlightPlaylistController
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if(self = [super init])
|
||||
{
|
||||
oldObjects = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// Allow drag and drop from Spotlight into main playlist
|
||||
- (BOOL)tableView:(NSTableView *)tv
|
||||
writeRowsWithIndexes:(NSIndexSet *)rowIndexes
|
||||
|
@ -36,4 +45,20 @@
|
|||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (NSArray *)arrangeObjects:(NSArray *)objects
|
||||
{
|
||||
if(![spotlightWindowController.query isGathering])
|
||||
self.oldObjects = [super arrangeObjects:objects];
|
||||
|
||||
return oldObjects;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[oldObjects release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@synthesize oldObjects;
|
||||
|
||||
@end
|
|
@ -242,19 +242,6 @@ static NSPredicate * musicOnlyPredicate = nil;
|
|||
[self.query enableUpdates];
|
||||
}
|
||||
|
||||
// Don't update the track list until some results have been gathered
|
||||
- (id)valueForKeyPath:(NSString *)keyPath
|
||||
{
|
||||
if([keyPath isEqualToString:@"query.results"])
|
||||
{
|
||||
if(([self.query.results count] == 0) && [self.query isGathering])
|
||||
return self.oldResults;
|
||||
self.oldResults = [NSArray arrayWithArray:self.query.results];
|
||||
return self.oldResults;
|
||||
}
|
||||
return [super valueForKeyPath:keyPath];
|
||||
}
|
||||
|
||||
#pragma mark NSMetadataQuery delegate methods
|
||||
|
||||
// replace the NSMetadataItem with a PlaylistEntry
|
||||
|
|
Loading…
Reference in New Issue