aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPConnectionControllerDelegate.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-11-11 16:53:24 +0000
committerstuconnolly <stuart02@gmail.com>2010-11-11 16:53:24 +0000
commitb1bc59225d7f190b6db36da4634cc96095f01591 (patch)
tree95cfdcc96dfbb48750d9f0afa79569591d04bea0 /Source/SPConnectionControllerDelegate.m
parentb8fc79dd357d8dd1cf3177d1a7faef030497a9e0 (diff)
downloadsequelpro-b1bc59225d7f190b6db36da4634cc96095f01591.tar.gz
sequelpro-b1bc59225d7f190b6db36da4634cc96095f01591.tar.bz2
sequelpro-b1bc59225d7f190b6db36da4634cc96095f01591.zip
Refactor the favorite node class and fix auto-selection of the default or last used favorite.
Diffstat (limited to 'Source/SPConnectionControllerDelegate.m')
-rw-r--r--Source/SPConnectionControllerDelegate.m18
1 files changed, 10 insertions, 8 deletions
diff --git a/Source/SPConnectionControllerDelegate.m b/Source/SPConnectionControllerDelegate.m
index dab7465f..8d3b385d 100644
--- a/Source/SPConnectionControllerDelegate.m
+++ b/Source/SPConnectionControllerDelegate.m
@@ -146,24 +146,26 @@
{
SPFavoriteNode *node = (item == nil ? favoritesRoot : (SPFavoriteNode *)item);
- return [[node children] count];
+ return [[node nodeChildren] count];
}
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
{
SPFavoriteNode *node = (item == nil ? favoritesRoot : (SPFavoriteNode *)item);
- return [[node children] objectAtIndex:index];
+ return NSArrayObjectAtIndex([node nodeChildren], index);
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
- return [(SPFavoriteNode *)item isGroup];
+ return [(SPFavoriteNode *)item nodeIsGroup];
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
- return [[(SPFavoriteNode *)item favorite] objectForKey:@"name"];
+ SPFavoriteNode *node = (SPFavoriteNode *)item;
+
+ return ([node nodeIsGroup]) ? [node nodeName] : [[node nodeFavorite] objectForKey:SPFavoriteNameKey];
}
#pragma mark -
@@ -171,7 +173,7 @@
- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item
{
- return [(SPFavoriteNode *)item isGroup];
+ return [(SPFavoriteNode *)item nodeIsGroup];
}
- (void)outlineViewSelectionDidChange:(NSNotification *)notification
@@ -197,17 +199,17 @@
[(SPTableTextFieldCell *)cell setTextColor:[NSColor grayColor]];
}
- [(SPTableTextFieldCell *)cell setImage:([(SPFavoriteNode *)item isGroup]) ? nil : [NSImage imageNamed:@"database-small"]];
+ [(SPTableTextFieldCell *)cell setImage:([(SPFavoriteNode *)item nodeIsGroup]) ? nil : [NSImage imageNamed:@"database-small"]];
}
- (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item
{
- return ([item isGroup]) ? 22 : 17;
+ return ([item nodeIsGroup]) ? 22 : 17;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item
{
- return (![item isGroup]);
+ return (![item nodeIsGroup]);
}
@end