diff options
author | stuconnolly <stuart02@gmail.com> | 2011-03-13 18:50:40 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2011-03-13 18:50:40 +0000 |
commit | 1632c45fdd9d0b8fe1e0aef3e891e8bd5704df29 (patch) | |
tree | f2fc34195718108f7770900994443931b6b8807e | |
parent | c2cf0e39c3c59c3548bf39f0835ac552cdcd23f4 (diff) | |
download | sequelpro-1632c45fdd9d0b8fe1e0aef3e891e8bd5704df29.tar.gz sequelpro-1632c45fdd9d0b8fe1e0aef3e891e8bd5704df29.tar.bz2 sequelpro-1632c45fdd9d0b8fe1e0aef3e891e8bd5704df29.zip |
Fix issue related to dragging a node to a group node that is being renamed as well as fix all warnings related to the connection outlinew view.
-rw-r--r-- | Source/SPConnectionController.h | 5 | ||||
-rw-r--r-- | Source/SPConnectionController.m | 20 | ||||
-rw-r--r-- | Source/SPConnectionControllerDataSource.m | 7 | ||||
-rw-r--r-- | Source/SPConnectionControllerDelegate.m | 28 | ||||
-rw-r--r-- | Source/SPConnectionHandler.m | 17 | ||||
-rw-r--r-- | Source/SPFavoriteNode.h | 10 | ||||
-rw-r--r-- | Source/SPFavoriteNode.m | 7 | ||||
-rw-r--r-- | Source/SPFavoritesController.h | 2 | ||||
-rw-r--r-- | Source/SPFavoritesController.m | 7 | ||||
-rw-r--r-- | Source/SPGroupNode.m | 2 | ||||
-rw-r--r-- | Source/SPTreeNode.m | 4 |
11 files changed, 77 insertions, 32 deletions
diff --git a/Source/SPConnectionController.h b/Source/SPConnectionController.h index b6212dc0..de9063f9 100644 --- a/Source/SPConnectionController.h +++ b/Source/SPConnectionController.h @@ -44,7 +44,7 @@ @interface SPConnectionController : NSObject { - id <SPConnectionControllerDelegateProtocol> delegate; + NSObject <SPConnectionControllerDelegateProtocol> *delegate; SPDatabaseDocument *dbDocument; SPSSHTunnel *sshTunnel; @@ -139,6 +139,7 @@ IBOutlet NSTextField *progressIndicatorText; IBOutlet NSMenuItem *favoritesSortByMenuItem; + BOOL isEditing; BOOL isConnecting; BOOL cancellingConnection; BOOL reverseFavoritesSort; @@ -203,7 +204,7 @@ // Favorites interaction - (void)updateFavoriteSelection:(id)sender; -- (NSDictionary *)selectedFavorite; +- (NSMutableDictionary *)selectedFavorite; - (SPTreeNode *)selectedFavoriteNode; - (NSArray *)selectedFavoriteNodes; diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m index da828cda..0362b9ae 100644 --- a/Source/SPConnectionController.m +++ b/Source/SPConnectionController.m @@ -118,9 +118,11 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v connectionSSHKeychainItemName = nil; connectionSSHKeychainItemAccount = nil; + isEditing = NO; + isConnecting = NO; + sshTunnel = nil; mySQLConnection = nil; - isConnecting = NO; cancellingConnection = NO; mySQLConnectionCancelled = NO; @@ -519,7 +521,7 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v // Perform sorting [self _sortFavorites]; - if (previousSortItem > -1) [[[sender menu] itemAtIndex:previousSortItem] setState:NSOffState]; + if ((NSInteger)previousSortItem > -1) [[[sender menu] itemAtIndex:previousSortItem] setState:NSOffState]; [[[sender menu] itemAtIndex:currentSortItem] setState:NSOnState]; } @@ -637,7 +639,7 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v /** * Returns the selected favorite data dictionary or nil if nothing is selected. */ -- (NSDictionary *)selectedFavorite +- (NSMutableDictionary *)selectedFavorite { SPTreeNode *node = [self selectedFavoriteNode]; @@ -714,7 +716,7 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v SPTreeNode *selectedNode = [self selectedFavoriteNode]; - SPTreeNode *parent = ([selectedNode isGroup]) ? selectedNode : [selectedNode parentNode]; + SPTreeNode *parent = ([selectedNode isGroup]) ? selectedNode : (SPTreeNode *)[selectedNode parentNode]; SPTreeNode *node = [favoritesController addFavoriteNodeWithData:favorite asChildOfNode:parent]; @@ -722,7 +724,7 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v [self _selectNode:node]; [[[[NSApp delegate] preferenceController] generalPreferencePane] updateDefaultFavoritePopup]; - + favoriteNameFieldWasTouched = NO; [favoritesOutlineView editColumn:0 row:[favoritesOutlineView selectedRow] withEvent:nil select:YES]; @@ -829,13 +831,15 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v { SPTreeNode *selectedNode = [self selectedFavoriteNode]; - SPTreeNode *parent = ([selectedNode isGroup]) ? selectedNode : [selectedNode parentNode]; + SPTreeNode *parent = ([selectedNode isGroup]) ? selectedNode : (SPTreeNode *)[selectedNode parentNode]; SPTreeNode *node = [favoritesController addGroupNodeWithName:NSLocalizedString(@"New Folder", @"new folder placeholder name") asChildOfNode:parent]; [self _reloadFavoritesViewData]; [self _selectNode:node]; + isEditing = YES; + [favoritesOutlineView editColumn:0 row:[favoritesOutlineView selectedRow] withEvent:nil select:YES]; } @@ -928,7 +932,7 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v SPTreeNode *selectedNode = [self selectedFavoriteNode]; - SPTreeNode *parent = ([selectedNode isGroup]) ? selectedNode : [selectedNode parentNode]; + SPTreeNode *parent = ([selectedNode isGroup]) ? selectedNode : (SPTreeNode *)[selectedNode parentNode]; SPTreeNode *node = [favoritesController addFavoriteNodeWithData:favorite asChildOfNode:parent]; @@ -1322,7 +1326,7 @@ static NSComparisonResult compareFavoritesUsingKey(id favorite1, id favorite2, v // Re-enable favorites table view [favoritesOutlineView setEnabled:YES]; - [favoritesOutlineView display]; + [(NSView *)favoritesOutlineView display]; mySQLConnectionCancelled = NO; diff --git a/Source/SPConnectionControllerDataSource.m b/Source/SPConnectionControllerDataSource.m index 766b04f0..dd919980 100644 --- a/Source/SPConnectionControllerDataSource.m +++ b/Source/SPConnectionControllerDataSource.m @@ -29,6 +29,13 @@ #import "SPGroupNode.h" #import "SPTreeNode.h" +@interface SPConnectionController (PrivateAPI) + +- (void)_reloadFavoritesViewData; +- (void)_updateFavoritePasswordsFromField:(NSControl *)control; + +@end + @implementation SPConnectionController (SPConnectionControllerDataSource) - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m index 31ec4099..b86e716f 100644 --- a/Source/SPConnectionControllerDelegate.m +++ b/Source/SPConnectionControllerDelegate.m @@ -24,14 +24,27 @@ // More info at <http://code.google.com/p/sequel-pro/> #import "SPConnectionControllerDelegate.h" +#import "SPFavoritesController.h" #import "SPTableTextFieldCell.h" +#import "SPPreferenceController.h" +#import "SPGeneralPreferencePane.h" +#import "SPAppController.h" #import "SPFavoriteNode.h" #import "SPGroupNode.h" #import "SPTreeNode.h" #define CELL(cell) (SPTableTextFieldCell *)cell -static const NSString *SPDatabaseImage = @"database-small"; +static NSString *SPDatabaseImage = @"database-small"; + +@interface SPConnectionController (PrivateAPI) + +- (void)_checkHost; +- (void)_favoriteTypeDidChange; +- (void)_reloadFavoritesViewData; +- (void)_updateFavoritePasswordsFromField:(NSControl *)control; + +@end @implementation SPConnectionController (SPConnectionControllerDelegate) @@ -143,6 +156,17 @@ static const NSString *SPDatabaseImage = @"database-small"; - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard { + // If the user is in the process of changing a node's name, trigger a save and prevent dragging. + if (isEditing) { + [favoritesController saveFavorites]; + + [self _reloadFavoritesViewData]; + + isEditing = NO; + + return NO; + } + [pboard declareTypes:[NSArray arrayWithObject:SPFavoritesPasteboardDragType] owner:self]; [pboard setData:[NSData data] forType:SPFavoritesPasteboardDragType]; @@ -327,7 +351,7 @@ static const NSString *SPDatabaseImage = @"database-small"; { // Request a password refresh to keep keychain references in sync with favorites, but only if a favorite // is selected, meaning we're editing an existing one, not a new one. - if ((control != favoritesOutlineView) && ([self selectedFavoriteNode])) { + if (((id)control != (id)favoritesOutlineView) && ([self selectedFavoriteNode])) { [self _updateFavoritePasswordsFromField:control]; } diff --git a/Source/SPConnectionHandler.m b/Source/SPConnectionHandler.m index e66580a9..bca96ce1 100644 --- a/Source/SPConnectionHandler.m +++ b/Source/SPConnectionHandler.m @@ -24,7 +24,17 @@ // More info at <http://code.google.com/p/sequel-pro/> #import "SPConnectionHandler.h" +#import "SPDatabaseDocument.h" #import "SPAlertSheets.h" +#import "SPSSHTunnel.h" +#import "SPKeychain.h" +#import "RegexKitLite.h" + +@interface SPConnectionController (PrivateAPI) + +- (void)_restoreConnectionInterface; + +@end @implementation SPConnectionController (SPConnectionHandler) @@ -80,8 +90,7 @@ if ([self useSSL]) { [mySQLConnection setSSL:YES usingKeyFilePath:[self sslKeyFileLocationEnabled] ? [self sslKeyFileLocation] : nil - certificatePath:[self sslCertificateFileLocationEnabled] ? [self sslCertificateFileLocation] : nil -certificateAuthorityCertificatePath:[self sslCACertFileLocationEnabled] ? [self sslCACertFileLocation] : nil]; + certificatePath:[self sslCertificateFileLocationEnabled] ? [self sslCertificateFileLocation] : nil certificateAuthorityCertificatePath:[self sslCACertFileLocationEnabled] ? [self sslCACertFileLocation] : nil]; } // Connection delegate must be set before actual connection attempt is made @@ -262,7 +271,7 @@ certificateAuthorityCertificatePath:[self sslCACertFileLocationEnabled] ? [self // Re-enable favorites table view [favoritesOutlineView setEnabled:YES]; - [favoritesOutlineView display]; + [(NSView *)favoritesOutlineView display]; // Release the tunnel if set - will now be retained by the connection if (sshTunnel) [sshTunnel release], sshTunnel = nil; @@ -335,7 +344,7 @@ certificateAuthorityCertificatePath:[self sslCACertFileLocationEnabled] ? [self // Restore the toolbar icons NSArray *toolbarItems = [[[dbDocument parentWindow] toolbar] items]; - for (NSInteger i = 0; i < [toolbarItems count]; i++) [[toolbarItems objectAtIndex:i] setEnabled:YES]; + for (NSUInteger i = 0; i < [toolbarItems count]; i++) [[toolbarItems objectAtIndex:i] setEnabled:YES]; if (connectionKeychainID) [dbDocument setKeychainID:connectionKeychainID]; diff --git a/Source/SPFavoriteNode.h b/Source/SPFavoriteNode.h index a77e7dc0..ecd8aa28 100644 --- a/Source/SPFavoriteNode.h +++ b/Source/SPFavoriteNode.h @@ -32,18 +32,16 @@ */ @interface SPFavoriteNode : NSObject <NSCopying, NSCoding> { - NSDictionary *nodeFavorite; + NSMutableDictionary *nodeFavorite; } /** * @property nodeFavorite The actual favorite dictionary */ -@property (readwrite, retain) NSDictionary *nodeFavorite; +@property (readwrite, retain) NSMutableDictionary *nodeFavorite; -- (id)initWithDictionary:(NSDictionary *)dictionary; +- (id)initWithDictionary:(NSMutableDictionary *)dictionary; -+ (SPFavoriteNode *)favoriteNodeWithDictionary:(NSDictionary *)dictionary; - -- (NSDictionary *)dictionaryRepresentation; ++ (SPFavoriteNode *)favoriteNodeWithDictionary:(NSMutableDictionary *)dictionary; @end diff --git a/Source/SPFavoriteNode.m b/Source/SPFavoriteNode.m index ee40f61f..a70823f7 100644 --- a/Source/SPFavoriteNode.m +++ b/Source/SPFavoriteNode.m @@ -23,10 +23,11 @@ // // More info at <http://code.google.com/p/sequel-pro/> +#import "SPTreeNode.h" #import "SPFavoriteNode.h" // Constants -static const NSString *SPFavoriteNodeKey = @"SPFavoriteNode"; +static NSString *SPFavoriteNodeKey = @"SPFavoriteNode"; @implementation SPFavoriteNode @@ -44,7 +45,7 @@ static const NSString *SPFavoriteNodeKey = @"SPFavoriteNode"; return self; } -- (id)initWithDictionary:(NSDictionary *)dictionary +- (id)initWithDictionary:(NSMutableDictionary *)dictionary { if ((self = [self init])) { [self setNodeFavorite:dictionary]; @@ -53,7 +54,7 @@ static const NSString *SPFavoriteNodeKey = @"SPFavoriteNode"; return self; } -+ (SPFavoriteNode *)favoriteNodeWithDictionary:(NSDictionary *)dictionary ++ (SPFavoriteNode *)favoriteNodeWithDictionary:(NSMutableDictionary *)dictionary { return [[[self alloc] initWithDictionary:dictionary] autorelease]; } diff --git a/Source/SPFavoritesController.h b/Source/SPFavoritesController.h index 095e1cd0..3bde2376 100644 --- a/Source/SPFavoritesController.h +++ b/Source/SPFavoritesController.h @@ -60,7 +60,7 @@ - (void)reloadFavoritesWithSave:(BOOL)save; - (SPTreeNode *)addGroupNodeWithName:(NSString *)name asChildOfNode:(SPTreeNode *)parent; -- (SPTreeNode *)addFavoriteNodeWithData:(NSDictionary *)data asChildOfNode:(SPTreeNode *)parent; +- (SPTreeNode *)addFavoriteNodeWithData:(NSMutableDictionary *)data asChildOfNode:(SPTreeNode *)parent; - (void)removeFavoriteNode:(SPTreeNode *)node; diff --git a/Source/SPFavoritesController.m b/Source/SPFavoritesController.m index 7080c9b9..bd16e1ad 100644 --- a/Source/SPFavoritesController.m +++ b/Source/SPFavoritesController.m @@ -25,6 +25,7 @@ #import "SPFavoritesController.h" #import "SPFavoriteNode.h" +#import "SPTreeNode.h" #import "SPGroupNode.h" #import "pthread.h" @@ -154,7 +155,7 @@ static SPFavoritesController *sharedFavoritesController = nil; * * @return The node instance that was created and added */ -- (SPTreeNode *)addFavoriteNodeWithData:(NSDictionary *)data asChildOfNode:(SPTreeNode *)parent +- (SPTreeNode *)addFavoriteNodeWithData:(NSMutableDictionary *)data asChildOfNode:(SPTreeNode *)parent { SPTreeNode *node = [SPTreeNode treeNodeWithRepresentedObject:[SPFavoriteNode favoriteNodeWithDictionary:data]]; @@ -210,9 +211,9 @@ static SPFavoritesController *sharedFavoritesController = nil; favoritesData = [[NSDictionary alloc] initWithContentsOfFile:favoritesFile]; } else { - NSDictionary *newFavorites = [NSMutableDictionary dictionaryWithObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Favorites", @"favorites label"), SPFavoritesGroupNameKey, [NSArray array], SPFavoriteChildrenKey, nil] forKey:SPFavoritesRootKey]; + NSMutableDictionary *newFavorites = [NSMutableDictionary dictionaryWithObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Favorites", @"favorites label"), SPFavoritesGroupNameKey, [NSArray array], SPFavoriteChildrenKey, nil] forKey:SPFavoritesRootKey]; - NSError *error = nil; + error = nil; NSString *errorString = nil; NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:newFavorites diff --git a/Source/SPGroupNode.m b/Source/SPGroupNode.m index 182a96f7..5479397b 100644 --- a/Source/SPGroupNode.m +++ b/Source/SPGroupNode.m @@ -26,7 +26,7 @@ #import "SPGroupNode.h" // Constants -static const NSString *SPGroupNodeNameKey = @"SPGroupNodeName"; +static NSString *SPGroupNodeNameKey = @"SPGroupNodeName"; @implementation SPGroupNode diff --git a/Source/SPTreeNode.m b/Source/SPTreeNode.m index 3d5f2ebc..e197d180 100644 --- a/Source/SPTreeNode.m +++ b/Source/SPTreeNode.m @@ -28,7 +28,7 @@ #import "SPGroupNode.h" // Constants -static const NSString *SPTreeNodeIsGroupKey = @"SPTreeNodeIsGroup"; +static NSString *SPTreeNodeIsGroupKey = @"SPTreeNodeIsGroup"; @implementation SPTreeNode @@ -65,7 +65,7 @@ static const NSString *SPTreeNodeIsGroupKey = @"SPTreeNodeIsGroup"; for (SPTreeNode *node in [self childNodes]) { if (node == object) { - [[self childNodes] removeObjectIdenticalTo:object]; + [[self mutableChildNodes] removeObjectIdenticalTo:object]; return; } |