diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-10-19 13:33:35 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-10-21 19:57:49 +0300 |
commit | 2f81890f496a21c852513a26b728e04e03c4f01e (patch) | |
tree | acd665a6112a751146a1cdc498a7d133ed5f8f30 /qt-models | |
parent | bca9c8f88cccf708f54b97524dc84ab5aaa9c4f3 (diff) | |
download | subsurface-2f81890f496a21c852513a26b728e04e03c4f01e.tar.gz |
Dive list: update trip headers on filter-finish
On change of the filter, the headers of non-extended trips were not
updated. Therefore, on filter-finish-event loop over all trips
in DiveTripModel and signal data-changed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divetripmodel.cpp | 16 | ||||
-rw-r--r-- | qt-models/divetripmodel.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index ff96669a7..5f64b8741 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #include "qt-models/divetripmodel.h" +#include "qt-models/filtermodels.h" #include "core/gettextfromc.h" #include "core/metrics.h" #include "core/divelist.h" @@ -319,6 +320,9 @@ DiveTripModel::DiveTripModel(QObject *parent) : connect(&diveListNotifier, &DiveListNotifier::divesSelected, this, &DiveTripModel::divesSelected); connect(&diveListNotifier, &DiveListNotifier::divesDeselected, this, &DiveTripModel::divesDeselected); connect(&diveListNotifier, &DiveListNotifier::currentDiveChanged, this, &DiveTripModel::currentDiveChanged); + + // Update trip headers if filter finished + connect(MultiFilterSortModel::instance(), &MultiFilterSortModel::filterFinished, this, &DiveTripModel::filterFinished); } int DiveTripModel::columnCount(const QModelIndex&) const @@ -1095,3 +1099,15 @@ void DiveTripModel::currentDiveChanged() emit newCurrentDive(createIndex(diveIdx, 0, idx)); } } + +void DiveTripModel::filterFinished() +{ + // If the filter finished, update all trip items to show the correct number of displayed dives + // in each trip. Without doing this, only trip headers of expanded trips were updated. + if (currentLayout == LIST) + return; // No trips in list mode + for (int idx = 0; idx < (int)items.size(); ++idx) { + QModelIndex tripIndex = createIndex(idx, 0, noParent); + dataChanged(tripIndex, tripIndex); + } +} diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h index d75926f9e..9ccad16dc 100644 --- a/qt-models/divetripmodel.h +++ b/qt-models/divetripmodel.h @@ -75,6 +75,7 @@ private slots: void divesSelected(dive_trip *trip, const QVector<dive *> &dives); void divesDeselected(dive_trip *trip, const QVector<dive *> &dives); void currentDiveChanged(); + void filterFinished(); private: // The model has up to two levels. At the top level, we have either trips or dives // that do not belong to trips. Such a top-level item is represented by the "Item" |