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>
This commit is contained in:
Dirk Hohndel 2015-07-16 12:42:39 -07:00
parent 076f86202a
commit 829e816e2b

View file

@ -507,6 +507,13 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
if (index.row() < 2) { if (index.row() < 2) {
diveSiteName = index.data().toString(); diveSiteName = index.data().toString();
bottomText = index.data(Qt::ToolTipRole).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; goto print_part;
} }
@ -531,9 +538,13 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
} }
#ifndef NO_MARBLE #ifndef NO_MARBLE
if ((option.state & QStyle::State_HasFocus) && dive_site_has_gps_location(ds)) { if ((option.state & QStyle::State_HasFocus)) {
qDebug() << "center on" << ds->name; // 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); MainWindow::instance()->globe()->centerOnDiveSite(ds);
else
MainWindow::instance()->globe()->centerOnDiveSite(&displayed_dive_site);
} }
#endif #endif