aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorbamse16 <marius@marius.me.uk>2009-06-30 14:20:14 +0000
committerbamse16 <marius@marius.me.uk>2009-06-30 14:20:14 +0000
commitcdafb3e3ebcb3e6ef1fad77347916fd69a84a1cb (patch)
tree92c815a9850dfd6902a1ce89cdca194aa5638f40 /Source
parentff3fc67fabead60441354209ab3e03d4f5a49c65 (diff)
downloadsequelpro-cdafb3e3ebcb3e6ef1fad77347916fd69a84a1cb.tar.gz
sequelpro-cdafb3e3ebcb3e6ef1fad77347916fd69a84a1cb.tar.bz2
sequelpro-cdafb3e3ebcb3e6ef1fad77347916fd69a84a1cb.zip
Fixed the last use connection when you're reordering your connections
Issue 240: Default connection not being set correctly
Diffstat (limited to 'Source')
-rw-r--r--Source/SPPreferenceController.m14
1 files changed, 9 insertions, 5 deletions
diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m
index 10d58862..a8430659 100644
--- a/Source/SPPreferenceController.m
+++ b/Source/SPPreferenceController.m
@@ -478,7 +478,7 @@
// tableView:validateDrop:proposedRow:proposedDropOperation:
// -------------------------------------------------------------------------------
- (NSDragOperation)tableView:(NSTableView *)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)operation
-{
+{
int originalRow;
NSArray *pboardTypes = [[info draggingPasteboard] types];
@@ -499,28 +499,32 @@
// tableView:acceptDrop:row:dropOperation:
// -------------------------------------------------------------------------------
- (BOOL)tableView:(NSTableView *)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)operation
-{
+{
int originalRow;
int destinationRow;
+ int lastFavoriteIndexCached;
NSMutableDictionary *draggedRow;
originalRow = [[[info draggingPasteboard] stringForType:FAVORITES_PB_DRAG_TYPE] intValue];
destinationRow = row;
-
+
if (destinationRow > originalRow) {
destinationRow--;
}
draggedRow = [NSMutableDictionary dictionaryWithDictionary:[[favoritesController arrangedObjects] objectAtIndex:originalRow]];
+ //Before deleting this favorite, we need to save the current index.
+ //because removeObjectAtArrangedObjectIndex will set prefs LastFavoriteIndex to 0
+ lastFavoriteIndexCached = [prefs integerForKey:@"LastFavoriteIndex"];
[favoritesController removeObjectAtArrangedObjectIndex:originalRow];
[favoritesController insertObject:draggedRow atArrangedObjectIndex:destinationRow];
-
+
[favoritesTableView reloadData];
[favoritesTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:destinationRow] byExtendingSelection:NO];
// Update default favorite to take on new value
- if ([prefs integerForKey:@"LastFavoriteIndex"] == originalRow) {
+ if (lastFavoriteIndexCached == originalRow) {
[prefs setInteger:destinationRow forKey:@"LastFavoriteIndex"];
}