aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/modeldelegates.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-16 12:42:39 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-16 12:50:56 -0700
commit829e816e2b1e464e5635e6c396cc001fb7ccf537 (patch)
tree91232974042a3708db7f8fd1331322e2719b7e9b /qt-ui/modeldelegates.cpp
parent076f86202aab51529d99f73427a1a834a0ef5d34 (diff)
downloadsubsurface-829e816e2b1e464e5635e6c396cc001fb7ccf537.tar.gz
Location edit: correctly position globe if create dive options are active
This way when the user looks through the list of completion options the globe behaves in a consistent way, i.e., if the current dive site has a GPS fix and the user activates one of the two options to create a dive site with that GPS information, the globe show the right area (and the globe zooms out if the current dive site doesn't have a GPS fix). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/modeldelegates.cpp')
-rw-r--r--qt-ui/modeldelegates.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp
index 7089289aa..f0f77ab67 100644
--- a/qt-ui/modeldelegates.cpp
+++ b/qt-ui/modeldelegates.cpp
@@ -507,6 +507,13 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
if (index.row() < 2) {
diveSiteName = index.data().toString();
bottomText = index.data(Qt::ToolTipRole).toString();
+#ifndef NO_MARBLE
+ if ((option.state & QStyle::State_HasFocus)) {
+ // we call this even if the displayed dive site has no GPS data
+ // so that the globe appropriately zooms out...
+ MainWindow::instance()->globe()->centerOnDiveSite(&displayed_dive_site);
+ }
+#endif
goto print_part;
}
@@ -531,9 +538,13 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
}
#ifndef NO_MARBLE
- if ((option.state & QStyle::State_HasFocus) && dive_site_has_gps_location(ds)) {
- qDebug() << "center on" << ds->name;
- MainWindow::instance()->globe()->centerOnDiveSite(ds);
+ if ((option.state & QStyle::State_HasFocus)) {
+ // show either the GPS location of the currently focused dive site or
+ // the gps data for the displayed dive site (even if that has no GPS -> zoom out)
+ if (dive_site_has_gps_location(ds))
+ MainWindow::instance()->globe()->centerOnDiveSite(ds);
+ else
+ MainWindow::instance()->globe()->centerOnDiveSite(&displayed_dive_site);
}
#endif