QML UI: on edit only request location if user checks the box

The code inexplicably always checked for a gps location. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-01-27 06:29:14 -08:00
parent a74175324a
commit 4abe73ff2a

View file

@ -374,25 +374,27 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
ds = get_dive_site_by_uuid(create_dive_site(qPrintable(location), d->when)); ds = get_dive_site_by_uuid(create_dive_site(qPrintable(location), d->when));
d->dive_site_uuid = ds->uuid; d->dive_site_uuid = ds->uuid;
} }
QString gpsString = getCurrentPosition(); if (!gps.isEmpty()) {
if (gpsString != QString("waiting for the next gps location")) { QString gpsString = getCurrentPosition();
qDebug() << "from commitChanges call to getCurrentPosition returns" << gpsString; if (gpsString != QString("waiting for the next gps location")) {
double lat, lon; qDebug() << "from commitChanges call to getCurrentPosition returns" << gpsString;
if (parseGpsText(qPrintable(gpsString), &lat, &lon)) { double lat, lon;
struct dive_site *ds = get_dive_site_by_uuid(d->dive_site_uuid); if (parseGpsText(qPrintable(gpsString), &lat, &lon)) {
if (ds) { struct dive_site *ds = get_dive_site_by_uuid(d->dive_site_uuid);
ds->latitude.udeg = lat * 1000000; if (ds) {
ds->longitude.udeg = lon * 1000000; ds->latitude.udeg = lat * 1000000;
} else { ds->longitude.udeg = lon * 1000000;
degrees_t latData, lonData; } else {
latData.udeg = lat; degrees_t latData, lonData;
lonData.udeg = lon; latData.udeg = lat;
d->dive_site_uuid = create_dive_site_with_gps("new site", latData, lonData, d->when); lonData.udeg = lon;
d->dive_site_uuid = create_dive_site_with_gps("new site", latData, lonData, d->when);
}
qDebug() << "set up dive site with new GPS data";
} }
qDebug() << "set up dive site with new GPS data"; } else {
qDebug() << "still don't have a position - will need to implement some sort of callback";
} }
} else {
qDebug() << "still don't have a position - will need to implement some sort of callback";
} }
if (get_dive_duration_string(d->duration.seconds, tr("h:"), tr("min")) != duration) { if (get_dive_duration_string(d->duration.seconds, tr("h:"), tr("min")) != duration) {
diveChanged = true; diveChanged = true;