diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-09-03 15:18:37 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-09-03 15:18:37 +0000 |
commit | 623b55eeb355aaceb3ffe3e13197944bef6fb1d4 (patch) | |
tree | 11c8538c58a4fc37d7de7821162b5dcc983abe2d /Source/SPQueryConsole.m | |
parent | 8a8ba1fecaf8d51a964d09c04d6065b3769dea5f (diff) | |
download | sequelpro-623b55eeb355aaceb3ffe3e13197944bef6fb1d4.tar.gz sequelpro-623b55eeb355aaceb3ffe3e13197944bef6fb1d4.tar.bz2 sequelpro-623b55eeb355aaceb3ffe3e13197944bef6fb1d4.zip |
• fixed document registering with its query favorites and history
• added and applied removeRegisteredDocumentWithURL to remove a registered document from the app-wide query fav/history controller
• saveDocumentWithFilePath now returns the success status after saving
- if saving fails for some reasons SP suggests to save that doc under a new name
• fixed issues for "Save" an Untitled doc
• improved error handling
Diffstat (limited to 'Source/SPQueryConsole.m')
-rw-r--r-- | Source/SPQueryConsole.m | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/Source/SPQueryConsole.m b/Source/SPQueryConsole.m index 663855fe..bcea3e32 100644 --- a/Source/SPQueryConsole.m +++ b/Source/SPQueryConsole.m @@ -328,13 +328,14 @@ static SPQueryConsole *sharedQueryConsole = nil; #pragma mark - #pragma mark DocumentsController -- (NSURL *)registerDocumentWithFileURL:(NSURL *)fileURL andContextInfo:(NSDictionary *)contextInfo +- (NSURL *)registerDocumentWithFileURL:(NSURL *)fileURL andContextInfo:(NSMutableDictionary *)contextInfo { // Register a new untiled document and return its URL if(fileURL == nil) { NSURL *new = [NSURL URLWithString:[[NSString stringWithFormat:@"Untitled %d", untitledDocumentCounter] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; untitledDocumentCounter++; + if(![favoritesContainer objectForKey:[new absoluteString]]) [favoritesContainer setObject:[NSMutableArray array] forKey:[new absoluteString]]; if(![historyContainer objectForKey:[new absoluteString]]) @@ -342,25 +343,48 @@ static SPQueryConsole *sharedQueryConsole = nil; return new; } - - // Register a spf file - // if(![favoritesContainer objectForKey:[fileURL absoluteString]]) { - // if(contextInfo != nil && [contextInfo objectForKey:@"queryFavorites"] != nil) - // [favoritesContainer setObject:[[contextInfo objectForKey:@"queryFavorites"] mutableCopy] forKey:[fileURL absoluteString]]; - // else - // [favoritesContainer setObject:[NSMutableArray array] forKey:[fileURL absoluteString]]; - // } - // if(![historyContainer objectForKey:[fileURL absoluteString]]) { - // if(contextInfo != nil && [contextInfo objectForKey:@"queryHistory"] != nil) - // [historyContainer setObject:[[contextInfo objectForKey:@"queryHistory"] mutableCopy] forKey:[fileURL absoluteString]]; - // else - // [historyContainer setObject:[NSMutableArray array] forKey:[fileURL absoluteString]]; - // } + + // Register a spf file to manage all query favorites and query history items + // file path based in a dictionary whereby the key represents the file name. + if(![favoritesContainer objectForKey:[fileURL absoluteString]]) { + if(contextInfo != nil && [contextInfo objectForKey:@"queryFavorites"] && [[contextInfo objectForKey:@"queryFavorites"] count]) { + NSMutableArray *arr = [[NSMutableArray alloc] init]; + [arr addObjectsFromArray:[contextInfo objectForKey:@"queryFavorites"]]; + [favoritesContainer setObject:arr forKey:[fileURL absoluteString]]; + [arr release]; + } else { + NSMutableArray *arr = [[NSMutableArray alloc] init]; + [favoritesContainer setObject:arr forKey:[fileURL absoluteString]]; + [arr release]; + } + } + if(![historyContainer objectForKey:[fileURL absoluteString]]) { + if(contextInfo != nil && [contextInfo objectForKey:@"queryHistory"] && [[contextInfo objectForKey:@"queryHistory"] count]) { + NSMutableArray *arr = [[NSMutableArray alloc] init]; + [arr addObjectsFromArray:[contextInfo objectForKey:@"queryHistory"]]; + [historyContainer setObject:arr forKey:[fileURL absoluteString]]; + [arr release]; + } else { + NSMutableArray *arr = [[NSMutableArray alloc] init]; + [historyContainer setObject:arr forKey:[fileURL absoluteString]]; + [arr release]; + } + } return fileURL; } +- (void)removeRegisteredDocumentWithFileURL:(NSURL *)fileURL +{ + + if([favoritesContainer objectForKey:[fileURL absoluteString]]) + [favoritesContainer removeObjectForKey:[fileURL absoluteString]]; + if([historyContainer objectForKey:[fileURL absoluteString]]) + [historyContainer removeObjectForKey:[fileURL absoluteString]]; + +} + - (void)addFavorite:(NSString *)favorite forFileURL:(NSURL *)fileURL { |