diff options
-rw-r--r-- | core/divelist.c | 1 | ||||
-rw-r--r-- | core/divelist.h | 1 | ||||
-rw-r--r-- | desktop-widgets/filterwidget2.cpp | 4 | ||||
-rw-r--r-- | qt-models/filtermodels.cpp | 13 | ||||
-rw-r--r-- | qt-models/filtermodels.h | 1 |
5 files changed, 10 insertions, 10 deletions
diff --git a/core/divelist.c b/core/divelist.c index a9ce0d7a3..4367b8708 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -899,6 +899,7 @@ void deselect_dive(struct dive *dive) } } +int shown_dives = 0; void filter_dive(struct dive *d, bool shown) { if (!d) diff --git a/core/divelist.h b/core/divelist.h index dc3ab1302..c0f70ccb6 100644 --- a/core/divelist.h +++ b/core/divelist.h @@ -9,6 +9,7 @@ extern "C" { #endif struct deco_state; +extern int shown_dives; /* this is used for both git and xml format */ #define DATAFORMAT_VERSION 3 diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp index bbb0aa124..0ab6bb022 100644 --- a/desktop-widgets/filterwidget2.cpp +++ b/desktop-widgets/filterwidget2.cpp @@ -2,6 +2,7 @@ #include "desktop-widgets/simplewidgets.h" #include "desktop-widgets/mainwindow.h" #include "core/qthelper.h" +#include "core/divelist.h" #include "core/settings/qPrefUnit.h" #include <QDoubleSpinBox> @@ -242,8 +243,7 @@ void FilterWidget2::filterDataChanged(const FilterData &data) QString FilterWidget2::shownText() { if (isActive()) - return tr("%L1/%L2 shown").arg(MultiFilterSortModel::instance()->divesDisplayed) - .arg(dive_table.nr); + return tr("%L1/%L2 shown").arg(shown_dives).arg(dive_table.nr); else return tr("%L1 dives").arg(dive_table.nr); } 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; |