summaryrefslogtreecommitdiffstats
path: root/qt-models/filtermodels.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-05-06 22:52:52 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-05-11 12:06:19 -0700
commit29c6aea797f96e59eae621df3b35b4fd0f260e3f (patch)
tree24f8b4421c69f9c29dda05ab54d3300bffa240cb /qt-models/filtermodels.cpp
parent4e81edcf1e73b118fea1cb72b8a287a2ed738ef5 (diff)
downloadsubsurface-29c6aea797f96e59eae621df3b35b4fd0f260e3f.tar.gz
Filter: prevent selection-change notifications in filter invalidation
Invalidating the filter can cause numerous selection-change notifications. These cause a full UI reload. Therefore, go into "command" mode that was implemented for the undo commands. Then, all selection-changes are considered as "programmatical" and ignored. At the end of filter invalidation, a filter-finished signal causes a proper reload anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/filtermodels.cpp')
-rw-r--r--qt-models/filtermodels.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp
index 331439bb4..5b1169de8 100644
--- a/qt-models/filtermodels.cpp
+++ b/qt-models/filtermodels.cpp
@@ -227,21 +227,33 @@ void MultiFilterSortModel::myInvalidate()
int i;
struct dive *d;
- divesDisplayed = 0;
-
- // Apply filter for each dive
- for_each_dive (i, d) {
- bool show = showDive(d);
- filter_dive(d, show);
- if (show)
- divesDisplayed++;
+ {
+ // This marker prevents the UI from getting notifications on selection changes.
+ // It is active until the end of the scope.
+ // This is actually meant for the undo-commands, so that they can do their work
+ // without having the UI updated.
+ // Here, it is used because invalidating the filter can generate numerous
+ // selection changes, which do full ui reloads. Instead, do that all at once
+ // as a consequence of the filterFinished signal right after the local scope.
+ auto marker = diveListNotifier.enterCommand();
+
+ divesDisplayed = 0;
+
+ // Apply filter for each dive
+ for_each_dive (i, d) {
+ bool show = showDive(d);
+ filter_dive(d, show);
+ if (show)
+ divesDisplayed++;
+ }
+
+ invalidateFilter();
+
+ // Tell the dive trip model to update the displayed-counts
+ DiveTripModelBase::instance()->filterFinished();
+ countsChanged();
}
- invalidateFilter();
-
- // Tell the dive trip model to update the displayed-counts
- DiveTripModelBase::instance()->filterFinished();
- countsChanged();
emit filterFinished();
#if !defined(SUBSURFACE_MOBILE)