From 4f7b215bc3cb14270e2825eacc57c075eedc847e Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 7 Sep 2009 16:58:47 +0000 Subject: =?UTF-8?q?=E2=80=A2=20removed=20leaks=20in=20QueryFavoriteManager?= =?UTF-8?q?=20=E2=80=A2=20prepared=20QueryController=20for=20future=20step?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPQueryController.m | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Source/SPQueryController.m') diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index 4dbd3749..a08a0906 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -569,6 +569,27 @@ static SPQueryController *sharedQueryController = nil; } +- (NSArray *)queryFavoritesForFileURL:(NSURL *)fileURL andTabTrigger:(NSString *)tabTrigger includeGlobals:(BOOL)includeGlobals +{ + + if(![tabTrigger length]) return [NSArray array]; + + NSMutableArray *result = [[NSMutableArray alloc] init]; + for(id fav in [self favoritesForFileURL:fileURL]) { + if([fav objectForKey:@"tabtrigger"] && [[fav objectForKey:@"tabtrigger"] isEqualToString:tabTrigger]) + [result addObject:fav]; + } + + if(includeGlobals && [prefs objectForKey:@"queryFavorites"]) { + for(id fav in [prefs objectForKey:@"queryFavorites"]) { + if([fav objectForKey:@"tabtrigger"] && [[fav objectForKey:@"tabtrigger"] isEqualToString:tabTrigger]) + [result addObject:fav]; + } + } + + return [result autorelease]; +} + - (void)removeFavoriteAtIndex:(NSUInteger)index forFileURL:(NSURL *)fileURL { [[favoritesContainer objectForKey:[fileURL absoluteString]] removeObjectAtIndex:index]; -- cgit v1.2.3