aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPConnectionControllerInitializer.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2012-05-03 12:05:01 +0000
committerstuconnolly <stuart02@gmail.com>2012-05-03 12:05:01 +0000
commit83fa503079f7a049ffab9747b0360046474f3253 (patch)
tree028d0a92e558ba42e796847ab0f68d6e3037fb50 /Source/SPConnectionControllerInitializer.m
parent0d3af5fe7631325e8a892011f0595c76b1ebd49a (diff)
downloadsequelpro-83fa503079f7a049ffab9747b0360046474f3253.tar.gz
sequelpro-83fa503079f7a049ffab9747b0360046474f3253.tar.bz2
sequelpro-83fa503079f7a049ffab9747b0360046474f3253.zip
Add support for saving the state of the connection favorites outline view.
Diffstat (limited to 'Source/SPConnectionControllerInitializer.m')
-rw-r--r--Source/SPConnectionControllerInitializer.m36
1 files changed, 32 insertions, 4 deletions
diff --git a/Source/SPConnectionControllerInitializer.m b/Source/SPConnectionControllerInitializer.m
index a9aa6ca8..7bafe157 100644
--- a/Source/SPConnectionControllerInitializer.m
+++ b/Source/SPConnectionControllerInitializer.m
@@ -26,7 +26,9 @@
#import "SPConnectionControllerInitializer.h"
#import "SPKeychain.h"
#import "SPFavoritesController.h"
+#import "SPTreeNode.h"
#import "SPFavoriteNode.h"
+#import "SPGroupNode.h"
#import "SPDatabaseViewController.h"
static NSString *SPConnectionViewNibName = @"ConnectionView";
@@ -35,6 +37,7 @@ static NSString *SPConnectionViewNibName = @"ConnectionView";
- (void)_reloadFavoritesViewData;
- (void)_selectNode:(SPTreeNode *)node;
+- (void)_restoreOutlineViewStateNode:(SPTreeNode *)node;
- (SPTreeNode *)_favoriteNodeForFavoriteID:(NSInteger)favoriteID;
@@ -102,6 +105,7 @@ static NSString *SPConnectionViewNibName = @"ConnectionView";
[self _reloadFavoritesViewData];
[self setUpFavoritesOutlineView];
[self setUpSelectedConnectionFavorite];
+ [self _restoreOutlineViewStateNode:favoritesRoot];
// Set sort items
currentSortItem = [prefs integerForKey:SPFavoritesSortedBy];
@@ -240,10 +244,7 @@ static NSString *SPConnectionViewNibName = @"ConnectionView";
// Register drag types for the favorites outline view
[favoritesOutlineView registerForDraggedTypes:[NSArray arrayWithObject:SPFavoritesPasteboardDragType]];
- [favoritesOutlineView setDraggingSourceOperationMask:NSDragOperationMove forLocal:YES];
-
- // Preserve expanded group nodes
- [favoritesOutlineView setAutosaveExpandedItems:YES];
+ [favoritesOutlineView setDraggingSourceOperationMask:NSDragOperationMove forLocal:YES];
}
/**
@@ -271,4 +272,31 @@ static NSString *SPConnectionViewNibName = @"ConnectionView";
}
}
+#pragma mark -
+#pragma mark Private API
+
+/**
+ * Restores the outline views group nodes expansion state.
+ *
+ * @param node The node to traverse
+ */
+- (void)_restoreOutlineViewStateNode:(SPTreeNode *)node
+{
+ if ([node isGroup]) {
+ if ([[node representedObject] nodeIsExpanded]) {
+ [favoritesOutlineView expandItem:node];
+ }
+ else {
+ [favoritesOutlineView collapseItem:node];
+ }
+
+ for (SPTreeNode *childNode in [node childNodes])
+ {
+ if ([childNode isGroup]) {
+ [self _restoreOutlineViewStateNode:childNode];
+ }
+ }
+ }
+}
+
@end