Dive list model: send changed signals for top-level items

In analogy to the tree-model send signals when dives change
their shown status in the list-view. Do this in two passes
(collect changes; send changes) to be able to reuse the
already existing functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-11-19 22:14:03 +01:00 committed by bstoeger
parent c54e58e078
commit 7d5c15f49a

View file

@ -1320,6 +1320,12 @@ dive *DiveTripModelList::diveOrNull(const QModelIndex &index) const
void DiveTripModelList::recalculateFilter()
{
// Collect the changes in a vector used later to send signals.
// This could be solved more efficiently in one pass, but
// doing it in two passes allows us to use a common function without
// resorting to co-routines, lambdas or similar techniques.
std::vector<char> changed;
changed.reserve(items.size());
{
// This marker prevents the UI from getting notifications on selection changes.
// It is active until the end of the scope. See comment in DiveTripModelTree::recalculateFilter().
@ -1332,6 +1338,9 @@ void DiveTripModelList::recalculateFilter()
}
}
// Send the data-changed signals if some items changed visibility.
sendShownChangedSignals(changed, noParent);
emit diveListNotifier.numShownChanged();
emit diveListNotifier.filterReset();
}