diff options
-rw-r--r-- | qt-models/filtermodels.cpp | 12 | ||||
-rw-r--r-- | qt-models/filtermodels.h | 1 |
2 files changed, 11 insertions, 2 deletions
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index 1491dbacf..c8ed16274 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -228,7 +228,7 @@ bool FilterModelBase::setData(const QModelIndex &index, const QVariant &value, i break; } } - dataChanged(index, index); + dataChanged(index, index, { role }); return true; } return false; @@ -631,6 +631,14 @@ bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &s return false; } +void MultiFilterSortModel::filterChanged(const QModelIndex &from, const QModelIndex &to, const QVector<int> &roles) +{ + // Only redo the filter if a checkbox changed. If the count of an entry changed, + // we do *not* want to recalculate the filters. + if (roles.contains(Qt::CheckStateRole)) + myInvalidate(); +} + void MultiFilterSortModel::myInvalidate() { #if !defined(SUBSURFACE_MOBILE) @@ -683,7 +691,7 @@ void MultiFilterSortModel::myInvalidate() void MultiFilterSortModel::addFilterModel(FilterModelBase *model) { models.append(model); - connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(myInvalidate())); + connect(model, &FilterModelBase::dataChanged, this, &MultiFilterSortModel::filterChanged); } void MultiFilterSortModel::removeFilterModel(FilterModelBase *model) diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h index 3f5ca5f01..2fd5ef2b2 100644 --- a/qt-models/filtermodels.h +++ b/qt-models/filtermodels.h @@ -131,6 +131,7 @@ slots: void clearFilter(); void startFilterDiveSite(uint32_t uuid); void stopFilterDiveSite(); + void filterChanged(const QModelIndex &from, const QModelIndex &to, const QVector<int> &roles); signals: void filterFinished(); |