mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Filter: reload only when checkstate changed
Currently, the filter is recalculated if a filter-entry is changed. This also happens if the counts of a filter-entry changes. This is to be avoided, as it causes unnecessary churn. Therefore, send the proper role with the dataChanged() signal and add a new slot, which invalidates only if a field with the Qt::CheckStateRole is changed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
7150d1c6f6
commit
e0fcf99d0a
2 changed files with 11 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue