mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
3915e8a0d5
commit
c210bfc0e0
5 changed files with 33 additions and 8 deletions
|
@ -79,6 +79,9 @@ MultiFilterSortModel::MultiFilterSortModel(QObject *parent) : QSortFilterProxyMo
|
|||
{
|
||||
setFilterKeyColumn(-1); // filter all columns
|
||||
setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
|
||||
connect(&diveListNotifier, &DiveListNotifier::divesAdded, this, &MultiFilterSortModel::divesAdded);
|
||||
connect(&diveListNotifier, &DiveListNotifier::divesDeleted, this, &MultiFilterSortModel::divesDeleted);
|
||||
}
|
||||
|
||||
void MultiFilterSortModel::resetModel(DiveTripModelBase::Layout layout)
|
||||
|
@ -235,3 +238,21 @@ void MultiFilterSortModel::filterDataChanged(const FilterData &data)
|
|||
filterData = data;
|
||||
myInvalidate();
|
||||
}
|
||||
|
||||
void MultiFilterSortModel::divesAdded(dive_trip *, bool, const QVector<dive *> &dives)
|
||||
{
|
||||
for (dive *d: dives) {
|
||||
if (!d->hidden_by_filter)
|
||||
++divesDisplayed;
|
||||
}
|
||||
emit countsChanged();
|
||||
}
|
||||
|
||||
void MultiFilterSortModel::divesDeleted(dive_trip *, bool, const QVector<dive *> &dives)
|
||||
{
|
||||
for (dive *d: dives) {
|
||||
if (!d->hidden_by_filter)
|
||||
--divesDisplayed;
|
||||
}
|
||||
emit countsChanged();
|
||||
}
|
||||
|
|
|
@ -57,9 +57,12 @@ slots:
|
|||
void filterChanged(const QModelIndex &from, const QModelIndex &to, const QVector<int> &roles);
|
||||
void resetModel(DiveTripModelBase::Layout layout);
|
||||
void filterDataChanged(const FilterData &data);
|
||||
void divesAdded(struct dive_trip *, bool, const QVector<dive *> &dives);
|
||||
void divesDeleted(struct dive_trip *, bool, const QVector<dive *> &dives);
|
||||
|
||||
signals:
|
||||
void filterFinished();
|
||||
void countsChanged();
|
||||
|
||||
private:
|
||||
MultiFilterSortModel(QObject *parent = 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue