summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-11-17 18:32:35 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-11-19 21:13:40 -0800
commit9ffafbc326b38bd2d0bb870fa4721b6c94280c28 (patch)
treed4ebf99b7c0320abdf1cf17bbf3ddbf4e5fd2f8b /qt-models
parentb76f2071589d6a7f45ec2845afa8b49110da608b (diff)
downloadsubsurface-9ffafbc326b38bd2d0bb870fa4721b6c94280c28.tar.gz
Filter: move num_shown logic from model to core
Since the number of shown dives is stored in the core, let's also keep it updated there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/divetripmodel.cpp1
-rw-r--r--qt-models/filtermodels.cpp16
2 files changed, 2 insertions, 15 deletions
diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp
index 7f9ca9e32..7ee09d2a7 100644
--- a/qt-models/divetripmodel.cpp
+++ b/qt-models/divetripmodel.cpp
@@ -1377,7 +1377,6 @@ void DiveTripModelList::filterFinished()
// In list mode, we don't have to change anything after filter finished.
}
-
// Simple sorting helper for sorting against a criterium and if
// that is undefined against a different criterium.
// Return true if diff1 < 0, false if diff1 > 0.
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp
index b04fce127..53b9e2e45 100644
--- a/qt-models/filtermodels.cpp
+++ b/qt-models/filtermodels.cpp
@@ -57,8 +57,6 @@ void MultiFilterSortModel::myInvalidate()
// as a consequence of the filterFinished signal right after the local scope.
auto marker = diveListNotifier.enterCommand();
- shown_dives = 0;
-
DiveFilter *filter = DiveFilter::instance();
for (int i = 0; i < m->rowCount(QModelIndex()); ++i) {
QModelIndex idx = m->index(i, 0, QModelIndex());
@@ -75,18 +73,14 @@ void MultiFilterSortModel::myInvalidate()
continue;
}
bool show = filter->showDive(d);
- if (show) {
- shown_dives++;
+ if (show)
showTrip = true;
- }
m->setData(idx2, show, DiveTripModelBase::SHOWN_ROLE);
}
m->setData(idx, showTrip, DiveTripModelBase::SHOWN_ROLE);
} else {
dive *d = m->data(idx, DiveTripModelBase::DIVE_ROLE).value<dive *>();
bool show = (d != NULL) && filter->showDive(d);
- if (show)
- shown_dives++;
m->setData(idx, show, DiveTripModelBase::SHOWN_ROLE);
}
}
@@ -103,14 +97,8 @@ void MultiFilterSortModel::myInvalidate()
bool MultiFilterSortModel::updateDive(struct dive *d)
{
- bool oldStatus = !d->hidden_by_filter;
bool newStatus = DiveFilter::instance()->showDive(d);
- bool changed = oldStatus != newStatus;
- if (changed) {
- filter_dive(d, newStatus);
- shown_dives += newStatus - oldStatus;
- }
- return changed;
+ return filter_dive(d, newStatus);
}
bool MultiFilterSortModel::lessThan(const QModelIndex &i1, const QModelIndex &i2) const