aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-06-21 01:37:48 +0200
committerMax <post@wickenrode.com>2015-06-21 01:37:48 +0200
commit1d32954fbe70f6d98784eced88f29c47903f27c7 (patch)
tree2b69710cb0869ad2239554acaf9080054bc95ee7 /Source
parent0c39d230884d5d65dcfa758e13780ebe6c1c057b (diff)
downloadsequelpro-1d32954fbe70f6d98784eced88f29c47903f27c7.tar.gz
sequelpro-1d32954fbe70f6d98784eced88f29c47903f27c7.tar.bz2
sequelpro-1d32954fbe70f6d98784eced88f29c47903f27c7.zip
Add option to sort favorites by color
Diffstat (limited to 'Source')
-rw-r--r--Source/SPConnectionController.m3
-rw-r--r--Source/SPConstants.h9
-rw-r--r--Source/SPPreferencesUpgrade.m16
3 files changed, 24 insertions, 4 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index aca3e982..5af38274 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -1432,6 +1432,9 @@ static NSComparisonResult _compareFavoritesUsingKey(id favorite1, id favorite2,
case SPFavoritesSortTypeItem:
sortKey = SPFavoriteTypeKey;
break;
+ case SPFavoritesSortColorItem:
+ sortKey = SPFavoriteColorIndexKey;
+ break;
case SPFavoritesSortUnsorted:
return;
}
diff --git a/Source/SPConstants.h b/Source/SPConstants.h
index 6a8afeea..5e34ef56 100644
--- a/Source/SPConstants.h
+++ b/Source/SPConstants.h
@@ -129,10 +129,11 @@ typedef enum
// Sort by constants
typedef enum
{
- SPFavoritesSortUnsorted = -1,
- SPFavoritesSortNameItem = 0,
- SPFavoritesSortHostItem = 1,
- SPFavoritesSortTypeItem = 2
+ SPFavoritesSortUnsorted = -1,
+ SPFavoritesSortNameItem = 0,
+ SPFavoritesSortHostItem = 1,
+ SPFavoritesSortTypeItem = 2,
+ SPFavoritesSortColorItem = 3
} SPFavoritesSortItem;
// Text and link cell draw states
diff --git a/Source/SPPreferencesUpgrade.m b/Source/SPPreferencesUpgrade.m
index d88dc4c8..6d0a3393 100644
--- a/Source/SPPreferencesUpgrade.m
+++ b/Source/SPPreferencesUpgrade.m
@@ -30,6 +30,8 @@
#import "SPPreferencesUpgrade.h"
#import "SPKeychain.h"
+#import "SPFavoritesController.h"
+#import "SPTreeNode.h"
static NSString *SPOldFavoritesKey = @"favorites";
static NSString *SPOldDefaultEncodingKey = @"DefaultEncoding";
@@ -344,6 +346,20 @@ void SPApplyRevisionChanges(void)
if (recordedVersionNumber < 4049) {
[prefs removeObjectForKey:SPOldFavoritesKey];
}
+
+ // For versions prior to r4485, add a default colorIndex to fix sorting favorites by color
+ if (recordedVersionNumber < 4485) {
+ SPFavoritesController *ctrl = [SPFavoritesController sharedFavoritesController];
+ NSMutableArray *favs = [(SPTreeNode *)[[[ctrl favoritesTree] childNodes] objectAtIndex:0] descendants];
+ for(SPTreeNode *node in favs) {
+ if([node isGroup])
+ continue;
+ NSMutableDictionary *data = [[node representedObject] nodeFavorite];
+ if(![data objectForKey:SPFavoriteColorIndexKey])
+ [data setObject:@(-1) forKey:SPFavoriteColorIndexKey];
+ }
+ [ctrl saveFavorites];
+ }
// Display any important release notes, if any. Call this after a slight delay to prevent double help
// menus - see http://www.cocoabuilder.com/archive/cocoa/6200-two-help-menus-why.html .