diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-03-09 08:39:13 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-03-09 08:39:13 +0000 |
commit | aa0a178df3316777c001c59e03c534cfa537b365 (patch) | |
tree | 48fd04e1c7b26c543de4fcb3a002eb7afbf00462 /Source/SPNarrowDownCompletion.m | |
parent | c0aa273646ad4b6be2d1c47a6e9d4fa67a9c59b9 (diff) | |
download | sequelpro-aa0a178df3316777c001c59e03c534cfa537b365.tar.gz sequelpro-aa0a178df3316777c001c59e03c534cfa537b365.tar.bz2 sequelpro-aa0a178df3316777c001c59e03c534cfa537b365.zip |
• fixed some minor GUI issues for SPNarrowDownCompletion window
- added oneColumn mode for dict and list view to decrease the window's width
Diffstat (limited to 'Source/SPNarrowDownCompletion.m')
-rw-r--r-- | Source/SPNarrowDownCompletion.m | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index 9f539d67..ea6752f6 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -139,7 +139,7 @@ charRange:(NSRange)initRange parseRange:(NSRange)parseRange inView:(id)aView dictMode:(BOOL)mode dbMode:(BOOL)theDbMode tabTriggerMode:(BOOL)tabTriggerMode fuzzySearch:(BOOL)fuzzySearch backtickMode:(NSInteger)theBackTickMode withDbName:(NSString*)dbName withTableName:(NSString*)tableName - selectedDb:(NSString*)selectedDb caretMovedLeft:(BOOL)caretMovedLeft autoComplete:(BOOL)autoComplete + selectedDb:(NSString*)selectedDb caretMovedLeft:(BOOL)caretMovedLeft autoComplete:(BOOL)autoComplete oneColumn:(BOOL)oneColumn { if(self = [self init]) { @@ -149,6 +149,7 @@ [mutablePrefix appendString:aUserString]; autoCompletionMode = autoComplete; + oneColumnMode = oneColumn; fuzzyMode = fuzzySearch; if(fuzzyMode) @@ -177,8 +178,25 @@ suggestions = [someSuggestions retain]; - [[theTableView tableColumnWithIdentifier:@"image"] setWidth:((dictMode) ? 0 : 20)]; - [[theTableView tableColumnWithIdentifier:@"name"] setWidth:((dictMode) ? 440 : 180)]; + if(dictMode || oneColumnMode) { + [[theTableView tableColumnWithIdentifier:@"image"] setWidth:0]; + if(!dictMode) { + NSUInteger maxLength = 0; + for(id w in someSuggestions) { + NSUInteger len = [[w objectForKey:@"display"] length]; + if(len>maxLength) maxLength = len; + } + NSMutableString *dummy = [NSMutableString string]; + for(NSUInteger i=0; i<maxLength; i++) + [dummy appendString:@" "]; + + CGFloat w = NSSizeToCGSize([dummy sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).width + 26.0f; + maxWindowWidth = (w>maxWindowWidth) ? maxWindowWidth : w; + } else { + maxWindowWidth = 220; + } + [[theTableView tableColumnWithIdentifier:@"name"] setWidth:maxWindowWidth]; + } currentDb = selectedDb; @@ -344,8 +362,6 @@ if(dictMode) { return @""; } else { - // [[aTableColumn dataCell] setTextColor:([aTableView selectedRow] == rowIndex)?[NSColor whiteColor]:[NSColor darkGrayColor]]; - // return ([[filtered objectAtIndex:rowIndex] objectForKey:@"path"]) ? [[filtered objectAtIndex:rowIndex] objectForKey:@"path"] : @""; if([[filtered objectAtIndex:rowIndex] objectForKey:@"path"]) { NSPopUpButtonCell *b = [[NSPopUpButtonCell new] autorelease]; [b setPullsDown:NO]; @@ -542,7 +558,7 @@ else if(t == NSKeyDown) { NSUInteger flags = [event modifierFlags]; - unichar key = [[event characters] length] == 1 ? [[event characters] characterAtIndex:0] : 0; + unichar key = [[event characters] length] == 1 ? [[event characters] characterAtIndex:0] : 0; // Check if user pressed ⌥ to allow composing of accented characters. // e.g. for US keyboard "⌥u a" to insert ä |