diff options
author | stuconnolly <stuart02@gmail.com> | 2010-09-26 14:49:42 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2010-09-26 14:49:42 +0000 |
commit | 25ef15930d0b8d4ce558ca89e721910aa2391dd8 (patch) | |
tree | 2eeb3e57f0758639d155d2f9e1976a594b23d9d9 /Source/SPConnectionController.m | |
parent | 8fbd6bbedd98e012b2b2a56e3c9a87672e55e179 (diff) | |
download | sequelpro-25ef15930d0b8d4ce558ca89e721910aa2391dd8.tar.gz sequelpro-25ef15930d0b8d4ce558ca89e721910aa2391dd8.tar.bz2 sequelpro-25ef15930d0b8d4ce558ca89e721910aa2391dd8.zip |
- Correctly sort connection favourites upon startup for both the connection and preferences view. Fixes issue #807.
- Remove the default favourite indicator from the preferences view.
Diffstat (limited to 'Source/SPConnectionController.m')
-rw-r--r-- | Source/SPConnectionController.m | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index aefca1fd..6e760a9d 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -94,7 +94,7 @@ isConnecting = NO; mySQLConnectionCancelled = NO; favoritesPBoardType = @"FavoritesPBoardType"; - + // Load the connection nib, keeping references to the top-level objects for later release nibObjectsToRelease = [[NSMutableArray alloc] init]; NSArray *connectionViewTopLevelObjects = nil; @@ -106,17 +106,20 @@ // Hide the main view and position and display the connection view [databaseConnectionView setHidden:YES]; [connectionView setFrame:[databaseConnectionView frame]]; - [databaseConnectionSuperview addSubview:connectionView]; + [databaseConnectionSuperview addSubview:connectionView]; [connectionSplitView setPosition:[[tableDocument valueForKey:@"dbTablesTableView"] frame].size.width-6 ofDividerAtIndex:0]; [connectionSplitViewButtonBar setSplitViewDelegate:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scrollViewFrameChanged:) name:NSViewFrameDidChangeNotification object:nil]; - + // Set up a keychain instance and preferences reference, and create the initial favorites list keychain = [[SPKeychain alloc] init]; prefs = [[NSUserDefaults standardUserDefaults] retain]; + favorites = nil; + + // Load favorites [self updateFavorites]; - + // Register an observer for changes within the favorites [prefs addObserver:self forKeyPath:SPFavorites options:NSKeyValueObservingOptionNew context:NULL]; @@ -131,7 +134,7 @@ [favoritesTable setDraggingSourceOperationMask:NSDragOperationMove forLocal:YES]; // Sort the favourites to match prefs and select the appropriate row - if (currentSortItem > -1) [self _sortFavorites]; + [self _sortFavorites]; NSInteger tableRow = ([prefs integerForKey:[prefs boolForKey:SPSelectLastFavoriteUsed] ? SPLastFavoriteIndex : SPDefaultFavorite] + 1); @@ -140,11 +143,13 @@ [favoritesTable selectRowIndexes:[NSIndexSet indexSetWithIndex:tableRow] byExtendingSelection:NO]; [self resizeTabViewToConnectionType:[[[favorites objectAtIndex:tableRow] objectForKey:@"type"] integerValue] animating:NO]; [favoritesTable scrollRowToVisible:[favoritesTable selectedRow]]; - } else { + } + else { previousType = SPTCPIPConnection; [self resizeTabViewToConnectionType:SPTCPIPConnection animating:NO]; } } + return self; } @@ -488,26 +493,27 @@ * interface, allowing the application to run as normal. */ - (void)addConnectionToDocument -{ - +{ // Hide the connection view and restore the main view [connectionView removeFromSuperviewWithoutNeedingDisplay]; [databaseConnectionView setHidden:NO]; - + // Restore the toolbar icons NSArray *toolbarItems = [[[tableDocument parentWindow] toolbar] items]; + for (NSInteger i = 0; i < [toolbarItems count]; i++) [[toolbarItems objectAtIndex:i] setEnabled:YES]; // Set keychain id for saving SPF files - if([self valueForKeyPath:@"selectedFavorite.id"]) + if ([self valueForKeyPath:@"selectedFavorite.id"]) { [tableDocument setKeychainID:[[self valueForKeyPath:@"selectedFavorite.id"] stringValue]]; - else + } + else { [tableDocument setKeychainID:@""]; + } // Pass the connection to the table document, allowing it to set // up the other classes and the rest of the interface. [tableDocument setConnection:mySQLConnection]; - } #pragma mark - |