summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-11-17 16:23:00 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-11-19 21:13:40 -0800
commit2d09819ddfc6bbb4eb9bd7127485f42c839fd85b (patch)
tree9cdd417a2f266faaec73a9a2bfe5f599ac60a82f /qt-models
parentcbd98edb73e26b3b3d9068823d9155c61cb3a9b2 (diff)
downloadsubsurface-2d09819ddfc6bbb4eb9bd7127485f42c839fd85b.tar.gz
Filter: move number of shown dives to core
We mark hidden/shown dives in the core but store the number of shown dives in the MultiFilterSortModel. Move this datum to the core for improved locality. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/filtermodels.cpp13
-rw-r--r--qt-models/filtermodels.h1
2 files changed, 6 insertions, 8 deletions
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp
index 37578abc1..7a1a8af7d 100644
--- a/qt-models/filtermodels.cpp
+++ b/qt-models/filtermodels.cpp
@@ -107,7 +107,6 @@ MultiFilterSortModel *MultiFilterSortModel::instance()
}
MultiFilterSortModel::MultiFilterSortModel(QObject *parent) : QSortFilterProxyModel(parent),
- divesDisplayed(0),
diveSiteRefCount(0)
{
setFilterKeyColumn(-1); // filter all columns
@@ -215,7 +214,7 @@ void MultiFilterSortModel::myInvalidate()
// as a consequence of the filterFinished signal right after the local scope.
auto marker = diveListNotifier.enterCommand();
- divesDisplayed = 0;
+ shown_dives = 0;
for (int i = 0; i < m->rowCount(QModelIndex()); ++i) {
QModelIndex idx = m->index(i, 0, QModelIndex());
@@ -233,7 +232,7 @@ void MultiFilterSortModel::myInvalidate()
}
bool show = showDive(d);
if (show) {
- divesDisplayed++;
+ shown_dives++;
showTrip = true;
}
m->setData(idx2, show, DiveTripModelBase::SHOWN_ROLE);
@@ -243,7 +242,7 @@ void MultiFilterSortModel::myInvalidate()
dive *d = m->data(idx, DiveTripModelBase::DIVE_ROLE).value<dive *>();
bool show = (d != NULL) && showDive(d);
if (show)
- divesDisplayed++;
+ shown_dives++;
m->setData(idx, show, DiveTripModelBase::SHOWN_ROLE);
}
}
@@ -278,7 +277,7 @@ bool MultiFilterSortModel::updateDive(struct dive *d)
bool changed = oldStatus != newStatus;
if (changed) {
filter_dive(d, newStatus);
- divesDisplayed += newStatus - oldStatus;
+ shown_dives += newStatus - oldStatus;
}
return changed;
}
@@ -348,7 +347,7 @@ void MultiFilterSortModel::divesAdded(dive_trip *, bool, const QVector<dive *> &
{
for (dive *d: dives) {
if (!d->hidden_by_filter)
- ++divesDisplayed;
+ ++shown_dives;
}
countsChanged();
}
@@ -357,7 +356,7 @@ void MultiFilterSortModel::divesDeleted(dive_trip *, bool, const QVector<dive *>
{
for (dive *d: dives) {
if (!d->hidden_by_filter)
- --divesDisplayed;
+ --shown_dives;
}
countsChanged();
}
diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h
index 65bab27df..a3397dde6 100644
--- a/qt-models/filtermodels.h
+++ b/qt-models/filtermodels.h
@@ -61,7 +61,6 @@ public:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
bool showDive(const struct dive *d) const;
bool updateDive(struct dive *d); // returns true if visibility status changed
- int divesDisplayed;
bool lessThan(const QModelIndex &, const QModelIndex &) const override;
bool diveSiteMode() const; // returns true if we're filtering on dive site
const QVector<dive_site *> &filteredDiveSites() const;