aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPConnectionController.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-07-03 22:10:38 +0000
committerstuconnolly <stuart02@gmail.com>2010-07-03 22:10:38 +0000
commit89719b64e4f6fa793c4ed7d4d1a63f8b4938812c (patch)
treeaf76d4247f35cdd77d3defdfadc144bfb79beb27 /Source/SPConnectionController.m
parente173979e6dd7b343a7a6d4a5b694b938de0956c6 (diff)
downloadsequelpro-89719b64e4f6fa793c4ed7d4d1a63f8b4938812c.tar.gz
sequelpro-89719b64e4f6fa793c4ed7d4d1a63f8b4938812c.tar.bz2
sequelpro-89719b64e4f6fa793c4ed7d4d1a63f8b4938812c.zip
Various improvements to default connection favorites handling, including:
- Updating the default favorite popup button to reflect the sorted order of the favorites tableview. - A new icon indicating the default favorite in the favorites tableview. - A new 'Make Default' menu item in the favorites tableview context menu. (Outstanding issue: Incorrect default favorite being selected upon launch because the sorting of favorites on the connection screen and preferences are independent of each other).
Diffstat (limited to 'Source/SPConnectionController.m')
-rw-r--r--Source/SPConnectionController.m85
1 files changed, 49 insertions, 36 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index ad2bdf62..ee3bb724 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -58,6 +58,8 @@
@synthesize connectionSSHKeychainItemName;
@synthesize connectionSSHKeychainItemAccount;
+#pragma mark -
+
/**
* Initialise the connection controller, linking it to the
* parent document and setting up the parent window.
@@ -682,6 +684,9 @@
}
+/**
+ *
+ */
- (void)reverseSortFavorites:(id)sender
{
reverseFavoritesSort = (![sender state]);
@@ -694,42 +699,6 @@
[sender setState:reverseFavoritesSort];
}
-- (void)_sortFavorites
-{
- NSString *sortKey = @"";
-
- switch (currentSortItem)
- {
- case SPFavoritesSortNameItem:
- sortKey = @"name";
- break;
- case SPFavoritesSortHostItem:
- sortKey = @"host";
- break;
- case SPFavoritesSortTypeItem:
- sortKey = @"type";
- break;
- default:
- sortKey = @"name";
- break;
- }
-
- NSSortDescriptor *sortDescriptor = nil;
-
- if (currentSortItem == SPFavoritesSortTypeItem) {
- sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:sortKey ascending:(!reverseFavoritesSort)] autorelease];
- }
- else {
- sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:sortKey ascending:(!reverseFavoritesSort) selector:@selector(caseInsensitiveCompare:)] autorelease];
- }
- NSDictionary *first = [[favorites objectAtIndex:0] retain];
- [favorites removeObjectAtIndex:0];
- [favorites sortUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
- [favorites insertObject:first atIndex:0];
- [favoritesTable reloadData];
- [first release];
-
-}
/**
* Updates the local favorites array from the user defaults
*/
@@ -1084,6 +1053,7 @@
#pragma mark -
#pragma mark Menu Validation
+
-(BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
SEL action = [menuItem action];
@@ -1103,6 +1073,49 @@
return YES;
}
+
+#pragma mark -
+#pragma mark Private API
+
+- (void)_sortFavorites
+{
+ NSString *sortKey = @"";
+
+ switch (currentSortItem)
+ {
+ case SPFavoritesSortNameItem:
+ sortKey = @"name";
+ break;
+ case SPFavoritesSortHostItem:
+ sortKey = @"host";
+ break;
+ case SPFavoritesSortTypeItem:
+ sortKey = @"type";
+ break;
+ default:
+ sortKey = @"name";
+ break;
+ }
+
+ NSSortDescriptor *sortDescriptor = nil;
+
+ if (currentSortItem == SPFavoritesSortTypeItem) {
+ sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:sortKey ascending:(!reverseFavoritesSort)] autorelease];
+ }
+ else {
+ sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:sortKey ascending:(!reverseFavoritesSort) selector:@selector(caseInsensitiveCompare:)] autorelease];
+ }
+
+ NSDictionary *first = [[favorites objectAtIndex:0] retain];
+
+ [favorites removeObjectAtIndex:0];
+ [favorites sortUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
+ [favorites insertObject:first atIndex:0];
+ [favoritesTable reloadData];
+
+ [first release];
+}
+
@end
#pragma mark -