diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-08-24 09:13:57 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-08-24 09:13:57 +0000 |
commit | 8e737837b17f564e9c04f336858d1bea4d1a13a5 (patch) | |
tree | 52077fde7a91ab0f0cc974de14bb793d07c70dff /Source/SPTableContent.m | |
parent | 3a072cc8ff3b6aad3951f19c23391c98f4e953fd (diff) | |
download | sequelpro-8e737837b17f564e9c04f336858d1bea4d1a13a5.tar.gz sequelpro-8e737837b17f564e9c04f336858d1bea4d1a13a5.tar.bz2 sequelpro-8e737837b17f564e9c04f336858d1bea4d1a13a5.zip |
• introduced tri-state sort order for Content and Custom Query tables
- by clicking a the same table header the sort will changed to desc, asc, no sort order, desc, asc, etc.
• fixed sorting issue for Custom Query table
- reset sort order status before executing a new custom query
• code cosmetics: reduced file size for SPCustomQuery.m
Diffstat (limited to 'Source/SPTableContent.m')
-rw-r--r-- | Source/SPTableContent.m | 33 |
1 files changed, 24 insertions, 9 deletions
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 |