diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-09-07 13:38:36 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-09-07 13:38:36 +0000 |
commit | 2441b2c439a3da072ea634aaaf1345d2c24b6158 (patch) | |
tree | 6aa7e77f3ce532173508b07b39ed621f27cba21c | |
parent | 4693139403ba538559a939e776ee3d65d5c74598 (diff) | |
download | sequelpro-2441b2c439a3da072ea634aaaf1345d2c24b6158.tar.gz sequelpro-2441b2c439a3da072ea634aaaf1345d2c24b6158.tar.bz2 sequelpro-2441b2c439a3da072ea634aaaf1345d2c24b6158.zip |
• Query Favorite Manager
- disabled sorting by clicking at table headers
- added drag&drop support of multiple selected items
-rw-r--r-- | Interfaces/English.lproj/QueryFavoriteManager.xib | 75 | ||||
-rw-r--r-- | Source/SPQueryFavoriteManager.m | 73 |
2 files changed, 96 insertions, 52 deletions
diff --git a/Interfaces/English.lproj/QueryFavoriteManager.xib b/Interfaces/English.lproj/QueryFavoriteManager.xib index 0a761cf3..20029676 100644 --- a/Interfaces/English.lproj/QueryFavoriteManager.xib +++ b/Interfaces/English.lproj/QueryFavoriteManager.xib @@ -8,6 +8,7 @@ <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> + <integer value="23"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -45,7 +46,7 @@ <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSWindowContentMinSize">{500, 371}</string> <object class="NSView" key="NSWindowView" id="1006"> - <nil key="NSNextResponder"/> + <reference key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -830,6 +831,7 @@ </object> </object> <string key="NSFrameSize">{500, 371}</string> + <reference key="NSSuperview"/> </object> <string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string> <string key="NSMinSize">{500, 393}</string> @@ -1142,22 +1144,6 @@ </object> <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> - <string key="label">value: arrangedObjects.name</string> - <reference key="source" ref="901293108"/> - <reference key="destination" ref="863945469"/> - <object class="NSNibBindingConnector" key="connector"> - <reference key="NSSource" ref="901293108"/> - <reference key="NSDestination" ref="863945469"/> - <string key="NSLabel">value: arrangedObjects.name</string> - <string key="NSBinding">value</string> - <string key="NSKeyPath">arrangedObjects.name</string> - <int key="NSNibBindingConnectorVersion">2</int> - </object> - </object> - <int key="connectionID">285</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBBindingConnection" key="connection"> <string key="label">value: selection.name</string> <reference key="source" ref="247897226"/> <reference key="destination" ref="863945469"/> @@ -1189,6 +1175,34 @@ <int key="connectionID">291</int> </object> <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">favoritesArrayController</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="863945469"/> + </object> + <int key="connectionID">297</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">value: arrangedObjects.name</string> + <reference key="source" ref="901293108"/> + <reference key="destination" ref="863945469"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="901293108"/> + <reference key="NSDestination" ref="863945469"/> + <string key="NSLabel">value: arrangedObjects.name</string> + <string key="NSBinding">value</string> + <string key="NSKeyPath">arrangedObjects.name</string> + <object class="NSDictionary" key="NSOptions"> + <string key="NS.key.0">NSCreatesSortDescriptor</string> + <boolean value="NO" key="NS.object.0" id="6"/> + </object> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">298</int> + </object> + <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> <string key="label">value: arrangedObjects.tabtrigger</string> <reference key="source" ref="183746003"/> @@ -1200,21 +1214,22 @@ <string key="NSBinding">value</string> <string key="NSKeyPath">arrangedObjects.tabtrigger</string> <object class="NSDictionary" key="NSOptions"> - <string key="NS.key.0">NSConditionallySetsEditable</string> - <boolean value="YES" key="NS.object.0" id="5"/> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMutableArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSConditionallySetsEditable</string> + <string>NSCreatesSortDescriptor</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <boolean value="YES" id="5"/> + <reference ref="6"/> + </object> </object> <int key="NSNibBindingConnectorVersion">2</int> </object> </object> - <int key="connectionID">295</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">favoritesArrayController</string> - <reference key="source" ref="1001"/> - <reference key="destination" ref="863945469"/> - </object> - <int key="connectionID">297</int> + <int key="connectionID">299</int> </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> @@ -1714,7 +1729,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>{{209, 69}, {500, 371}}</string> <string>{{209, 69}, {500, 371}}</string> - <boolean value="NO"/> + <reference ref="6"/> <string>{196, 240}</string> <string>{{357, 418}, {480, 270}}</string> <reference ref="5"/> @@ -1867,7 +1882,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">297</int> + <int key="maxID">299</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m index 545d0317..41276769 100644 --- a/Source/SPQueryFavoriteManager.m +++ b/Source/SPQueryFavoriteManager.m @@ -482,6 +482,15 @@ } /* + * Sorting by clicking at a column header inside groups + */ +- (void)tableView:(NSTableView*)tableView didClickTableColumn:(NSTableColumn *)tableColumn +{ + // TODO: Not yet implemented + return; +} + +/* * favoriteProperties holds the data if a table row is a group header or not */ - (BOOL)tableView:(NSTableView *)aTableView isGroupRow:(NSInteger)rowIndex @@ -556,7 +565,7 @@ { // Up to now only one row can be dragged - if ([rows count] == 1) { + // if ([rows count] == 1) { NSArray *pboardTypes = [NSArray arrayWithObject:QUERY_FAVORITES_PB_DRAG_TYPE]; NSInteger originalRow = [[rows objectAtIndex:0] intValue]; @@ -567,13 +576,18 @@ if([[favorites objectAtIndex:originalRow] objectForKey:@"headerOfFileURL"]) return NO; [pboard declareTypes:pboardTypes owner:nil]; - [pboard setString:[[NSNumber numberWithInt:originalRow] stringValue] forType:QUERY_FAVORITES_PB_DRAG_TYPE]; + + NSMutableData *indexdata = [[[NSMutableData alloc] init] autorelease]; + NSKeyedArchiver *archiver = [[[NSKeyedArchiver alloc] initForWritingWithMutableData:indexdata] autorelease]; + [archiver encodeObject:rows forKey:@"indexdata"]; + [archiver finishEncoding]; + [pboard setData:indexdata forType:QUERY_FAVORITES_PB_DRAG_TYPE]; return YES; - } + // } - return NO; + // return NO; } /** @@ -585,9 +599,7 @@ if (([pboardTypes count] > 1) && (row != -1)) { if (([pboardTypes containsObject:QUERY_FAVORITES_PB_DRAG_TYPE]) && (operation == NSTableViewDropAbove)) { - NSInteger originalRow = [[[info draggingPasteboard] stringForType:QUERY_FAVORITES_PB_DRAG_TYPE] intValue]; - - if ((row != originalRow) && (row != (originalRow + 1)) && (row > 0)) { + if (row > 0) { return NSDragOperationMove; } } @@ -601,29 +613,46 @@ */ - (BOOL)tableView:(NSTableView *)tableView acceptDrop:(id <NSDraggingInfo>)info row:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation -{ - NSInteger originalRow = [[[info draggingPasteboard] stringForType:QUERY_FAVORITES_PB_DRAG_TYPE] intValue]; +{ + + if(row < 1) return NO; + + NSKeyedUnarchiver *unarchiver = [[[NSKeyedUnarchiver alloc] initForReadingWithData:[[info draggingPasteboard] dataForType:QUERY_FAVORITES_PB_DRAG_TYPE]] autorelease]; + NSArray *draggedRows = [NSArray arrayWithArray:(NSArray *)[unarchiver decodeObjectForKey:@"indexdata"]]; + [unarchiver finishDecoding]; + NSInteger destinationRow = row; + NSInteger offset = 0; - if(destinationRow == originalRow || row < 1) return NO; - if(destinationRow > originalRow) destinationRow--; + NSUInteger i; - NSMutableDictionary *draggedRow = [NSMutableDictionary dictionaryWithDictionary:[favorites objectAtIndex:originalRow]]; + for(i=0; i<[draggedRows count]; i++) { - [favorites removeObjectAtIndex:originalRow]; - [favorites insertObject:draggedRow atIndex:destinationRow]; + NSInteger originalRow = [[draggedRows objectAtIndex:i] intValue]; - [favoritesTableView reloadData]; - [favoritesArrayController rearrangeObjects]; + if(originalRow < destinationRow) destinationRow--; + + originalRow += offset; + + // For safety reasons + if(originalRow > [favorites count]-1) originalRow = [favorites count] - 1; + + NSMutableDictionary *draggedRow = [NSMutableDictionary dictionaryWithDictionary:[favorites objectAtIndex:originalRow]]; + [favorites removeObjectAtIndex:originalRow]; + [favoritesTableView reloadData]; + + if(destinationRow+i >= [favorites count]) + [favorites addObject:draggedRow]; + else + [favorites insertObject:draggedRow atIndex:destinationRow+i]; + + if(originalRow < row) offset--; - if([[favorites objectAtIndex:destinationRow] objectForKey:@"headerOfFileURL"]) - [self _initWithNoSelection]; - else if([favoritesTableView numberOfSelectedRows] == 1 - && [favoritesTableView selectedRow] == originalRow) { - [favoritesTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:destinationRow] byExtendingSelection:NO]; - [favoritesArrayController setSelectionIndexes:[NSIndexSet indexSetWithIndex:destinationRow]]; } + [favoritesTableView reloadData]; + [favoritesArrayController rearrangeObjects]; + return YES; } |