summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-01-25 21:30:43 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-01-26 08:05:39 -0800
commitc210bfc0e0205067c4f4274afc7975486e35252a (patch)
tree1e83943a45e7089d63ede422aa6123ccb1253e90 /qt-models
parent3915e8a0d5a3199ec1aa3c2dfc1de049b2be7d9e (diff)
downloadsubsurface-c210bfc0e0205067c4f4274afc7975486e35252a.tar.gz
Filter: update counts if dives added / removed
Update the filter counts if dives were added removed by the undo commands. The undo commands call into the filter model at the right time so that hidden_by_filter is already set. The filter model keeps track of the counts and emits a signal, which is caught by the widget. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/filtermodels.cpp21
-rw-r--r--qt-models/filtermodels.h3
2 files changed, 24 insertions, 0 deletions
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp
index 53149eba2..5168e32d8 100644
--- a/qt-models/filtermodels.cpp
+++ b/qt-models/filtermodels.cpp
@@ -79,6 +79,9 @@ MultiFilterSortModel::MultiFilterSortModel(QObject *parent) : QSortFilterProxyMo
{
setFilterKeyColumn(-1); // filter all columns
setFilterCaseSensitivity(Qt::CaseInsensitive);
+
+ connect(&diveListNotifier, &DiveListNotifier::divesAdded, this, &MultiFilterSortModel::divesAdded);
+ connect(&diveListNotifier, &DiveListNotifier::divesDeleted, this, &MultiFilterSortModel::divesDeleted);
}
void MultiFilterSortModel::resetModel(DiveTripModelBase::Layout layout)
@@ -235,3 +238,21 @@ void MultiFilterSortModel::filterDataChanged(const FilterData &data)
filterData = data;
myInvalidate();
}
+
+void MultiFilterSortModel::divesAdded(dive_trip *, bool, const QVector<dive *> &dives)
+{
+ for (dive *d: dives) {
+ if (!d->hidden_by_filter)
+ ++divesDisplayed;
+ }
+ emit countsChanged();
+}
+
+void MultiFilterSortModel::divesDeleted(dive_trip *, bool, const QVector<dive *> &dives)
+{
+ for (dive *d: dives) {
+ if (!d->hidden_by_filter)
+ --divesDisplayed;
+ }
+ emit countsChanged();
+}
diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h
index 1925bc422..faaae8c2f 100644
--- a/qt-models/filtermodels.h
+++ b/qt-models/filtermodels.h
@@ -57,9 +57,12 @@ slots:
void filterChanged(const QModelIndex &from, const QModelIndex &to, const QVector<int> &roles);
void resetModel(DiveTripModelBase::Layout layout);
void filterDataChanged(const FilterData &data);
+ void divesAdded(struct dive_trip *, bool, const QVector<dive *> &dives);
+ void divesDeleted(struct dive_trip *, bool, const QVector<dive *> &dives);
signals:
void filterFinished();
+ void countsChanged();
private:
MultiFilterSortModel(QObject *parent = 0);