aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPConnectionControllerDelegate.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-08-06 09:19:58 +0000
committerstuconnolly <stuart02@gmail.com>2012-08-06 09:19:58 +0000
commit4be3e59653119605294ebcb7e341df00ee8c3b05 (patch)
tree9ccca3989cc0e2548c83f347c102db565a8b891d /Source/SPConnectionControllerDelegate.m
parentbec9204f21160fe4c001df75050e5d0ec8e42a2f (diff)
downloadsequelpro-4be3e59653119605294ebcb7e341df00ee8c3b05.tar.gz
sequelpro-4be3e59653119605294ebcb7e341df00ee8c3b05.tar.bz2
sequelpro-4be3e59653119605294ebcb7e341df00ee8c3b05.zip
Fix being able to type favorite names with spaces as well as remove some redundant checks and duplicate code.
Diffstat (limited to 'Source/SPConnectionControllerDelegate.m')
-rw-r--r--Source/SPConnectionControllerDelegate.m46
1 files changed, 13 insertions, 33 deletions
diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m
index d8f82a02..30b602cd 100644
--- a/Source/SPConnectionControllerDelegate.m
+++ b/Source/SPConnectionControllerDelegate.m
@@ -239,11 +239,13 @@ static NSString *SPDatabaseImage = @"database-small";
// Ensure that none of the dragged nodes are being dragged into children of themselves; if they are,
// prevent the drag.
id itemToCheck = item;
+
do {
if ([draggedNodes containsObject:itemToCheck]) {
return result;
}
- } while ((itemToCheck = [itemToCheck parentNode]));
+ }
+ while ((itemToCheck = [itemToCheck parentNode]));
if ([info draggingSource] == outlineView) {
[outlineView setDropItem:item dropChildIndex:childIndex];
@@ -357,61 +359,40 @@ static NSString *SPDatabaseImage = @"database-small";
id field = [notification object];
if (((field == standardNameField) || (field == socketNameField) || (field == sshNameField)) && [self selectedFavoriteNode]) {
-
- [field setStringValue:[self _stripInvalidCharactersFromString:[field stringValue]]];
-
+
favoriteNameFieldWasTouched = YES;
- BOOL nameFieldIsEmpty = [[field stringValue] isEqualToString:@""];
+ NSString *favoriteName = [self _stripInvalidCharactersFromString:[field stringValue]];
+
+ BOOL nameFieldIsEmpty = [favoriteName length] == 0;
switch (previousType)
{
case SPTCPIPConnection:
-
- nameFieldIsEmpty = (nameFieldIsEmpty || [[standardNameField stringValue] isEqualToString:@""]);
-
if (nameFieldIsEmpty || (!favoriteNameFieldWasTouched && (field == standardUserField || field == standardSQLHostField))) {
[standardNameField setStringValue:[NSString stringWithFormat:@"%@@%@", [standardUserField stringValue], [standardSQLHostField stringValue]]];
-
- // Trigger KVO update
- [self setName:[standardNameField stringValue]];
-
- // If name field is empty enable user@host update
- if (nameFieldIsEmpty) favoriteNameFieldWasTouched = NO;
}
break;
case SPSocketConnection:
-
- nameFieldIsEmpty = (nameFieldIsEmpty || [[socketNameField stringValue] isEqualToString:@""]);
-
if (nameFieldIsEmpty || (!favoriteNameFieldWasTouched && field == socketUserField)) {
[socketNameField setStringValue:[NSString stringWithFormat:@"%@@localhost", [socketUserField stringValue]]];
-
- // Trigger KVO update
- [self setName:[socketNameField stringValue]];
-
- // If name field is empty enable user@host update
- if (nameFieldIsEmpty) favoriteNameFieldWasTouched = NO;
}
break;
case SPSSHTunnelConnection:
-
- nameFieldIsEmpty = (nameFieldIsEmpty || [[sshNameField stringValue] isEqualToString:@""]);
-
if (nameFieldIsEmpty || (!favoriteNameFieldWasTouched && (field == sshUserField || field == sshSQLHostField))) {
[sshNameField setStringValue:[NSString stringWithFormat:@"%@@%@", [sshUserField stringValue], [sshSQLHostField stringValue]]];
-
- // Trigger KVO update
- [self setName:[sshNameField stringValue]];
-
- // If name field is empty enable user@host update
- if (nameFieldIsEmpty) favoriteNameFieldWasTouched = NO;
}
break;
}
+
+ // Trigger KVO update
+ [self setName:favoriteName];
+
+ // If name field is empty enable user@host update
+ if (nameFieldIsEmpty) favoriteNameFieldWasTouched = NO;
}
}
@@ -432,7 +413,6 @@ static NSString *SPDatabaseImage = @"database-small";
*/
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
{
-
// 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 (((id)control != (id)favoritesOutlineView) && ([self selectedFavoriteNode])) {