From 0612652448f32e620a96e923a44b463fa1b9e0dc Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 14 Jul 2009 19:34:40 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fix=20for=20completion=20in=20CustomQuery?= =?UTF-8?q?=20editor=20-=20now=20the=20gathering=20of=20suggestions=20does?= =?UTF-8?q?=20not=20query=20the=20MySQL=20connection,=20instead=20it=20use?= =?UTF-8?q?s=20the=20TableList/TableDocument=20tableView=20data=20as=20a?= =?UTF-8?q?=20kind=20of=20cache=20-=20this=20approach=20should=20improve?= =?UTF-8?q?=20the=20speed=20for=20slow=20server=20connections?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TODO: auto-update for TableList and Database List resp. (it could happen that an other user changed the name of a table/db meanwhile) --- Source/TableDocument.m | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'Source/TableDocument.m') diff --git a/Source/TableDocument.m b/Source/TableDocument.m index f4383535..cbcc13b7 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -70,8 +70,9 @@ [printWebView setFrameLoadDelegate:self]; prefs = [NSUserDefaults standardUserDefaults]; + } - + return self; } @@ -349,12 +350,19 @@ [queryResult dataSeek:0]; } - int i; - - for (i = 0 ; i < [queryResult numOfRows] ; i++) - { - [chooseDatabaseButton addItemWithTitle:NSArrayObjectAtIndex([queryResult fetchRowAsArray], 0)]; - } + // if([allDatabases count]) + // [allDatabases removeAllObjects]; + + if(allDatabases) + [allDatabases release]; + + allDatabases = [[NSMutableArray alloc] initWithCapacity:[queryResult numOfRows]]; + + for (int i = 0 ; i < [queryResult numOfRows] ; i++) + [allDatabases addObject:NSArrayObjectAtIndex([queryResult fetchRowAsArray], 0)]; + + for (id db in allDatabases) + [chooseDatabaseButton addItemWithTitle:db]; (![self database]) ? [chooseDatabaseButton selectItemAtIndex:0] : [chooseDatabaseButton selectItemWithTitle:[self database]]; } @@ -494,6 +502,14 @@ [alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"removedatabase"]; } +/* + * Returns an array of all available database names + */ +- (NSArray *)allDatabaseNames +{ + return allDatabases; +} + /** * alert sheets method * invoked when alertSheet get closed @@ -2127,7 +2143,7 @@ [selectedDatabase release]; [mySQLVersion release]; [connectionController release]; - + [allDatabases release]; [super dealloc]; } -- cgit v1.2.3