summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-01-25 21:30:43 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-01-26 08:05:39 -0800
commitc210bfc0e0205067c4f4274afc7975486e35252a (patch)
tree1e83943a45e7089d63ede422aa6123ccb1253e90 /desktop-widgets
parent3915e8a0d5a3199ec1aa3c2dfc1de049b2be7d9e (diff)
downloadsubsurface-c210bfc0e0205067c4f4274afc7975486e35252a.tar.gz
Filter: update counts if dives added / removed
Update the filter counts if dives were added removed by the undo commands. The undo commands call into the filter model at the right time so that hidden_by_filter is already set. The filter model keeps track of the counts and emits a signal, which is caught by the widget. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/command_divelist.cpp8
-rw-r--r--desktop-widgets/filterwidget2.cpp8
-rw-r--r--desktop-widgets/filterwidget2.h1
3 files changed, 9 insertions, 8 deletions
diff --git a/desktop-widgets/command_divelist.cpp b/desktop-widgets/command_divelist.cpp
index cf8feed0b..f45202aa9 100644
--- a/desktop-widgets/command_divelist.cpp
+++ b/desktop-widgets/command_divelist.cpp
@@ -141,14 +141,6 @@ std::vector<dive *> DiveListBase::addDives(DivesAndTripsToAdd &toAdd)
std::vector<dive *> res;
res.resize(toAdd.dives.size());
- // First, tell the filters that new dives are added. We do this here
- // instead of later by signals, so that the filter can set the
- // checkboxes of the new rows to its liking. The added dives will
- // then appear in the correct shown/hidden state.
- QVector<dive *> divesForFilter;
- for (const DiveToAdd &entry: toAdd.dives)
- divesForFilter.push_back(entry.dive.get());
-
// Now, add the dives
// Note: the idiomatic STL-way would be std::transform, but let's use a loop since
// that is closer to classical C-style.
diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp
index 9eb4f733b..028f774f1 100644
--- a/desktop-widgets/filterwidget2.cpp
+++ b/desktop-widgets/filterwidget2.cpp
@@ -96,6 +96,10 @@ FilterWidget2::FilterWidget2(QWidget* parent) : QWidget(parent)
// Update temperature fields if user changes temperature-units in preferences.
connect(qPrefUnits::instance(), &qPrefUnits::temperatureChanged, this, &FilterWidget2::temperatureChanged);
connect(qPrefUnits::instance(), &qPrefUnits::unit_systemChanged, this, &FilterWidget2::temperatureChanged);
+
+ // Update counts if dives were added / removed
+ connect(MultiFilterSortModel::instance(), &MultiFilterSortModel::countsChanged,
+ this, &FilterWidget2::countsChanged);
}
void FilterWidget2::temperatureChanged()
@@ -161,7 +165,11 @@ void FilterWidget2::hideEvent(QHideEvent *event)
void FilterWidget2::filterDataChanged(const FilterData &data)
{
MultiFilterSortModel::instance()->filterDataChanged(data);
+ countsChanged();
+}
+void FilterWidget2::countsChanged()
+{
ui.filterText->setText(tr("%L1/%L2 shown").arg(MultiFilterSortModel::instance()->divesDisplayed)
.arg(dive_table.nr));
}
diff --git a/desktop-widgets/filterwidget2.h b/desktop-widgets/filterwidget2.h
index ab388ba6a..23d08dd2a 100644
--- a/desktop-widgets/filterwidget2.h
+++ b/desktop-widgets/filterwidget2.h
@@ -29,6 +29,7 @@ public slots:
void updateLogged(int value);
private slots:
void temperatureChanged();
+ void countsChanged();
private:
Ui::FilterWidget2 ui;