From 8e737837b17f564e9c04f336858d1bea4d1a13a5 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 24 Aug 2010 09:13:57 +0000 Subject: =?UTF-8?q?=E2=80=A2=20introduced=20tri-state=20sort=20order=20for?= =?UTF-8?q?=20Content=20and=20Custom=20Query=20tables=20-=20by=20clicking?= =?UTF-8?q?=20a=20the=20same=20table=20header=20the=20sort=20will=20change?= =?UTF-8?q?d=20to=20desc,=20asc,=20no=20sort=20order,=20desc,=20asc,=20etc?= =?UTF-8?q?.=20=E2=80=A2=20fixed=20sorting=20issue=20for=20Custom=20Query?= =?UTF-8?q?=20table=20-=20reset=20sort=20order=20status=20before=20executi?= =?UTF-8?q?ng=20a=20new=20custom=20query=20=E2=80=A2=C2=A0code=20cosmetics?= =?UTF-8?q?:=20reduced=20file=20size=20for=20SPCustomQuery.m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPTableContent.m | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'Source/SPTableContent.m') diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 1194be97..4017f42a 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -3313,22 +3313,37 @@ return; } - // Sets order descending if a header is clicked twice + // Sets column order as tri-state descending, ascending, no sort, descending, ascending etc. order if the same + // header is clicked several times if ([[tableColumn identifier] isEqualTo:sortCol]) { - isDesc = !isDesc; + if(isDesc) { + [sortCol release]; + sortCol = nil; + } else { + if (sortCol) [sortCol release]; + sortCol = [[NSNumber alloc] initWithInteger:[[tableColumn identifier] integerValue]]; + isDesc = !isDesc; + } } else { isDesc = NO; [[tableContentView onMainThread] setIndicatorImage:nil inTableColumn:[tableContentView tableColumnWithIdentifier:sortCol]]; + if (sortCol) [sortCol release]; + sortCol = [[NSNumber alloc] initWithInteger:[[tableColumn identifier] integerValue]]; } - if (sortCol) [sortCol release]; - sortCol = [[NSNumber alloc] initWithInteger:[[tableColumn identifier] integerValue]]; - // Set the highlight and indicatorImage - [[tableContentView onMainThread] setHighlightedTableColumn:tableColumn]; - if (isDesc) { - [[tableContentView onMainThread] setIndicatorImage:[NSImage imageNamed:@"NSDescendingSortIndicator"] inTableColumn:tableColumn]; + if(sortCol) { + // Set the highlight and indicatorImage + [[tableContentView onMainThread] setHighlightedTableColumn:tableColumn]; + if (isDesc) { + [[tableContentView onMainThread] setIndicatorImage:[NSImage imageNamed:@"NSDescendingSortIndicator"] inTableColumn:tableColumn]; + } else { + [[tableContentView onMainThread] setIndicatorImage:[NSImage imageNamed:@"NSAscendingSortIndicator"] inTableColumn:tableColumn]; + } } else { - [[tableContentView onMainThread] setIndicatorImage:[NSImage imageNamed:@"NSAscendingSortIndicator"] inTableColumn:tableColumn]; + // If no sort order deselect column header and + // remove indicator image + [[tableContentView onMainThread] setHighlightedTableColumn:nil]; + [[tableContentView onMainThread] setIndicatorImage:nil inTableColumn:tableColumn]; } // Update data using the new sort order -- cgit v1.2.3