From bb8dfb0ad769b551ad2fd6944315c5292246ad7e Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sat, 21 Feb 2009 00:28:09 +0000 Subject: Deselect favorites when any detail other than the password is edited. This improves clarity, but also fixes an issue: if a connection with amended details failed, the default favourite details are reloaded in the sheet if a favorite is selected. This change allows a connection to fail and the actual used details to be reshown in the sheet. --- Source/TableDocument.h | 3 +++ Source/TableDocument.m | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'Source') diff --git a/Source/TableDocument.h b/Source/TableDocument.h index 52429c7b..61b770c3 100644 --- a/Source/TableDocument.h +++ b/Source/TableDocument.h @@ -203,6 +203,9 @@ - (void)willQueryString:(NSString *)query; - (void)queryGaveError:(NSString *)error; +// Connection sheet delegate methods +- (void) controlTextDidChange:(NSNotification *)aNotification; + //splitView delegate methods - (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview; - (float)splitView:(NSSplitView *)sender constrainMaxCoordinate:(float)proposedMax ofSubviewAt:(int)offset; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 10ef7dca..6fae3a0b 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -1515,6 +1515,22 @@ invoked when query gave an error [self showErrorInConsole:[NSString stringWithFormat:@"/* ERROR %@ */ %@;\n", currentTime, error]]; } +#pragma mark Connection sheet delegate methods + +/** + * When a favorite is selected, and the connection details are edited, deselect the favorite; + * this is clearer and also prevents a failed connection from being repopulated with the + * favorite's details instead of the last used details. + * This method allows the password to be changed without altering the selection. + */ +- (void) controlTextDidChange:(NSNotification *)aNotification +{ + if ([aNotification object] == hostField || [aNotification object] == userField || [aNotification object] == databaseField + || [aNotification object] == socketField || [aNotification object] == portField) { + [favoritesController setSelectionIndexes:[NSIndexSet indexSet]]; + } +} + #pragma mark SplitView delegate methods /** -- cgit v1.2.3