From e0a937b3e5bb2709a7c6356d7303e64bb7e747c7 Mon Sep 17 00:00:00 2001 From: matthewleon Date: Sat, 16 Feb 2008 20:40:47 +0000 Subject: [PATCH] Cleaned up Spotlight update code. --- Spotlight/SpotlightPlaylistController.h | 3 +++ Spotlight/SpotlightPlaylistController.m | 25 +++++++++++++++++++++++++ Spotlight/SpotlightWindowController.m | 13 ------------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/Spotlight/SpotlightPlaylistController.h b/Spotlight/SpotlightPlaylistController.h index bd780ffbe..d04c1867f 100644 --- a/Spotlight/SpotlightPlaylistController.h +++ b/Spotlight/SpotlightPlaylistController.h @@ -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 diff --git a/Spotlight/SpotlightPlaylistController.m b/Spotlight/SpotlightPlaylistController.m index 51aa67628..537bcde9f 100644 --- a/Spotlight/SpotlightPlaylistController.m +++ b/Spotlight/SpotlightPlaylistController.m @@ -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 \ No newline at end of file diff --git a/Spotlight/SpotlightWindowController.m b/Spotlight/SpotlightWindowController.m index ec93cea3d..f3e9cbf3e 100644 --- a/Spotlight/SpotlightWindowController.m +++ b/Spotlight/SpotlightWindowController.m @@ -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