From 829e816e2b1e464e5635e6c396cc001fb7ccf537 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 16 Jul 2015 12:42:39 -0700 Subject: 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 --- qt-ui/modeldelegates.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'qt-ui/modeldelegates.cpp') 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 -- cgit v1.2.3-70-g09d2