aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-09-07 16:58:47 +0000
committerBibiko <bibiko@eva.mpg.de>2009-09-07 16:58:47 +0000
commit4f7b215bc3cb14270e2825eacc57c075eedc847e (patch)
tree9861ae48d3fa1ce71cf0879bfae575ffdf203c81
parent884ac3db36f3addee4183d976655a91994a5f656 (diff)
downloadsequelpro-4f7b215bc3cb14270e2825eacc57c075eedc847e.tar.gz
sequelpro-4f7b215bc3cb14270e2825eacc57c075eedc847e.tar.bz2
sequelpro-4f7b215bc3cb14270e2825eacc57c075eedc847e.zip
• removed leaks in QueryFavoriteManager
• prepared QueryController for future steps
-rw-r--r--Source/SPQueryController.h3
-rw-r--r--Source/SPQueryController.m21
-rw-r--r--Source/SPQueryFavoriteManager.m4
3 files changed, 26 insertions, 2 deletions
diff --git a/Source/SPQueryController.h b/Source/SPQueryController.h
index abef41de..2a15ba45 100644
--- a/Source/SPQueryController.h
+++ b/Source/SPQueryController.h
@@ -93,4 +93,7 @@
- (NSMutableArray *)favoritesForFileURL:(NSURL *)fileURL;
- (NSMutableArray *)historyForFileURL:(NSURL *)fileURL;
+- (NSArray *)queryFavoritesForFileURL:(NSURL *)fileURL andTabTrigger:(NSString *)tabTrigger includeGlobals:(BOOL)includeGlobals;
+
+
@end
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];
diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m
index 41276769..202cfa09 100644
--- a/Source/SPQueryFavoriteManager.m
+++ b/Source/SPQueryFavoriteManager.m
@@ -98,7 +98,7 @@
// change will be stored in the prefs at once)
if([prefs objectForKey:@"queryFavorites"]) {
for(id fav in [prefs objectForKey:@"queryFavorites"])
- [favorites addObject:[fav mutableCopy]];
+ [favorites addObject:[[fav mutableCopy] autorelease]];
}
[favorites addObject:[NSDictionary dictionaryWithObjectsAndKeys:
@@ -109,7 +109,7 @@
if([[SPQueryController sharedQueryController] favoritesForFileURL:delegatesFileURL]) {
for(id fav in [[SPQueryController sharedQueryController] favoritesForFileURL:delegatesFileURL])
- [favorites addObject:[fav mutableCopy]];
+ [favorites addObject:[[fav mutableCopy] autorelease]];
}