aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authormltownsend <mltownsend@gmail.com>2009-12-03 23:43:55 +0000
committermltownsend <mltownsend@gmail.com>2009-12-03 23:43:55 +0000
commitd7a5b54bb9d7356a4e2a26f3bc529104b7faf76e (patch)
treee480dc0637df01157a9d4e00452dae5e1c08f96a /Source
parent73ed762bceaf6244d00486c183f83639915dfe32 (diff)
downloadsequelpro-d7a5b54bb9d7356a4e2a26f3bc529104b7faf76e.tar.gz
sequelpro-d7a5b54bb9d7356a4e2a26f3bc529104b7faf76e.tar.bz2
sequelpro-d7a5b54bb9d7356a4e2a26f3bc529104b7faf76e.zip
Made the tab selection a little more intuitive
Diffstat (limited to 'Source')
-rw-r--r--Source/SPUserManager.m54
1 files changed, 34 insertions, 20 deletions
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m
index 4c75cc70..dc18659d 100644
--- a/Source/SPUserManager.m
+++ b/Source/SPUserManager.m
@@ -70,12 +70,6 @@
@"Replication_slave_priv", @"Repl_slave_priv",
@"Replication_client_priv", @"Repl_client_priv",
nil];
-
- //[[NSNotificationCenter defaultCenter] addObserver:self
-// selector:@selector(contextDidSave:)
-// name:NSManagedObjectContextDidSaveNotification
-// object:nil];
-
}
return self;
@@ -374,7 +368,7 @@
[tabView selectTabViewItemWithIdentifier:@"General"];
}
else {
- if ([[[tabView selectedTabViewItem] identifier] isEqualToString:@"General"]) {
+ if ([selectedObject parent] != nil && [[[tabView selectedTabViewItem] identifier] isEqualToString:@"General"]) {
[tabView selectTabViewItemWithIdentifier:@"Global Privileges"];
}
}
@@ -551,6 +545,26 @@
}
}
+- (void)_selectFirstChildOfParentNode
+{
+ if ([[treeController selectedObjects] count] > 0)
+ {
+ [outlineView expandItem:[outlineView itemAtRow:[outlineView selectedRow]]];
+
+ id selectedObject = [[treeController selectedObjects] objectAtIndex:0];
+ NSTreeNode *firstSelectedNode = [[treeController selectedNodes] objectAtIndex:0];
+ id parent = [selectedObject parent];
+ // If this is already a parent, then parentNode should be null.
+ // If a child is already selected, then we want to not change the selection
+ if (!parent)
+ {
+ NSIndexPath *childIndex = [[[firstSelectedNode childNodes] objectAtIndex:0] indexPath];
+ [treeController setSelectionIndexPath:childIndex];
+ }
+
+ }
+}
+
#pragma mark -
#pragma mark Notifications
@@ -748,25 +762,25 @@
#pragma mark -
#pragma mark Tab View Delegate methods
-- (BOOL)tabView:(NSTabView *)tabView shouldSelectTabViewItem:(NSTabViewItem *)tabViewItem
+-(void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
{
- if ([[treeController selectedObjects] count] == 0) return NO;
+ if ([[treeController selectedObjects] count] == 0) return;
id selectedObject = [[treeController selectedObjects] objectAtIndex:0];
+ // If the selected tab is General and a child is selected, select the
+ // parent (user info)
if ([[tabViewItem identifier] isEqualToString:@"General"]) {
- return ([selectedObject parent] == nil);
- }
- else if ([[tabViewItem identifier] isEqualToString:@"Global Privileges"] || [[tabViewItem identifier] isEqualToString:@"Resources"]) {
- return ([selectedObject parent] != nil);
+ if ([selectedObject parent] != nil)
+ {
+ [self _selectParentFromSelection];
+ }
+ } else if ([[tabViewItem identifier] isEqualToString:@"Global Privileges"]
+ || [[tabViewItem identifier] isEqualToString:@"Resources"]) {
+ // if the tab is either Global Privs or Resources and we have a user
+ // selected, then open tree and select first child node.
+ [self _selectFirstChildOfParentNode];
}
-
- return NO;
-}
-
--(void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
-{
-
}
#pragma mark -