mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Undo: update filter flag when dives change
The filter code is strange: it actually only checks the dive->hidden_by_filter flag. Thus, before propagating the dive changed signal, this flag has to be updated. Do this in the DiveTripModel. Ultimately, this should be refactored. Moreover, if the filter-flag changed notify the frontend of a changed trip so that the trip is hidden / unhidden. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
e7063b6b08
commit
9afea37e15
4 changed files with 46 additions and 3 deletions
|
@ -876,6 +876,12 @@ void DiveTripModelTree::divesDeleted(dive_trip *trip, bool deleteTrip, const QVe
|
|||
|
||||
void DiveTripModelTree::divesChanged(dive_trip *trip, const QVector<dive *> &dives)
|
||||
{
|
||||
// Update filter flags. TODO: The filter should update the flag by itself when
|
||||
// recieving the signals below.
|
||||
bool diveChanged = false;
|
||||
for (dive *d: dives)
|
||||
diveChanged |= MultiFilterSortModel::instance()->updateDive(d);
|
||||
|
||||
if (!trip) {
|
||||
// This is outside of a trip. Process top-level items range-wise.
|
||||
|
||||
|
@ -910,6 +916,10 @@ void DiveTripModelTree::divesChanged(dive_trip *trip, const QVector<dive *> &div
|
|||
|
||||
// If necessary, move the trip
|
||||
topLevelChanged(idx);
|
||||
|
||||
// If a dive changed, re-render the trip in the list [or actually make it (in)visible].
|
||||
if (diveChanged)
|
||||
dataChanged(createIndex(idx, 0, noParent), createIndex(idx, 0, noParent));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1161,6 +1171,11 @@ void DiveTripModelList::divesDeleted(dive_trip *trip, bool deleteTrip, const QVe
|
|||
|
||||
void DiveTripModelList::divesChanged(dive_trip *trip, const QVector<dive *> &dives)
|
||||
{
|
||||
// Update filter flags. TODO: The filter should update the flag by itself when
|
||||
// recieving the signals below.
|
||||
for (dive *d: dives)
|
||||
MultiFilterSortModel::instance()->updateDive(d);
|
||||
|
||||
// Since we know that the dive list is sorted, we will only ever search for the first element
|
||||
// in dives as this must be the first that we encounter. Once we find a range, increase the
|
||||
// index accordingly.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue