diff options
-rw-r--r-- | Source/SPGotoDatabaseController.h | 5 | ||||
-rw-r--r-- | Source/SPGotoDatabaseController.m | 25 |
2 files changed, 22 insertions, 8 deletions
diff --git a/Source/SPGotoDatabaseController.h b/Source/SPGotoDatabaseController.h index 05dfcbf1..3ae15d95 100644 --- a/Source/SPGotoDatabaseController.h +++ b/Source/SPGotoDatabaseController.h @@ -29,7 +29,6 @@ // More info at <https://github.com/sequelpro/sequelpro> #import <Cocoa/Cocoa.h> -@class SPDatabaseDocument; /** * This class provides a dialog with a single-column table view and a @@ -61,10 +60,10 @@ /** * Set the list of databases the user can pick from. - * @param list An array of NSStrings + * @param list An array of NSStrings, will be shallow-copied * * This method must be called before runModal. The list will not be updated - * when the dialog is on screen. + * while the dialog is on screen. */ - (void)setDatabaseList:(NSArray *)list; diff --git a/Source/SPGotoDatabaseController.m b/Source/SPGotoDatabaseController.m index d9573ea4..3f9a4730 100644 --- a/Source/SPGotoDatabaseController.m +++ b/Source/SPGotoDatabaseController.m @@ -29,10 +29,19 @@ // More info at <https://github.com/sequelpro/sequelpro> #import "SPGotoDatabaseController.h" -#import "SPDatabaseDocument.h" @interface SPGotoDatabaseController (Private) +/** Update the list of matched names + * @param filter The string to be matched. + * @param exactMatch Will be set to YES if there is at least one entry in + * unfilteredList that is equivalent to filter. Can be NULL to disable. + * + * This method will take every item in the unfilteredList and add matching items + * to the filteredList, including highlighting. + * It will neither clear the filteredList first, nor change the isFiltered ivar! + * Search is case insensitive. + */ - (void)_buildHightlightedFilterList:(NSString *)filter didFindExactMatch:(BOOL *)exactMatch; - (IBAction)okClicked:(id)sender; @@ -58,6 +67,12 @@ return self; } +- (void)windowDidLoad { + // Handle a double click in the DB list the same as if OK was clicked. + [databaseListView setTarget:self]; + [databaseListView setDoubleAction:@selector(okClicked:)]; +} + #pragma mark - #pragma mark IBAction @@ -169,13 +184,13 @@ [NSNumber numberWithInt:NSUnderlineStyleSingle],NSUnderlineStyleAttributeName, nil]; - for (NSString *db in unfilteredList) - { - NSRange match = [db rangeOfString:filter]; + for (NSString *db in unfilteredList) { + // Let's just assume it is in the users interest (most of the time) for searches to be CI. + NSRange match = [db rangeOfString:filter options:NSCaseInsensitiveSearch]; if (match.location == NSNotFound) continue; - // Check for exact match? + // Should we check for exact match AND have not yet found one? if (exactMatch && !*exactMatch) { if (match.location == 0 && match.length == [db length]) { *exactMatch = YES; |