aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMax <dmoagx@users.noreply.github.com>2018-06-03 02:07:57 +0200
committerMax <dmoagx@users.noreply.github.com>2018-06-03 02:07:57 +0200
commitbc3b8ab575f4e981afdb3a363a280766fca0dba6 (patch)
treeb8c3b2599b9e2d1ddf206d727eddc7b3e5c7cf9d /Source
parent8c23f9b83a2c48623237f3b4b67a3cefd5348fce (diff)
downloadsequelpro-bc3b8ab575f4e981afdb3a363a280766fca0dba6.tar.gz
sequelpro-bc3b8ab575f4e981afdb3a363a280766fca0dba6.tar.bz2
sequelpro-bc3b8ab575f4e981afdb3a363a280766fca0dba6.zip
Move code in SPNarrowDownCompletion to where it should be (part of #3062)
Still a bit strangeā€¦
Diffstat (limited to 'Source')
-rw-r--r--Source/SPNarrowDownCompletion.m170
1 files changed, 82 insertions, 88 deletions
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m
index e769645a..52131735 100644
--- a/Source/SPNarrowDownCompletion.m
+++ b/Source/SPNarrowDownCompletion.m
@@ -491,69 +491,107 @@ static NSString * const SPAutoCompletePlaceholderVal = @"placholder";
return proposedSelectionIndexes;
}
-- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
+- (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
{
- NSString *identifier = [aTableColumn identifier];
- if([identifier isEqualToString:@"image"]) {
- if(!dictMode) {
- if(isQueryingDatabaseStructure && rowIndex == 0) {
- return [syncArrowImages objectAtIndex:currentSyncImage];
- }
- else {
- NSImage* image = nil;
- NSString *imageName = [[filtered objectAtIndex:rowIndex] objectForKey:@"image"];
- if(imageName) image = [NSImage imageNamed:imageName];
- return image;
+ // tableColumn == nil is called for a potential group row by the table view, which we don't have
+ if(!tableColumn) return nil;
+
+ NSString *identifier = [tableColumn identifier];
+ if ([identifier isEqualToString:@"list"]) {
+ if(
+ !(isQueryingDatabaseStructure && rowIndex == 0) &&
+ !dictMode &&
+ [[filtered objectAtIndex:rowIndex] objectForKey:@"list"]
+ ) {
+ NSPopUpButtonCell *b = [NSPopUpButtonCell new];
+ [b setPullsDown:NO];
+ [b setAltersStateOfSelectedItem:NO];
+ [b setControlSize:NSMiniControlSize];
+ {
+ NSMenu *m = [[NSMenu alloc] init];
+ NSMenuItem *aMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Type Declaration:", @"type declaration header") action:NULL keyEquivalent:@""] autorelease];
+ [aMenuItem setEnabled:NO];
+ [m addItem:aMenuItem];
+ [m addItemWithTitle:[[filtered objectAtIndex:rowIndex] objectForKey:@"list"] action:NULL keyEquivalent:@""];
+ [b setMenu:m];
+ [m release];
}
+ [b setPreferredEdge:NSMinXEdge];
+ [b setArrowPosition:NSPopUpArrowAtCenter];
+ [b setFont:[NSFont systemFontOfSize:11]];
+ [b setBordered:NO];
+ return [b autorelease];
}
-
- return @"";
}
- else if([identifier isEqualToString:@"name"]) {
- if(isQueryingDatabaseStructure && rowIndex == 0) {
- return NSLocalizedString(@"fetching database structure in progress", @"fetching database structure in progress");
+ else if([identifier isEqualToString:@"type"]) {
+ if(!(isQueryingDatabaseStructure && rowIndex == 0) && !dictMode) {
+ NSTokenFieldCell *b = [[NSTokenFieldCell alloc] init];
+ [b setEditable:NO];
+ [b setAlignment:NSRightTextAlignment];
+ [b setFont:[NSFont systemFontOfSize:11]];
+ return [b autorelease];
}
-
- return [[filtered objectAtIndex:rowIndex] objectForKey:@"display"];
}
- else if ([identifier isEqualToString:@"list"]) {
- if(isQueryingDatabaseStructure && rowIndex == 0) {
- NSPopUpButtonCell *b = [[NSPopUpButtonCell new] autorelease];
+ else if ([identifier isEqualToString:@"path"]) {
+ if(
+ !(isQueryingDatabaseStructure && rowIndex == 0) &&
+ !dictMode &&
+ [[filtered objectAtIndex:rowIndex] objectForKey:@"path"]
+ ) {
+ NSPopUpButtonCell *b = [NSPopUpButtonCell new];
[b setPullsDown:NO];
- [b setArrowPosition:NSPopUpNoArrow];
+ [b setAltersStateOfSelectedItem:NO];
[b setControlSize:NSMiniControlSize];
+ {
+ NSMenu *m = [[NSMenu alloc] init];
+ for(id p in [[[[[filtered objectAtIndex:rowIndex] objectForKey:@"path"] componentsSeparatedByString:SPUniqueSchemaDelimiter] reverseObjectEnumerator] allObjects]) {
+ [m addItemWithTitle:p action:NULL keyEquivalent:@""];
+ }
+ if([m numberOfItems] > 2) {
+ [m removeItemAtIndex:[m numberOfItems]-1];
+ [m removeItemAtIndex:0];
+ }
+ [b setMenu:m];
+ [m release];
+ }
+ [b setPreferredEdge:NSMinXEdge];
+ [b setArrowPosition:([b numberOfItems] > 1 ? NSPopUpArrowAtCenter : NSPopUpNoArrow)];
[b setFont:[NSFont systemFontOfSize:11]];
[b setBordered:NO];
- [aTableColumn setDataCell:b];
- return @"";
+ return [b autorelease];
}
+ }
+ // ... otherwise use the default cell for the column (text field cell)
+ return nil;
+}
+
+- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
+{
+ NSString *identifier = [aTableColumn identifier];
+ if([identifier isEqualToString:@"image"]) {
if(dictMode) {
return @"";
}
- if([[filtered objectAtIndex:rowIndex] objectForKey:@"list"]) {
- NSPopUpButtonCell *b = [[NSPopUpButtonCell new] autorelease];
- [b setPullsDown:NO];
- [b setAltersStateOfSelectedItem:NO];
- [b setControlSize:NSMiniControlSize];
- NSMenu *m = [[NSMenu alloc] init];
- NSMenuItem *aMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Type Declaration:", @"type declaration header") action:NULL keyEquivalent:@""] autorelease];
- [aMenuItem setEnabled:NO];
- [m addItem:aMenuItem];
- [m addItemWithTitle:[[filtered objectAtIndex:rowIndex] objectForKey:@"list"] action:NULL keyEquivalent:@""];
- [b setMenu:m];
- [m release];
- [b setPreferredEdge:NSMinXEdge];
- [b setArrowPosition:NSPopUpArrowAtCenter];
- [b setFont:[NSFont systemFontOfSize:11]];
- [b setBordered:NO];
- [aTableColumn setDataCell:b];
+ if(isQueryingDatabaseStructure && rowIndex == 0) {
+ return [syncArrowImages objectAtIndex:currentSyncImage];
}
else {
- [aTableColumn setDataCell:[[NSTextFieldCell new] autorelease]];
+ NSImage* image = nil;
+ NSString *imageName = [[filtered objectAtIndex:rowIndex] objectForKey:@"image"];
+ if(imageName) image = [NSImage imageNamed:imageName];
+ return image;
+ }
+ }
+ else if([identifier isEqualToString:@"name"]) {
+ if(isQueryingDatabaseStructure && rowIndex == 0) {
+ return NSLocalizedString(@"fetching database structure in progress", @"fetching database structure in progress");
}
+ return [[filtered objectAtIndex:rowIndex] objectForKey:@"display"];
+ }
+ else if ([identifier isEqualToString:@"list"]) {
return @"";
}
else if([identifier isEqualToString:@"type"]) {
@@ -565,53 +603,9 @@ static NSString * const SPAutoCompletePlaceholderVal = @"placholder";
return @"";
}
- NSTokenFieldCell *b = [[[NSTokenFieldCell alloc] initTextCell:([[filtered objectAtIndex:rowIndex] objectForKey:@"type"]) ? [[filtered objectAtIndex:rowIndex] objectForKey:@"type"] : @""] autorelease];
- [b setEditable:NO];
- [b setAlignment:NSRightTextAlignment];
- [b setFont:[NSFont systemFontOfSize:11]];
- return b;
+ return ([[filtered objectAtIndex:rowIndex] objectForKey:@"type"] ? [[filtered objectAtIndex:rowIndex] objectForKey:@"type"] : @"");
}
else if ([identifier isEqualToString:@"path"]) {
- if(isQueryingDatabaseStructure && rowIndex == 0) {
- NSPopUpButtonCell *b = [[NSPopUpButtonCell new] autorelease];
- [b setPullsDown:NO];
- [b setArrowPosition:NSPopUpNoArrow];
- [b setControlSize:NSMiniControlSize];
- [b setFont:[NSFont systemFontOfSize:11]];
- [b setBordered:NO];
- [aTableColumn setDataCell:b];
- return @"";
- }
-
- if(dictMode) {
- return @"";
- }
-
- if([[filtered objectAtIndex:rowIndex] objectForKey:@"path"]) {
- NSPopUpButtonCell *b = [[NSPopUpButtonCell new] autorelease];
- [b setPullsDown:NO];
- [b setAltersStateOfSelectedItem:NO];
- [b setControlSize:NSMiniControlSize];
- NSMenu *m = [[NSMenu alloc] init];
- for(id p in [[[[[filtered objectAtIndex:rowIndex] objectForKey:@"path"] componentsSeparatedByString:SPUniqueSchemaDelimiter] reverseObjectEnumerator] allObjects]) {
- [m addItemWithTitle:p action:NULL keyEquivalent:@""];
- }
- if([m numberOfItems]>2) {
- [m removeItemAtIndex:[m numberOfItems]-1];
- [m removeItemAtIndex:0];
- }
- [b setMenu:m];
- [m release];
- [b setPreferredEdge:NSMinXEdge];
- [b setArrowPosition:([m numberOfItems]>1) ? NSPopUpArrowAtCenter : NSPopUpNoArrow];
- [b setFont:[NSFont systemFontOfSize:11]];
- [b setBordered:NO];
- [aTableColumn setDataCell:b];
- }
- else {
- [aTableColumn setDataCell:[[NSTextFieldCell new] autorelease]];
- }
-
return @"";
}