diff options
author | Miroslav Zoricak <zoricak@udesign.sk> | 2014-03-05 11:19:38 +0100 |
---|---|---|
committer | Miroslav Zoricak <zoricak@udesign.sk> | 2014-03-05 11:19:38 +0100 |
commit | 2be037fb2f1b60231ad8f8f58720d6becf5ff528 (patch) | |
tree | 0201a4e12356c0cc66d5e811ceff5c9942744d96 /Source/SPCustomQuery.m | |
parent | 1941d8487b4b93519d4451941e8cd9ed3de19404 (diff) | |
download | sequelpro-2be037fb2f1b60231ad8f8f58720d6becf5ff528.tar.gz sequelpro-2be037fb2f1b60231ad8f8f58720d6becf5ff528.tar.bz2 sequelpro-2be037fb2f1b60231ad8f8f58720d6becf5ff528.zip |
Inverse shift+click sorting for custom queries
Add inverse sorting for custom queries
Keep the inverse order while shift+clicking after the first click
Diffstat (limited to 'Source/SPCustomQuery.m')
-rw-r--r-- | Source/SPCustomQuery.m | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m index 4b20af0b..8a2031f1 100644 --- a/Source/SPCustomQuery.m +++ b/Source/SPCustomQuery.m @@ -2141,19 +2141,31 @@ NSMutableString *queryString = [NSMutableString stringWithString:lastExecutedQuery]; + NSUInteger modifierFlags = [[NSApp currentEvent] modifierFlags]; + // Sets column order as tri-state descending, ascending, no sort, descending, ascending etc. order if the same // header is clicked several times if (sortField && [[tableColumn identifier] integerValue] == [sortField integerValue]) { - if(isDesc) { + BOOL invert = NO; + if (modifierFlags & NSShiftKeyMask) { + invert = YES; + } + + // this is the same as saying (isDesc && !invert) || (!isDesc && invert) + if (isDesc != invert) { [sortField release]; sortField = nil; } else { - if (sortField) [sortField release]; - sortField = [[NSNumber alloc] initWithInteger:[[tableColumn identifier] integerValue]]; isDesc = !isDesc; } } else { - isDesc = NO; + // When the column is not sorted, allow to sort in reverse order using Shift+click + if (modifierFlags & NSShiftKeyMask) { + isDesc = YES; + } else { + isDesc = NO; + } + [[customQueryView onMainThread] setIndicatorImage:nil inTableColumn:[customQueryView tableColumnWithIdentifier:[NSString stringWithFormat:@"%lld", (long long)[sortField integerValue]]]]; if (sortField) [sortField release]; sortField = [[NSNumber alloc] initWithInteger:[[tableColumn identifier] integerValue]]; |