aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPPreferenceController.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-07-05 21:54:28 +0000
committerstuconnolly <stuart02@gmail.com>2010-07-05 21:54:28 +0000
commit9de3398e48f50646f616893df3eba30211d94eec (patch)
treeedfe3297166f27e5424ff1a9b298eee45ab98ce0 /Source/SPPreferenceController.m
parentee39747795b41551509a11fa770d8a937feb5f39 (diff)
downloadsequelpro-9de3398e48f50646f616893df3eba30211d94eec.tar.gz
sequelpro-9de3398e48f50646f616893df3eba30211d94eec.tar.bz2
sequelpro-9de3398e48f50646f616893df3eba30211d94eec.zip
Enable manual sorting of connection favourites in the preferences, which will disable automatic sorting. Also, connection favourites sort order in the preferences and the connection view should now be in sync. Needs thoroughly tested. Fixes issue #655.
Diffstat (limited to 'Source/SPPreferenceController.m')
-rw-r--r--Source/SPPreferenceController.m36
1 files changed, 26 insertions, 10 deletions
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m
index 66dc2597..ab8ec067 100644
--- a/Source/SPPreferenceController.m
+++ b/Source/SPPreferenceController.m
@@ -98,7 +98,9 @@
[prefs synchronize];
- [self _sortFavorites];
+ if (currentSortItem > -1) {
+ [self _sortFavorites];
+ }
}
#pragma mark -
@@ -456,7 +458,7 @@
* Sorts the favorites table view based on the selected sort by item
*/
- (IBAction)sortFavorites:(id)sender
-{
+{
previousSortItem = currentSortItem;
currentSortItem = [[sender menu] indexOfItem:sender];
@@ -465,8 +467,9 @@
// Perform sorting
[self _sortFavorites];
- [[[sender menu] itemAtIndex:previousSortItem] setState:NSOffState];
- [[[sender menu] itemAtIndex:currentSortItem] setState:NSOnState];
+ if (previousSortItem > -1) [[[sender menu] itemAtIndex:previousSortItem] setState:NSOffState];
+
+ [[[sender menu] itemAtIndex:currentSortItem] setState:NSOnState];
}
/**
@@ -621,12 +624,12 @@
}
#pragma mark -
-#pragma mark TableView drag & drop datasource methods
+#pragma mark TableView drag & drop delegate methods
// -------------------------------------------------------------------------------
// tableView:writeRowsWithIndexes:toPasteboard:
// -------------------------------------------------------------------------------
-/*- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rows toPasteboard:(NSPasteboard*)pboard
+- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rows toPasteboard:(NSPasteboard*)pboard
{
if ([rows count] == 1) {
[pboard declareTypes:[NSArray arrayWithObject:SPFavoritesPasteboardDragType] owner:nil];
@@ -670,6 +673,22 @@
NSInteger lastFavoriteIndexCached;
NSMutableDictionary *draggedRow;
+ // Disable all automatic sorting
+ currentSortItem = -1;
+ reverseFavoritesSort = NO;
+
+ [prefs setInteger:currentSortItem forKey:SPFavoritesSortedBy];
+ [prefs setBool:NO forKey:SPFavoritesSortedInReverse];
+
+ // Remove sort descriptors
+ [favoritesController setSortDescriptors:[NSArray array]];
+
+ // Uncheck sort by menu items
+ for (NSMenuItem *menuItem in [[favoritesSortByMenuItem submenu] itemArray])
+ {
+ [menuItem setState:NSOffState];
+ }
+
originalRow = [[[info draggingPasteboard] stringForType:SPFavoritesPasteboardDragType] integerValue];
destinationRow = row;
@@ -701,7 +720,7 @@
[self updateDefaultFavoritePopup];
return YES;
-}*/
+}
#pragma mark -
#pragma mark TableView delegate methods
@@ -1384,9 +1403,6 @@
case SPFavoritesSortTypeItem:
sortKey = @"type";
break;
- default:
- sortKey = @"name";
- break;
}
NSSortDescriptor *sortDescriptor = nil;