aboutsummaryrefslogtreecommitdiffstats
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
parent0c39d230884d5d65dcfa758e13780ebe6c1c057b (diff)
downloadsequelpro-1d32954fbe70f6d98784eced88f29c47903f27c7.tar.gz
sequelpro-1d32954fbe70f6d98784eced88f29c47903f27c7.tar.bz2
sequelpro-1d32954fbe70f6d98784eced88f29c47903f27c7.zip
Add option to sort favorites by color
-rw-r--r--Interfaces/English.lproj/ConnectionView.xib30
-rw-r--r--Source/SPConnectionController.m3
-rw-r--r--Source/SPConstants.h9
-rw-r--r--Source/SPPreferencesUpgrade.m16
4 files changed, 51 insertions, 7 deletions
diff --git a/Interfaces/English.lproj/ConnectionView.xib b/Interfaces/English.lproj/ConnectionView.xib
index b95910df..a6bfe95c 100644
--- a/Interfaces/English.lproj/ConnectionView.xib
+++ b/Interfaces/English.lproj/ConnectionView.xib
@@ -340,6 +340,16 @@
<string key="NSAction">_popUpItemAction:</string>
<reference key="NSTarget" ref="970960222"/>
</object>
+ <object class="NSMenuItem" id="660097916">
+ <reference key="NSMenu" ref="642202204"/>
+ <string key="NSTitle">Color</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="955092474"/>
+ <reference key="NSMixedImage" ref="913188683"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="970960222"/>
+ </object>
<object class="NSMenuItem" id="975459050">
<reference key="NSMenu" ref="642202204"/>
<bool key="NSIsDisabled">YES</bool>
@@ -368,7 +378,7 @@
</array>
<reference key="NSMenuFont" ref="807120225"/>
</object>
- <int key="NSSelectedIndex">-1</int>
+ <int key="NSSelectedIndex">10</int>
<bool key="NSPullDown">YES</bool>
<int key="NSPreferredEdge">1</int>
<bool key="NSUsesItemFromMenu">YES</bool>
@@ -1524,7 +1534,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{328, 12}, {29, 24}}</string>
<reference key="NSSuperview" ref="866600720"/>
- <reference key="NSNextKeyView" ref="990947983"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="308087760">
<int key="NSCellFlags">67108864</int>
@@ -2282,7 +2291,7 @@
<string key="NSFrame">{{328, 12}, {29, 24}}</string>
<reference key="NSSuperview" ref="709218819"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="990947983"/>
+ <reference key="NSNextKeyView" ref="134031646"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="345867488">
<int key="NSCellFlags">67108864</int>
@@ -3992,6 +4001,14 @@
<string key="id">nQE-St-ai8</string>
</object>
<object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">sortFavorites:</string>
+ <reference key="source" ref="545410097"/>
+ <reference key="destination" ref="660097916"/>
+ </object>
+ <string key="id">Q9D-q1-jts</string>
+ </object>
+ <object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="1012579052"/>
@@ -6068,6 +6085,7 @@
<reference ref="914367302"/>
<reference ref="703530048"/>
<reference ref="233015422"/>
+ <reference ref="660097916"/>
</array>
<reference key="parent" ref="788191870"/>
</object>
@@ -7477,12 +7495,18 @@
<reference key="object" ref="994249095"/>
<reference key="parent" ref="1003668465"/>
</object>
+ <object class="IBObjectRecord">
+ <string key="id">25V-E5-s4p</string>
+ <reference key="object" ref="660097916"/>
+ <reference key="parent" ref="642202204"/>
+ </object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="25V-E5-s4p.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="30l-FF-qhV.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="3Y2-Rj-0be.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="4829.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
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 .