Cleaned up Spotlight update code.

CQTexperiment
matthewleon 2008-02-16 20:40:47 +00:00
parent b5c46a0b3a
commit e0a937b3e5
3 changed files with 28 additions and 13 deletions

View File

@ -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

View File

@ -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

View File

@ -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