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>
This commit is contained in:
Berthold Stoeger 2019-01-25 21:30:43 +01:00 committed by Dirk Hohndel
parent 3915e8a0d5
commit c210bfc0e0
5 changed files with 33 additions and 8 deletions

View file

@ -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));
}