summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-08-31 09:09:14 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-09-06 11:48:47 -0700
commit093adf1ea88dbcab465051b28f8a60a3a29f7a87 (patch)
tree01611381737d3fe7bcb872503e452602217ee0fe /qt-models
parentfc706a0d722c2ae07d298f6e13794216e8d96a90 (diff)
downloadsubsurface-093adf1ea88dbcab465051b28f8a60a3a29f7a87.tar.gz
Map: highlight correct dive sites in dive site mode
Since changing the highlighting to use the selected dive, dive sites with no dive were never highlighted in dive site mode. Obviously, because there was no dive to be selected. Therefore special-case all dive-site selection code to recognize when we are in dive site mode. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/filtermodels.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp
index 7beb11d49..e9fbb9866 100644
--- a/qt-models/filtermodels.cpp
+++ b/qt-models/filtermodels.cpp
@@ -127,8 +127,7 @@ void MultiFilterSortModel::resetModel(DiveTripModelBase::Layout layout)
bool MultiFilterSortModel::showDive(const struct dive *d) const
{
- // If dive_sites is not empty, we are in a special dive-site filtering mode.
- if (!dive_sites.isEmpty())
+ if (diveSiteMode())
return dive_sites.contains(d->dive_site);
if (!filterData.validFilter)
@@ -267,13 +266,16 @@ void MultiFilterSortModel::myInvalidate()
#if !defined(SUBSURFACE_MOBILE)
// The shown maps may have changed -> reload the map widget.
- MapWidget::instance()->reload();
+ // But don't do this in dive site mode, because then we show all
+ // dive sites and only change the selected flag.
+ if (!diveSiteMode())
+ MapWidget::instance()->reload();
#endif
emit filterFinished();
#if !defined(SUBSURFACE_MOBILE)
- if (!dive_sites.isEmpty())
+ if (diveSiteMode())
MainWindow::instance()->diveList->expandAll();
#endif
}
@@ -303,6 +305,11 @@ void MultiFilterSortModel::startFilterDiveSites(QVector<dive_site *> ds)
} else {
std::sort(ds.begin(), ds.end());
dive_sites = ds;
+#if !defined(SUBSURFACE_MOBILE)
+ // When switching into dive site mode, reload the dive sites.
+ // We won't do this in myInvalidate() once we are in dive site mode.
+ MapWidget::instance()->reload();
+#endif
myInvalidate();
}
}
@@ -323,6 +330,10 @@ void MultiFilterSortModel::setFilterDiveSite(QVector<dive_site *> ds)
if (ds == dive_sites)
return;
dive_sites = ds;
+
+#if !defined(SUBSURFACE_MOBILE)
+ MapWidget::instance()->setSelected(dive_sites);
+#endif
myInvalidate();
}