aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPAppController.m12
-rw-r--r--Source/SPDatabaseDocument.m20
-rw-r--r--Source/SPTableContent.h1
-rw-r--r--Source/SPTableContent.m10
4 files changed, 38 insertions, 5 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m
index 8635fb29..46709aac 100644
--- a/Source/SPAppController.m
+++ b/Source/SPAppController.m
@@ -327,6 +327,7 @@
NSFileManager *fileManager = [NSFileManager defaultManager];
+ // Retrieve Save Panel accessory view data for remembering them globally
NSMutableDictionary *spfsDocData = [NSMutableDictionary dictionary];
[spfsDocData setObject:[NSNumber numberWithBool:[[spfs objectForKey:@"encrypted"] boolValue]] forKey:@"encrypted"];
[spfsDocData setObject:[NSNumber numberWithBool:[[spfs objectForKey:@"auto_connect"] boolValue]] forKey:@"auto_connect"];
@@ -334,15 +335,19 @@
[spfsDocData setObject:[NSNumber numberWithBool:[[spfs objectForKey:@"include_session"] boolValue]] forKey:@"include_session"];
[spfsDocData setObject:[NSNumber numberWithBool:[[spfs objectForKey:@"save_editor_content"] boolValue]] forKey:@"save_editor_content"];
+ // Set global session properties
[[NSApp delegate] setSpfSessionDocData:spfsDocData];
[[NSApp delegate] setSessionURL:filename];
+ // Loop through each defined window in reversed order to reconstruct the last active window
for(NSDictionary *window in [[[spfs objectForKey:@"windows"] reverseObjectEnumerator] allObjects]) {
// Create a new window controller, and set up a new connection view within it.
SPWindowController *newWindowController = [[SPWindowController alloc] initWithWindowNibName:@"MainWindow"];
NSWindow *newWindow = [newWindowController window];
+ // If window has more than 1 tab then set setHideForSingleTab to NO
+ // in order to avoid animation problems while opening tabs
if([[window objectForKey:@"tabs"] count] > 1)
[newWindowController setHideForSingleTab:NO];
@@ -365,11 +370,14 @@
// Show the window
[newWindowController showWindow:self];
+ // Loop through all defined tabs for each window
for(NSDictionary *tab in [window objectForKey:@"tabs"]) {
NSString *fileName = nil;
BOOL isBundleFile = NO;
+ // If isAbsolutePath then take this path directly
+ // otherwise construct the releative path for the passed spfs file
if([[tab objectForKey:@"isAbsolutePath"] boolValue])
fileName = [tab objectForKey:@"path"];
else {
@@ -377,8 +385,10 @@
isBundleFile = YES;
}
+ // Security check if file really exists
if([fileManager fileExistsAtPath:fileName]) {
+ // Add new the tab
if(newWindowController) {
if ([[newWindowController window] isMiniaturized]) [[newWindowController window] deminiaturize:self];
@@ -394,7 +404,9 @@
}
}
+ // Select active tab
[newWindowController selectTabAtIndex:[[window objectForKey:@"selectedTabIndex"] intValue]];
+ // Reset setHideForSingleTab
[newWindowController setHideForSingleTab:YES];
}
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index d2ba3d85..3c83f611 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -546,7 +546,6 @@
if([spfSession objectForKey:@"connectionEncoding"] && ![[self connectionEncoding] isEqualToString:[spfSession objectForKey:@"connectionEncoding"]])
[self setConnectionEncoding:[spfSession objectForKey:@"connectionEncoding"] reloadingViews:YES];
-
if(isSelectedTableDefined) {
// Set table content details for restore
if([spfSession objectForKey:@"contentSortCol"])
@@ -727,13 +726,17 @@
if(spfSession != nil) {
+ // Restore vertical split view divider for tables' list and right view (Structure, Content, etc.)
+ if([spfSession objectForKey:@"windowVerticalDividerPosition"])
+ [contentViewSplitter setPosition:[[spfSession objectForKey:@"windowVerticalDividerPosition"] floatValue] ofDividerAtIndex:0];
+
// Start a task to restore the session details
[self startTaskWithDescription:NSLocalizedString(@"Restoring session...", @"Restoring session task description")];
- if ([NSThread isMainThread]) {
+ if ([NSThread isMainThread])
[NSThread detachNewThreadSelector:@selector(restoreSession) toTarget:self withObject:nil];
- } else {
+ else
[self restoreSession];
- }
+
} else {
switch ([prefs integerForKey:SPDefaultViewMode] > 0 ? [prefs integerForKey:SPDefaultViewMode] : [prefs integerForKey:SPLastViewMode]) {
default:
@@ -3025,6 +3028,10 @@
NSInteger tabCount = 0;
NSInteger selectedTabItem = 0;
for(SPDatabaseDocument *doc in [[window windowController] documents]) {
+
+ // Skip not connected docs eg if connection controller is displayed (TODO maybe to be improved)
+ if(![doc mySQLVersion]) continue;
+
NSMutableDictionary *tabData = [NSMutableDictionary dictionary];
if([doc isUntitled]) {
// new bundle file name for untitled docs
@@ -3047,6 +3054,7 @@
selectedTabItem = tabCount;
tabCount++;
}
+ if(![tabs count]) continue;
[win setObject:tabs forKey:@"tabs"];
[win setObject:[NSNumber numberWithInteger:selectedTabItem] forKey:@"selectedTabIndex"];
[win setObject:NSStringFromRect([window frame]) forKey:@"frame"];
@@ -3213,7 +3221,8 @@
[spfdata setObject:[NSNumber numberWithInteger:1] forKey:@"version"];
[spfdata setObject:@"connection" forKey:@"format"];
[spfdata setObject:@"mysql" forKey:@"rdbms_type"];
- [spfdata setObject:[self mySQLVersion] forKey:@"rdbms_version"];
+ if([self mySQLVersion])
+ [spfdata setObject:[self mySQLVersion] forKey:@"rdbms_version"];
// Store the preferences - take them from the current document URL to catch renaming
[spfdata setObject:[[SPQueryController sharedQueryController] favoritesForFileURL:[self fileURL]] forKey:SPQueryFavorites];
@@ -3314,6 +3323,7 @@
[session setObject:[NSNumber numberWithBool:[tableContentInstance sortColumnIsAscending]] forKey:@"contentSortColIsAsc"];
[session setObject:[NSNumber numberWithInteger:[tableContentInstance pageNumber]] forKey:@"contentPageNumber"];
+ [session setObject:[NSNumber numberWithFloat:[tableContentInstance tablesListWidth]] forKey:@"windowVerticalDividerPosition"];
[session setObject:NSStringFromRect([tableContentInstance viewport]) forKey:@"contentViewport"];
if([tableContentInstance filterSettings])
[session setObject:[tableContentInstance filterSettings] forKey:@"contentFilter"];
diff --git a/Source/SPTableContent.h b/Source/SPTableContent.h
index 731e2383..7b87bc32 100644
--- a/Source/SPTableContent.h
+++ b/Source/SPTableContent.h
@@ -157,6 +157,7 @@
- (NSUInteger) pageNumber;
- (NSIndexSet *) selectedRowIndexes;
- (NSRect) viewport;
+- (CGFloat) tablesListWidth;
- (NSDictionary *) filterSettings;
- (void) setSortColumnNameToRestore:(NSString *)theSortColumnName isAscending:(BOOL)isAscending;
- (void) setPageToRestore:(NSUInteger)thePage;
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index d5ffb47c..75ab4f4a 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -2520,10 +2520,20 @@
*/
- (NSRect) viewport
{
+ NSLog(@"t %@", NSStringFromRect([[tablesListInstance valueForKeyPath:@"tablesListView"] frame]));
+ NSLog(@"c %@", NSStringFromRect([tableContentView visibleRect]));
return [tableContentView visibleRect];
}
/**
+ * Provide a getter for the table's list view width
+ */
+- (CGFloat) tablesListWidth
+{
+ return [[[[tableDocumentInstance valueForKeyPath:@"contentViewSplitter"] subviews] objectAtIndex:0] frame].size.width;
+}
+
+/**
* Provide a getter for the current filter details
*/
- (NSDictionary *) filterSettings