From 11e10321f97577204b74f84b528029490e64ef47 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sat, 18 Jul 2009 16:02:04 +0000 Subject: Add the ability to navigate between tables via foreign key relationships, addressing the first part of #209: - For the first column linked by each foreign key, display a link arrow within the table cell - When clicking on the link arrow, select the reference table and set the table filters to select the clicked value - Also uses the table cell subclass to allow the entire cell to be editable, not just the contained text (addresses #250) --- Source/TablesList.m | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Source/TablesList.m') diff --git a/Source/TablesList.m b/Source/TablesList.m index 49b97008..bba94272 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -1051,6 +1051,30 @@ statusLoaded = !reload; } +/** + * Select a table or view using the provided name; returns YES if the + * supplied name could be selected, or NO if not. + */ +- (BOOL)selectTableOrViewWithName:(NSString *)theName +{ + int i, tableType, itemIndex = NSNotFound; + + // Loop through the tables/views to find the desired item + for (i = 0; i < [tables count]; i++) { + tableType = [[tableTypes objectAtIndex:i] intValue]; + if (tableType != SP_TABLETYPE_TABLE && tableType != SP_TABLETYPE_VIEW) continue; + if ([[tables objectAtIndex:i] isEqualToString:theName]) { + itemIndex = i; + break; + } + } + + if (itemIndex == NSNotFound) return NO; + + [tablesListView selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex] byExtendingSelection:NO]; + return YES; +} + #pragma mark Datasource methods /** -- cgit v1.2.3