diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-09-03 08:55:57 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-09-03 08:55:57 +0000 |
commit | 58547cd1044df7a4d28a6007d4ff85d7b09ca399 (patch) | |
tree | 968ea2ca18225f5059341dffb865464928b07737 /Source/SPQueryConsole.m | |
parent | 5a2bb9490deb817a3e5e2e1b838fccb55857bd3f (diff) | |
download | sequelpro-58547cd1044df7a4d28a6007d4ff85d7b09ca399.tar.gz sequelpro-58547cd1044df7a4d28a6007d4ff85d7b09ca399.tar.bz2 sequelpro-58547cd1044df7a4d28a6007d4ff85d7b09ca399.zip |
• fixed issue if a SPF file contains non-valid URL character like space, etc.
• each new connection which is non-SPF file-based gets the document name "Untitled x"
• prepared SPQueryConsole to manage all query favorite and history data application-wide
• minor code fixes and renaming issues
Diffstat (limited to 'Source/SPQueryConsole.m')
-rw-r--r-- | Source/SPQueryConsole.m | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Source/SPQueryConsole.m b/Source/SPQueryConsole.m index d7f29811..312b637b 100644 --- a/Source/SPQueryConsole.m +++ b/Source/SPQueryConsole.m @@ -95,6 +95,11 @@ static SPQueryConsole *sharedQueryConsole = nil; // Weak reference to active messages set - starts off as full set messagesVisibleSet = messagesFullSet; + + untitledDocumentCounter = 1; + + favoritesContainer = [[NSMutableDictionary alloc] init]; + historyContainer = [[NSMutableDictionary alloc] init]; } return self; @@ -321,6 +326,62 @@ static SPQueryConsole *sharedQueryConsole = nil; } #pragma mark - +#pragma mark DocumentsController + +- (NSURL *)registerDocumentWithFileURL:(NSURL *)fileURL andContextInfo:(NSDictionary *)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]]) + [historyContainer setObject:[NSMutableArray array] forKey:[new absoluteString]]; + + 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]]; + } + NSLog(@"shared %@ %@", historyContainer, favoritesContainer); + return fileURL; + +} + +- (void)addFavorite:(NSString *)favorite forFileURL:(NSURL *)fileURL +{ + +} + +- (void)addHistory:(NSString *)history forFileURL:(NSURL *)fileURL +{ + +} + +- (void)favoritesForFileURL:(NSURL *)fileURL +{ + +} + +- (void)historyForFileURL:(NSURL *)fileURL +{ + +} + +#pragma mark - #pragma mark Other /** @@ -383,6 +444,9 @@ static SPQueryConsole *sharedQueryConsole = nil; [messagesFilteredSet release], messagesFilteredSet = nil; [activeFilterString release], activeFilterString = nil; + [favoritesContainer release]; + [historyContainer release]; + [super dealloc]; } |