mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Filter: Make filters aware of added / removed dives
Instead of reloading all the filter, only increment / decrement the count of the entries of added / removed dives. Originally, this was planned to be done via the signals from the divelist, but it turned out that this was suboptimal, because if the filter decides that the new item is selected, this has to be done *before* adding the dive. Otherwise, it wouldn't be shown. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
11e0b7ac0a
commit
7150d1c6f6
3 changed files with 183 additions and 5 deletions
|
@ -109,6 +109,11 @@ std::vector<DiveToAdd> DiveListBase::removeDives(std::vector<dive *> &divesToDel
|
|||
std::vector<DiveToAdd> res;
|
||||
res.reserve(divesToDelete.size());
|
||||
|
||||
// First, tell the filters that dives are removed. This could
|
||||
// be done later using the emitted signals, but we do this here
|
||||
// for symmetry with addDives()
|
||||
MultiFilterSortModel::instance()->divesDeleted(QVector<dive *>::fromStdVector(divesToDelete));
|
||||
|
||||
for (dive *d: divesToDelete)
|
||||
res.push_back(removeDive(d));
|
||||
divesToDelete.clear();
|
||||
|
@ -141,6 +146,15 @@ std::vector<dive *> DiveListBase::addDives(std::vector<DiveToAdd> &divesToAdd)
|
|||
std::vector<dive *> res;
|
||||
res.resize(divesToAdd.size());
|
||||
|
||||
// First, tell the filters that new dives are added. We do this here
|
||||
// instead of later by signals, so that the filter can set the
|
||||
// checkboxes of the new rows to its liking. The added dives will
|
||||
// then appear in the correct shown/hidden state.
|
||||
QVector<dive *> divesForFilter;
|
||||
for (const DiveToAdd &entry: divesToAdd)
|
||||
divesForFilter.push_back(entry.dive.get());
|
||||
MultiFilterSortModel::instance()->divesAdded(divesForFilter);
|
||||
|
||||
// At the end of the function, to send the proper dives-added signals,
|
||||
// we the the list of added trips. Create this list now.
|
||||
std::vector<dive_trip *> addedTrips;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue