Always send the UUID of the coordinates to the globe

We were relying in the current_dive to display the
globe coordinates correctly - but this is not always
the case: you can be inserting a new dive site and it
isn't yet inside of the dive until the user presses
accept. So always pass the uuid of the dive site that
we want to display.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-06-05 10:52:52 -03:00 committed by Dirk Hohndel
parent 218ad95d7d
commit 6b81fb49d0
6 changed files with 20 additions and 19 deletions

View file

@ -235,25 +235,21 @@ void GlobeGPS::reload()
repopulateLabels();
}
void GlobeGPS::centerOnCurrentDive()
void GlobeGPS::centerOnDiveSite(uint32_t uuid)
{
struct dive_site *ds = get_dive_site_for_dive(current_dive);
// dive has changed, if we had the 'editingDive', hide it.
if (messageWidget->isVisible() && (!ds || dive_site_has_gps_location(ds) || amount_selected != 1))
messageWidget->hide();
editingDiveLocation = false;
if (!ds)
if (uuid == 0)
return;
qreal longitude = ds->longitude.udeg / 1000000.0;
qreal latitude = ds->latitude.udeg / 1000000.0;
struct dive_site *ds = get_dive_site_by_uuid(uuid);
if (!dive_site_has_gps_location(ds)) {
zoomOutForNoGPS();
return;
}
qreal longitude = ds->longitude.udeg / 1000000.0;
qreal latitude = ds->latitude.udeg / 1000000.0;
// if no zoom is set up, set the zoom as seen from 3km above
// if we come back from a dive without GPS data, reset to the last zoom value
// otherwise check to make sure we aren't still running an animation and then remember

View file

@ -2,6 +2,7 @@
#define GLOBE_H
#ifndef NO_MARBLE
#include <stdint.h>
#include <marble/MarbleWidget.h>
#include <marble/GeoDataCoordinates.h>
@ -49,7 +50,7 @@ slots:
void zoomOutForNoGPS();
void prepareForGetDiveCoordinates();
void endGetDiveCoordinates();
void centerOnCurrentDive();
void centerOnDiveSite(uint32_t uuid);
};
#else // NO_MARBLE
@ -62,7 +63,7 @@ public:
GlobeGPS(QWidget *parent);
void reload();
void repopulateLabels();
void centerOnCurrentDive();
void centerOnDiveSite(uint32_t uuid);
bool eventFilter(QObject *, QEvent *);
public
slots:

View file

@ -701,7 +701,8 @@ void MainTab::updateDiveInfo(bool clear)
ui.cylinders->view()->hideColumn(CylindersModel::USE);
ui.location->blockSignals(false);
emit diveSiteChanged();
emit diveSiteChanged(displayed_dive.dive_site_uuid);
}
void MainTab::addCylinder_clicked()
@ -997,7 +998,7 @@ void MainTab::rejectChanges()
DivePictureModel::instance()->updateDivePictures();
// the user could have edited the location and then canceled the edit
// let's get the correct location back in view
MainWindow::instance()->globe()->centerOnCurrentDive();
MainWindow::instance()->globe()->centerOnDiveSite(displayed_dive.dive_site_uuid);
MainWindow::instance()->globe()->reload();
// show the profile and dive info
MainWindow::instance()->graphics()->replot();
@ -1280,9 +1281,12 @@ void MainTab::on_location_currentIndexChanged(int idx)
struct dive_site *ds_from_dive = get_dive_site_by_uuid(displayed_dive.dive_site_uuid);
if(ds_from_dive && ui.location->currentText() == ds_from_dive->name)
return;
displayed_dive.dive_site_uuid = get_dive_site(idx)->uuid;
ds_from_dive = get_dive_site(idx);
displayed_dive.dive_site_uuid = ds_from_dive->uuid;
markChangedWidget(ui.location);
emit diveSiteChanged();
emit diveSiteChanged(ds_from_dive->uuid);
}
}

View file

@ -57,7 +57,7 @@ signals:
void addDiveFinished();
void dateTimeChanged();
void requestDiveSiteAdd();
void diveSiteChanged();
void diveSiteChanged(uint32_t uuid);
public
slots:
void addCylinder_clicked();

View file

@ -146,7 +146,7 @@ MainWindow::MainWindow() : QMainWindow(),
connect(globeGps, SIGNAL(coordinatesChanged()), locationInformation, SLOT(updateGpsCoordinates()));
connect(locationInformation, SIGNAL(startEditDiveSite(uint32_t)), globeGps, SLOT(prepareForGetDiveCoordinates()));
connect(locationInformation, SIGNAL(endEditDiveSite()), globeGps, SLOT(prepareForGetDiveCoordinates()));
connect(information(), SIGNAL(diveSiteChanged()), globeGps, SLOT(centerOnCurrentDive()));
connect(information(), SIGNAL(diveSiteChanged(uint32_t)), globeGps, SLOT(centerOnDiveSite(uint32_t)));
#ifdef NO_PRINTING
plannerDetails->printPlan()->hide();

View file

@ -347,7 +347,7 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button)
if (merge_locations_into_dives()) {
mark_divelist_changed(true);
MainWindow::instance()->globe()->repopulateLabels();
MainWindow::instance()->globe()->centerOnCurrentDive();
MainWindow::instance()->globe()->centerOnDiveSite(current_dive->dive_site_uuid);
MainWindow::instance()->information()->updateDiveInfo();
}