diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-11-04 18:11:30 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-11-05 07:55:53 -0800 |
commit | 64a1a50e10c4ec8432de9d7cc08921b1b5b490a5 (patch) | |
tree | ba9446e1ca314913797963b17e9ec131c0639af4 | |
parent | f2f18b4e16656f0eb0d6b41981baa991ade3d33c (diff) | |
download | subsurface-64a1a50e10c4ec8432de9d7cc08921b1b5b490a5.tar.gz |
Dive list: remove sortColumn and currentOrder members
Since the QHeaderView of DiveListView is now the authority
over sort-column and sort-order, it makes little sense
to keep these as member variables. That would only risk
inconsistencies. Remove them and query the QHeaderView
instead.
We still need to keep track of currentLayout, as we
have to detect if it changes to change the underlying
model from tree to list or vice-versa.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | desktop-widgets/divelistview.cpp | 8 | ||||
-rw-r--r-- | desktop-widgets/divelistview.h | 2 |
2 files changed, 3 insertions, 7 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index 227ae502e..149682345 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -26,8 +26,8 @@ #include "core/metrics.h" #include "core/subsurface-qt/DiveListNotifier.h" -DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), sortColumn(DiveTripModel::NR), - currentOrder(Qt::AscendingOrder), currentLayout(DiveTripModel::TREE), dontEmitDiveChangedSignal(false), selectionSaved(false), +DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), + currentLayout(DiveTripModel::TREE), dontEmitDiveChangedSignal(false), selectionSaved(false), initialColumnWidths(DiveTripModel::COLUMNS, 50) // Set up with default length 50 { setItemDelegate(new DiveListDelegate(this)); @@ -478,9 +478,6 @@ void DiveListView::sortIndicatorChanged(int i, Qt::SortOrder order) restoreExpandedRows(); restoreSelection(); } - // remember the new sort column - sortColumn = i; - currentOrder = order; } void DiveListView::setSortOrder(int i, Qt::SortOrder order) @@ -890,6 +887,7 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event) if (!d->divetrip) { struct dive *top = d; struct dive *bottom = d; + Qt::SortOrder currentOrder = header()->sortIndicatorOrder(); if (d->selected) { if (currentOrder == Qt::AscendingOrder) { top = first_selected_dive(); diff --git a/desktop-widgets/divelistview.h b/desktop-widgets/divelistview.h index 79049d754..85d8bd21c 100644 --- a/desktop-widgets/divelistview.h +++ b/desktop-widgets/divelistview.h @@ -68,8 +68,6 @@ slots: private: bool mouseClickSelection; QList<int> expandedRows; - int sortColumn; - Qt::SortOrder currentOrder; DiveTripModel::Layout currentLayout; QModelIndex contextMenuIndex; bool dontEmitDiveChangedSignal; |