Filter: separate backend from frontend logic

The filter code was an unholy intermixture of backend and frontend
logic, which made it hard to access it from outside of the UI.
Notably, it expected that Qt would call filterAcceptsRow on all rows.
For trip-view, apparently the filter functions were called twice
(once for filtering the trip, then for filtering the individual dives).

Make the filtering explicit, by calling showDive() for all dives in
MultiFilterSortModel::myInvalidate(), setting the hidden_by_filter
flags accordingly and ultimately invalidating the filter.

The UI code only accesses the hidden_by_filter flag set previously.

The "justCleared" flag can then be removed, since accessing the filter
does not have side effects. Moreover, there is no noticeable performance
gain by returning out early.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-08-14 18:30:49 -04:00
parent 13fbca3f55
commit 979f81f409
2 changed files with 22 additions and 42 deletions

View file

@ -111,7 +111,6 @@ signals:
private:
MultiFilterSortModel(QObject *parent = 0);
QList<FilterModelBase *> models;
bool justCleared;
struct dive_site *curr_dive_site;
};