diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-03-18 14:54:47 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-03-18 14:54:47 +0000 |
commit | e2d9581fdcd4773cf23c0482beb3b5c6178b90bf (patch) | |
tree | 77e7c7ceacb2caf8ecb8672aad1e97cfec1a76b5 /Source | |
parent | 76c0ff7dee7b306a2e4e0e6af87ca02f07d0295b (diff) | |
download | sequelpro-e2d9581fdcd4773cf23c0482beb3b5c6178b90bf.tar.gz sequelpro-e2d9581fdcd4773cf23c0482beb3b5c6178b90bf.tar.bz2 sequelpro-e2d9581fdcd4773cf23c0482beb3b5c6178b90bf.zip |
• further progress for navigator
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPNavigatorController.h | 3 | ||||
-rw-r--r-- | Source/SPNavigatorController.m | 60 | ||||
-rw-r--r-- | Source/TableDocument.m | 2 |
3 files changed, 45 insertions, 20 deletions
diff --git a/Source/SPNavigatorController.h b/Source/SPNavigatorController.h index 4687f404..50f84cac 100644 --- a/Source/SPNavigatorController.h +++ b/Source/SPNavigatorController.h @@ -41,7 +41,6 @@ + (SPNavigatorController *)sharedNavigatorController; - (IBAction)outlineViewAction:(id)sender; - -- (void)updateEntries; +- (IBAction)updateEntries:(id)sender; @end diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m index c31c73c0..1dda5af3 100644 --- a/Source/SPNavigatorController.m +++ b/Source/SPNavigatorController.m @@ -87,7 +87,7 @@ static SPNavigatorController *sharedNavigatorController = nil; { prefs = [NSUserDefaults standardUserDefaults]; - [self updateEntries]; + // [self updateEntries:self]; [self setWindowFrameAutosaveName:@"SPNavigator"]; @@ -99,10 +99,10 @@ static SPNavigatorController *sharedNavigatorController = nil; } -- (void)updateEntries +- (IBAction)updateEntries:(id)sender; { - - [schemaData removeAllObjects]; + if(schemaData) [schemaData release]; schemaData = nil; + schemaData = [[NSMutableDictionary alloc] init]; if ([[[NSDocumentController sharedDocumentController] documents] count]) { for(id doc in [[NSDocumentController sharedDocumentController] documents]) { NSString *connectionName; @@ -111,9 +111,15 @@ static SPNavigatorController *sharedNavigatorController = nil; else connectionName = [doc host]; if(![schemaData objectForKey:connectionName]) { - [schemaData setObject:[[doc valueForKeyPath:@"mySQLConnection"] getDbStructure] forKey:connectionName]; + id data = [[doc valueForKeyPath:@"mySQLConnection"] getDbStructure]; + if(data) + [schemaData setObject:data forKey:connectionName]; + else + [schemaData setObject:@"No data available" forKey:connectionName]; } } + [outlineSchema1 reloadData]; + [outlineSchema2 reloadData]; } } @@ -130,12 +136,12 @@ static SPNavigatorController *sharedNavigatorController = nil; { if (item == nil) item = schemaData; - if ([item isKindOfClass:[NSDictionary class]] && [item allKeys] && [[item allKeys] count]) { + if ([item isKindOfClass:[NSDictionary class]] && [item allKeys] && [[item allKeys] count]) { NSSortDescriptor *desc = [[NSSortDescriptor alloc] initWithKey:nil ascending:YES selector:@selector(localizedCompare:)]; - NSArray *sortedTables = [[item allKeys] sortedArrayUsingDescriptors:[NSArray arrayWithObject:desc]]; + NSArray *sortedItems = [[item allKeys] sortedArrayUsingDescriptors:[NSArray arrayWithObject:desc]]; [desc release]; - if(index < [sortedTables count]) - return [item objectForKey:[sortedTables objectAtIndex:index]]; + if(index < [sortedItems count]) + return [item objectForKey:[sortedItems objectAtIndex:index]]; } return nil; @@ -143,8 +149,12 @@ static SPNavigatorController *sharedNavigatorController = nil; - (BOOL)outlineView:(id)outlineView isItemExpandable:(id)item { - if([item isKindOfClass:[NSDictionary class]] && [item count] && [[item objectForKey:@" struct_type "] intValue] < 2) + if([item isKindOfClass:[NSDictionary class]] && [item count]) { + if([item objectForKey:@" struct_type "] && [[item objectForKey:@" struct_type "] intValue] > 1) { + return NO; + } return YES; + } return NO; } @@ -195,14 +205,21 @@ static SPNavigatorController *sharedNavigatorController = nil; [[tableColumn dataCell] setImage:[NSImage imageNamed:@"database-small"]]; } } else { + // It's a field if(![[[parentObject allKeysForObject:item] objectAtIndex:0] hasPrefix:@" "]) [[tableColumn dataCell] setImage:[NSImage imageNamed:@"field-small-square"]]; + else + [[tableColumn dataCell] setImage:[NSImage imageNamed:@"dummy-small"]]; } } else { [[tableColumn dataCell] setImage:[NSImage imageNamed:@"network-small"]]; } - // if(![[[parentObject allKeysForObject:item] objectAtIndex:0] hasPrefix:@" "]) - return [[parentObject allKeysForObject:item] objectAtIndex:0]; + if([[parentObject allKeysForObject:item] count]) + // if(![[[parentObject allKeysForObject:item] objectAtIndex:0] hasPrefix:@" "]) + // return [[parentObject allKeysForObject:item] objectAtIndex:0]; + // return [[parentObject allKeysForObject:item] componentsJoinedByString:@"|"]; + + return [NSString stringWithFormat:@"%@ %ld", [[parentObject allKeysForObject:item] description], [outlineView levelForItem:item]]; return nil; } @@ -227,15 +244,21 @@ static SPNavigatorController *sharedNavigatorController = nil; - (BOOL)outlineView:outlineView isGroupItem:(id)item { - // if([item isKindOfClass:[NSDictionary class]]) - // return YES; - - return YES; + if ([item isKindOfClass:[NSDictionary class]]) + return YES; + + return NO; } - (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item { - return 18.0; + id parentObject = [outlineView parentForItem:item] ? [outlineView parentForItem:item] : schemaData; + + // Use " struct_type " as placeholder to increase distance between table and first field name otherwise it looks ugly + if([[[parentObject allKeysForObject:item] objectAtIndex:0] hasPrefix:@" "]) + return 5.0; + + return 148.0; } - (BOOL)outlineView:(NSOutlineView *)outlineView shouldExpandItem:(id)item @@ -261,6 +284,9 @@ static SPNavigatorController *sharedNavigatorController = nil; - (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item { + id parentObject = [outlineView parentForItem:item] ? [outlineView parentForItem:item] : schemaData; + if([[[parentObject allKeysForObject:item] objectAtIndex:0] hasPrefix:@" "]) + return NO; return YES; } diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 62823c36..d741c55d 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -1163,7 +1163,7 @@ // If the Console window is not visible data are not reloaded (for speed). // Due to that update list if user opens the Console window. if(!isNavigatorVisible) { - [[SPNavigatorController sharedNavigatorController] updateEntries]; + [[SPNavigatorController sharedNavigatorController] updateEntries:self]; } // Show or hide the navigator |