From 5aacd73a00bac5721674b1f8b223d3aacc862a4c Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 12 Apr 2019 15:31:11 +0200 Subject: [PATCH] Filter: call update title directly in filter model Instead of sending a signal when counts change, catching them in the filter widget and update the window title there, directly update the window title in the model. This removes a signal/slot pair. Signed-off-by: Berthold Stoeger --- desktop-widgets/filterwidget2.cpp | 10 ---------- desktop-widgets/filterwidget2.h | 1 - qt-models/filtermodels.cpp | 10 ++++++++-- qt-models/filtermodels.h | 2 +- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp index d95311da3..622b66aa6 100644 --- a/desktop-widgets/filterwidget2.cpp +++ b/desktop-widgets/filterwidget2.cpp @@ -119,10 +119,6 @@ FilterWidget2::FilterWidget2(QWidget* parent) : connect(qPrefUnits::instance(), &qPrefUnits::unit_systemChanged, this, &FilterWidget2::temperatureChanged); - // Update counts if dives were added / removed - connect(MultiFilterSortModel::instance(), &MultiFilterSortModel::countsChanged, - this, &FilterWidget2::countsChanged); - // Reset all fields. clearFilter(); } @@ -241,12 +237,6 @@ void FilterWidget2::hideEvent(QHideEvent *event) void FilterWidget2::filterDataChanged(const FilterData &data) { MultiFilterSortModel::instance()->filterDataChanged(data); - countsChanged(); -} - -void FilterWidget2::countsChanged() -{ - updateWindowTitle(); } QString FilterWidget2::shownText() diff --git a/desktop-widgets/filterwidget2.h b/desktop-widgets/filterwidget2.h index 297d65e4e..212f6b5ae 100644 --- a/desktop-widgets/filterwidget2.h +++ b/desktop-widgets/filterwidget2.h @@ -33,7 +33,6 @@ private slots: void clearFilter(); void closeFilter(); void temperatureChanged(); - void countsChanged(); private: bool ignoreSignal; diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index a0c910244..94b74d92d 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -241,6 +241,7 @@ void MultiFilterSortModel::myInvalidate() // Tell the dive trip model to update the displayed-counts DiveTripModelBase::instance()->filterFinished(); + countsChanged(); emit filterFinished(); #if !defined(SUBSURFACE_MOBILE) @@ -296,7 +297,7 @@ void MultiFilterSortModel::divesAdded(dive_trip *, bool, const QVector & if (!d->hidden_by_filter) ++divesDisplayed; } - emit countsChanged(); + countsChanged(); } void MultiFilterSortModel::divesDeleted(dive_trip *, bool, const QVector &dives) @@ -305,5 +306,10 @@ void MultiFilterSortModel::divesDeleted(dive_trip *, bool, const QVector if (!d->hidden_by_filter) --divesDisplayed; } - emit countsChanged(); + countsChanged(); +} + +void MultiFilterSortModel::countsChanged() +{ + updateWindowTitle(); } diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h index 6513788f2..45e1e7189 100644 --- a/qt-models/filtermodels.h +++ b/qt-models/filtermodels.h @@ -77,11 +77,11 @@ slots: signals: void filterFinished(); - void countsChanged(); private: MultiFilterSortModel(QObject *parent = 0); struct dive_site *curr_dive_site; + void countsChanged(); FilterData filterData; };