From 38b686687faed3f8f60828105a2036d5f4e48db6 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 22 Jun 2020 14:05:46 +0200 Subject: cleanup: move shown-text calculation from filter widget to core The filter widget was caching whether the filter was active and used that flag to calculate the "# dives shown" string. Move this directly to the DiveFilter class to remove interdependencies and to unify with mobile. Signed-off-by: Berthold Stoeger --- desktop-widgets/filterwidget2.cpp | 12 +----------- desktop-widgets/filterwidget2.h | 2 -- desktop-widgets/mainwindow.cpp | 2 +- 3 files changed, 2 insertions(+), 14 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp index c51bef29a..26cb05c2a 100644 --- a/desktop-widgets/filterwidget2.cpp +++ b/desktop-widgets/filterwidget2.cpp @@ -10,8 +10,7 @@ FilterWidget2::FilterWidget2(QWidget* parent) : QWidget(parent), - ignoreSignal(false), - validFilter(false) + ignoreSignal(false) { ui.setupUi(this); @@ -194,7 +193,6 @@ void FilterWidget2::updateFilter() return; FilterData filterData = createFilterData(); - validFilter = filterData.validFilter(); DiveFilter::instance()->setFilter(filterData); } @@ -227,11 +225,3 @@ void FilterWidget2::addConstraint(filter_constraint_type type) { constraintModel.addConstraint(type); } - -QString FilterWidget2::shownText() -{ - if (validFilter) - return tr("%L1/%L2 shown").arg(shown_dives).arg(dive_table.nr); - else - return tr("%L1 dives").arg(dive_table.nr); -} diff --git a/desktop-widgets/filterwidget2.h b/desktop-widgets/filterwidget2.h index a727c964c..3de16872e 100644 --- a/desktop-widgets/filterwidget2.h +++ b/desktop-widgets/filterwidget2.h @@ -20,7 +20,6 @@ class FilterWidget2 : public QWidget { public: explicit FilterWidget2(QWidget *parent = 0); ~FilterWidget2(); - QString shownText(); protected: void hideEvent(QHideEvent *event) override; @@ -43,7 +42,6 @@ private: bool ignoreSignal; Ui::FilterWidget2 ui; FilterConstraintModel constraintModel; - bool validFilter; void addConstraint(filter_constraint_type type); std::vector> constraintWidgets; FilterData createFilterData() const; diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index d4bbc1384..1683a4122 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -1536,7 +1536,7 @@ void MainWindow::setTitle() } QString unsaved = (unsavedChanges() ? " *" : ""); - QString shown = QString(" (%1)").arg(filterWidget2.shownText()); + QString shown = QString(" (%1)").arg(DiveFilter::instance()->shownText()); setWindowTitle("Subsurface: " + displayedFilename(existing_filename) + unsaved + shown); } -- cgit v1.2.3-70-g09d2