summaryrefslogtreecommitdiffstats
path: root/qt-ui/models.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-03 17:52:04 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-03 17:52:04 -0800
commit0dd87989a878945331ea3266ff0f490f058bfea3 (patch)
tree5636878028e4140acba7e90f6e4501a6b519022f /qt-ui/models.cpp
parenta3f1dc76816ae385315a91188fdbbcfc2d26d71d (diff)
downloadsubsurface-0dd87989a878945331ea3266ff0f490f058bfea3.tar.gz
Correctly unselect trips when dive list filters change
Oddly Qt left the trips selected (but all dives where unselected in the UI). This got our internal state rather confused. With this change we clean up that mess and go back to just having those dives that were originally selected and are still visible show up as selected. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r--qt-ui/models.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index c5b602c83..796397f77 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -2617,18 +2617,28 @@ void MultiFilterSortModel::myInvalidate()
{
int i;
struct dive *d;
+ DiveListView *dlv = MainWindow::instance()->dive_list();
invalidate();
- for_each_dive (i, d) {
- if(d->selected)
- MainWindow::instance()->dive_list()->selectDive(get_idx_by_uniq_id(d->id));
- }
+ // first make sure the trips are no longer shown as selected
+ // (but without updating the selection state of the dives... this just cleans
+ // up an oddity in the filter handling)
+ dlv->clearTripSelection();
+
// if we have no more selected dives, clean up the display - this later triggers us
// to pick one of the dives that are shown in the list as selected dive which is the
// natural behavior
- if (amount_selected == 0)
+ if (amount_selected == 0) {
MainWindow::instance()->cleanUpEmpty();
+ } else {
+ // otherwise find the dives that should still be selected (the filter above unselected any
+ // dive that's no longer visible) and select them again
+ for_each_dive (i, d) {
+ if(d->selected)
+ dlv->selectDive(get_idx_by_uniq_id(d->id));
+ }
+ }
}
void MultiFilterSortModel::addFilterModel(MultiFilterInterface *model)