mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-17 09:19:38 -06:00
Allow to change sort order for any column in the multi-column sort list
A second Ctrl+Click over an already added column changes the direction of any column. Before this change, the effect was only applied to the last selected column and a second Ctrl+Click on the other columns triggered a requery without having changed anything. This was mentioned in PR #1810. See also issue #1761.
This commit is contained in:
@@ -2081,11 +2081,18 @@ void MainWindow::browseTableHeaderClicked(int logicalindex)
|
||||
{
|
||||
// Multi column sorting
|
||||
|
||||
// If the last sort column was just clicked again, change its sort order.
|
||||
// If not, add the column as a new sort column to the list.
|
||||
if(columns.size() && columns.back().column == static_cast<size_t>(logicalindex))
|
||||
columns.back().direction = (columns.back().direction == sqlb::Ascending ? sqlb::Descending : sqlb::Ascending);
|
||||
else
|
||||
// If the column was control+clicked again, change its sort order.
|
||||
// If not already in the sort order, add the column as a new sort column to the list.
|
||||
bool present = false;
|
||||
for(sqlb::SortedColumn& sortedCol : columns) {
|
||||
|
||||
if(sortedCol.column == static_cast<size_t>(logicalindex)) {
|
||||
sortedCol.direction = (sortedCol.direction == sqlb::Ascending ? sqlb::Descending : sqlb::Ascending);
|
||||
present = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!present)
|
||||
columns.emplace_back(logicalindex, sqlb::Ascending);
|
||||
} else {
|
||||
// Single column sorting
|
||||
|
||||
Reference in New Issue
Block a user