diff options
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" |