aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableDocument.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-09-04 08:45:47 +0000
committerBibiko <bibiko@eva.mpg.de>2009-09-04 08:45:47 +0000
commit931a46891ac3f0610363105419b01eb7b40b034f (patch)
tree26c68003589c07e2bdd8ebad53111e778c54f13d /Source/TableDocument.m
parenta8bee6d7815cf9431cc53522f74bed648087a674 (diff)
downloadsequelpro-931a46891ac3f0610363105419b01eb7b40b034f.tar.gz
sequelpro-931a46891ac3f0610363105419b01eb7b40b034f.tar.bz2
sequelpro-931a46891ac3f0610363105419b01eb7b40b034f.zip
• implementation of a new history controller
- each history is doc-based even if you have opened not only one instance of the same spf file - for each SPF file identified by its file URL SP remembers each history item regardless from which doc instance it comes from internally ( to make sure that after closing the last instance of a doc all executed queries are saved in that file - if the user wants to change that s/he has to save that file under a different name ) - the history list for each Untitled doc will be initialized by the items stored in the global SP's prefs - the history list for each SPF doc will be initialized by the items stored in the SPF file unless an instance of the same file is already open - then the new instance inherits the history list from the opened one(s) - all history items executed in any Untitled docs will be added to SP's prefs - in other words SP's global prefs plist is the historyrepository for each new Untitled doc - if the user saves an untitled doc or rename an opened SPF file the _current_ history list for that doc will be saved to the chosen file unless an other doc instance is still open - all history lists are saved automatically if SP quits or the user closes a doc window Note: This should be tested for any logical pitfalls - each desired logic can be implemented :)
Diffstat (limited to 'Source/TableDocument.m')
-rw-r--r--Source/TableDocument.m35
1 files changed, 20 insertions, 15 deletions
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 35df953c..9c56ff04 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -507,7 +507,12 @@
_isConnected = YES;
mySQLConnection = [theConnection retain];
-
+
+ // Set the fileURL and init the preferences (query favs and history) if available for that URL
+ [self setFileURL:[[SPQueryController sharedQueryController] registerDocumentWithFileURL:[self fileURL] andContextInfo:[spfPreferences retain]]];
+
+ [spfPreferences release];
+
// Set the connection encoding
NSString *encodingName = [prefs objectForKey:@"DefaultEncoding"];
if ( [encodingName isEqualToString:@"Autodetect"] ) {
@@ -597,11 +602,6 @@
else
[tableWindow makeFirstResponder:[tablesListInstance valueForKeyPath:@"tablesListView"]];
- NSURL *anURL = [[SPQueryController sharedQueryController] registerDocumentWithFileURL:[self fileURL] andContextInfo:[spfPreferences retain]];
- [self setFileURL:anURL];
-
- [spfPreferences release];
-
if(spfSession != nil)
[self restoreSession];
@@ -2163,8 +2163,8 @@
}
// Update the keys
- [spf setObject:[customQueryInstance localFavorites] forKey:@"queryFavorites"];
- [spf setObject:[customQueryInstance localHistoryItems] forKey:@"queryHistory"];
+ [spf setObject:[[SPQueryController sharedQueryController] favoritesForFileURL:[self fileURL]] forKey:@"queryFavorites"];
+ [spf setObject:[[SPQueryController sharedQueryController] historyForFileURL:[self fileURL]] forKey:@"queryHistory"];
// Save it again
NSString *err = nil;
@@ -2212,9 +2212,9 @@
[spfdata setObject:@"mysql" forKey:@"rdbms_type"];
[spfdata setObject:[self mySQLVersion] forKey:@"rdbms_version"];
- // Store the preferences
- [spfdata setObject:[customQueryInstance localFavorites] forKey:@"queryFavorites"];
- [spfdata setObject:[customQueryInstance localHistoryItems] forKey:@"queryHistory"];
+ // Store the preferences - take them from the current document URL to catch renaming
+ [spfdata setObject:[[SPQueryController sharedQueryController] favoritesForFileURL:[self fileURL]] forKey:@"queryFavorites"];
+ [spfdata setObject:[[SPQueryController sharedQueryController] historyForFileURL:[self fileURL]] forKey:@"queryHistory"];
[spfdata setObject:[spfDocData_temp objectForKey:@"encrypted"] forKey:@"encrypted"];
@@ -2360,17 +2360,22 @@
return NO;
}
- // TODO take favs and history frm untitle or old file name with me
- [[SPQueryController sharedQueryController] registerDocumentWithFileURL:[NSURL URLWithString:[fileName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] andContextInfo:nil];
+ // Register and update query favorites and history for the (new) file URL
+ NSMutableDictionary *preferences = [[NSMutableDictionary alloc] init];
+ [preferences setObject:[spfdata objectForKey:@"queryHistory"] forKey:@"queryHistory"];
+ [preferences setObject:[spfdata objectForKey:@"queryFavorites"] forKey:@"queryFavorites"];
+ [[SPQueryController sharedQueryController] registerDocumentWithFileURL:[NSURL URLWithString:[fileName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] andContextInfo:preferences];
[self setFileURL:[NSURL URLWithString:[fileName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
[tableWindow setTitle:[self displayName]];
-
+
// Store doc data permanently
[spfDocData removeAllObjects];
[spfDocData addEntriesFromDictionary:spfDocData_temp];
-
+
+ [preferences release];
+
return YES;
}