aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-10-10 00:17:51 +0000
committerrowanbeentje <rowan@beent.je>2012-10-10 00:17:51 +0000
commitca71a7d3fe9818ea9f2b2e7f1eca643eb6e07ff1 (patch)
tree6d28e53bd4ce96034d69ab8a4a870cbc5f9ca6da /Source
parent7d7fdfc8b675ac827fb29577ef491ff075589b59 (diff)
downloadsequelpro-ca71a7d3fe9818ea9f2b2e7f1eca643eb6e07ff1.tar.gz
sequelpro-ca71a7d3fe9818ea9f2b2e7f1eca643eb6e07ff1.tar.bz2
sequelpro-ca71a7d3fe9818ea9f2b2e7f1eca643eb6e07ff1.zip
- Connection interface: correctly update the sort order when adding new items or renaming items. This addresses Issue #1209
Diffstat (limited to 'Source')
-rw-r--r--Source/SPConnectionController.m23
1 files changed, 18 insertions, 5 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index 15e68f41..d610dba8 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -727,7 +727,7 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
SPTreeNode *node = [favoritesController addFavoriteNodeWithData:favorite asChildOfNode:parent];
- [self _reloadFavoritesViewData];
+ [self _sortFavorites];
[self _selectNode:node];
[[[[NSApp delegate] preferenceController] generalPreferencePane] updateDefaultFavoritePopup];
@@ -1286,7 +1286,9 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
// Add the new node and select it
SPTreeNode *newNode = [favoritesController addFavoriteNodeWithData:theFavorite asChildOfNode:parentNode];
- [self _reloadFavoritesViewData];
+
+ [self _sortFavorites];
+
[self _selectNode:newNode];
// Update the favorites popup button in the preferences
@@ -1304,7 +1306,8 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
if (currentFavorite) [currentFavorite release], currentFavorite = nil;
currentFavorite = [theFavorite copy];
- [self _reloadFavoritesViewData];
+ [self _sortFavorites];
+ [self _scrollToSelectedNode];
}
[[NSNotificationCenter defaultCenter] postNotificationName:SPConnectionFavoritesChangedNotification object:self];
@@ -1352,15 +1355,25 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
sortKey = SPFavoriteTypeKey;
break;
case SPFavoritesSortUnsorted:
- break;
+ return;
}
-
+
+ // Store a copy of the selected nodes for re-selection
+ NSArray *preSortSelection = [self selectedFavoriteNodes];
+
[self _sortTreeNode:[[favoritesRoot childNodes] objectAtIndex:0] usingKey:sortKey];
[favoritesController saveFavorites];
[self _reloadFavoritesViewData];
+ // Update the selection to account for sorted favourites
+ NSMutableIndexSet *restoredSelection = [NSMutableIndexSet indexSet];
+ for (SPTreeNode *eachNode in preSortSelection) {
+ [restoredSelection addIndex:[favoritesOutlineView rowForItem:eachNode]];
+ }
+ [favoritesOutlineView selectRowIndexes:restoredSelection byExtendingSelection:NO];
+
[[NSNotificationCenter defaultCenter] postNotificationName:SPConnectionFavoritesChangedNotification object:self];
}
#endif