From 1941d8487b4b93519d4451941e8cd9ed3de19404 Mon Sep 17 00:00:00 2001 From: Miroslav Zoricak Date: Tue, 4 Mar 2014 21:25:14 +0100 Subject: Shift-click to reverse sort order of table columns --- Source/SPTableContent.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Source') diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 433ac25c..11c3d1df 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -1663,7 +1663,13 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper } } else { - isDesc = NO; + // When the column is not sorted, allow to sort in reverse order using Shift+click + NSUInteger modifierFlags = [[NSApp currentEvent] modifierFlags]; + if (modifierFlags & NSShiftKeyMask) { + isDesc = YES; + } else { + isDesc = NO; + } [[tableContentView onMainThread] setIndicatorImage:nil inTableColumn:[tableContentView tableColumnWithIdentifier:[NSString stringWithFormat:@"%lld", (long long)[sortCol integerValue]]]]; -- cgit v1.2.3 From 2be037fb2f1b60231ad8f8f58720d6becf5ff528 Mon Sep 17 00:00:00 2001 From: Miroslav Zoricak Date: Wed, 5 Mar 2014 11:19:38 +0100 Subject: Inverse shift+click sorting for custom queries Add inverse sorting for custom queries Keep the inverse order while shift+clicking after the first click --- Source/SPCustomQuery.m | 20 ++++++++++++++++---- Source/SPTableContent.m | 14 +++++++++----- 2 files changed, 25 insertions(+), 9 deletions(-) (limited to 'Source') 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]]; diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 11c3d1df..8e537178 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -1648,23 +1648,27 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper return; } + 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 (sortCol && [[tableColumn identifier] integerValue] == [sortCol integerValue]) { - if (isDesc) { + BOOL invert = NO; + if (modifierFlags & NSShiftKeyMask) { + invert = YES; + } + + // this is the same as saying (isDesc && !invert) || (!isDesc && invert) + if (isDesc != invert) { [sortCol release]; sortCol = nil; } else { - if (sortCol) [sortCol release]; - - sortCol = [[NSNumber alloc] initWithInteger:[[tableColumn identifier] integerValue]]; isDesc = !isDesc; } } else { // When the column is not sorted, allow to sort in reverse order using Shift+click - NSUInteger modifierFlags = [[NSApp currentEvent] modifierFlags]; if (modifierFlags & NSShiftKeyMask) { isDesc = YES; } else { -- cgit v1.2.3