diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-11-06 07:27:00 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-11-08 20:50:05 +0100 |
commit | 2c9bf775b7b30930513fd4804306559bd90cb76b (patch) | |
tree | 7c06e69649c6161477327bc9e1787892f8707c26 | |
parent | 8b0f4e65d392a4d7e0948e0d209342c47711ee45 (diff) | |
download | subsurface-2c9bf775b7b30930513fd4804306559bd90cb76b.tar.gz |
Mobile: ensure the sort order is always set
This shouldn't be necessary every time we replace the sort model,
but it can't hurt, either (famous last words?).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-models/divelistmodel.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index c9bcaa2e1..37e48b023 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -17,8 +17,6 @@ CollapsedDiveListSortModel::CollapsedDiveListSortModel() { setSourceModel(DiveListSortModel::instance()); - setDynamicSortFilter(true); - updateFilterState(); // make sure that we after changes to the underlying model (and therefore the dive list // we update the filter state connect(DiveListModel::instance(), &DiveListModel::rowsInserted, this, &CollapsedDiveListSortModel::updateFilterState); @@ -35,6 +33,10 @@ CollapsedDiveListSortModel *CollapsedDiveListSortModel::instance() void CollapsedDiveListSortModel::setSourceModel(QAbstractItemModel *sourceModel) { QSortFilterProxyModel::setSourceModel(sourceModel); + // make sure we sort descending and have the filters correct + setDynamicSortFilter(true); + setSortRole(DiveListModel::DiveDateRole); + sort(0, Qt::DescendingOrder); updateFilterState(); } @@ -175,10 +177,6 @@ bool CollapsedDiveListSortModel::filterAcceptsRow(int source_row, const QModelIn DiveListSortModel::DiveListSortModel() { setSourceModel(DiveListModel::instance()); - setDynamicSortFilter(true); - setSortRole(DiveListModel::DiveDateRole); - sort(0, Qt::DescendingOrder); - updateFilterState(); LOG_STP("run_ui diveListModel sorted"); } @@ -212,6 +210,11 @@ void DiveListSortModel::updateFilterState() void DiveListSortModel::setSourceModel(QAbstractItemModel *sourceModel) { QSortFilterProxyModel::setSourceModel(sourceModel); + // make sure we sort descending and have the filters correct + setDynamicSortFilter(true); + setSortRole(DiveListModel::DiveDateRole); + sort(0, Qt::DescendingOrder); + updateFilterState(); } void DiveListSortModel::setFilter(QString f) |