mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Remember the column we are sorting by
A call to DiveListView::reload always reset our sortcolumn to be 0. Instead we are tracking the correct sort column and sort direction. This also removes an obsolete private member that was unused. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
eaa0d647b7
commit
01d515b5d8
2 changed files with 9 additions and 5 deletions
|
@ -22,7 +22,7 @@
|
|||
#include <QFileDialog>
|
||||
|
||||
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
|
||||
currentHeaderClicked(-1), searchBox(new QLineEdit(this))
|
||||
sortColumn(0), currentOrder(Qt::DescendingOrder), searchBox(new QLineEdit(this))
|
||||
{
|
||||
setUniformRowHeights(true);
|
||||
setItemDelegateForColumn(DiveTripModel::RATING, new StarWidgetsDelegate());
|
||||
|
@ -107,6 +107,7 @@ bool DiveListView::eventFilter(QObject* , QEvent* event)
|
|||
// index. TRIP_ROLE vs DIVE_ROLE?
|
||||
void DiveListView::headerClicked(int i)
|
||||
{
|
||||
sortColumn = i;
|
||||
QItemSelection oldSelection = selectionModel()->selection();
|
||||
QList<struct dive*> currentSelectedDives;
|
||||
DiveTripModel::Layout newLayout;
|
||||
|
@ -127,11 +128,13 @@ void DiveListView::headerClicked(int i)
|
|||
|
||||
/* No layout change? Just re-sort, and scroll to first selection, making sure all selections are expanded */
|
||||
if (currentLayout == newLayout) {
|
||||
sortByColumn(i);
|
||||
currentOrder = (currentOrder == Qt::DescendingOrder) ? Qt::AscendingOrder : Qt::DescendingOrder;
|
||||
sortByColumn(i, currentOrder);
|
||||
} else {
|
||||
// clear the model, repopulate with new indexes.
|
||||
reload(newLayout, false);
|
||||
sortByColumn(i, Qt::DescendingOrder);
|
||||
currentOrder = Qt::DescendingOrder;
|
||||
sortByColumn(i, currentOrder);
|
||||
}
|
||||
|
||||
// repopulate the selections.
|
||||
|
@ -163,7 +166,7 @@ void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort)
|
|||
if(!forceSort)
|
||||
return;
|
||||
|
||||
sortByColumn(0, Qt::DescendingOrder);
|
||||
sortByColumn(sortColumn, currentOrder);
|
||||
if (amount_selected && selected_dive >= 0) {
|
||||
selectDive(current_dive, true);
|
||||
} else {
|
||||
|
|
|
@ -48,7 +48,8 @@ signals:
|
|||
|
||||
private:
|
||||
bool mouseClickSelection;
|
||||
int currentHeaderClicked;
|
||||
int sortColumn;
|
||||
Qt::SortOrder currentOrder;
|
||||
DiveTripModel::Layout currentLayout;
|
||||
QLineEdit *searchBox;
|
||||
QModelIndex contextMenuIndex;
|
||||
|
|
Loading…
Reference in a new issue