mobile: properly recognize changed dive site

QMLManager::checkLocation() would only return true if the
dive-site itself was changed, not if the dive-site was set
to a different site.

Thus, in some cases edit events could be lost.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-04-04 22:13:18 +02:00 committed by Dirk Hohndel
parent e43362fdcf
commit 4cdea48926

View file

@ -915,6 +915,7 @@ parsed:
bool QMLManager::checkLocation(DiveSiteChange &res, const DiveObjectHelper &myDive, struct dive *d, QString location, QString gps) bool QMLManager::checkLocation(DiveSiteChange &res, const DiveObjectHelper &myDive, struct dive *d, QString location, QString gps)
{ {
struct dive_site *ds = get_dive_site_for_dive(d); struct dive_site *ds = get_dive_site_for_dive(d);
bool changed = false;
qDebug() << "checkLocation" << location << "gps" << gps << "dive had" << myDive.location << "gps" << myDive.gas; qDebug() << "checkLocation" << location << "gps" << gps << "dive had" << myDive.location << "gps" << myDive.gas;
if (myDive.location != location) { if (myDive.location != location) {
ds = get_dive_site_by_name(qPrintable(location), &dive_site_table); ds = get_dive_site_by_name(qPrintable(location), &dive_site_table);
@ -924,6 +925,7 @@ bool QMLManager::checkLocation(DiveSiteChange &res, const DiveObjectHelper &myDi
ds = res.createdDs.get(); ds = res.createdDs.get();
} }
d->dive_site = ds; d->dive_site = ds;
changed = true;
} }
// now make sure that the GPS coordinates match - if the user changed the name but not // now make sure that the GPS coordinates match - if the user changed the name but not
// the GPS coordinates, this still does the right thing as the now new dive site will // the GPS coordinates, this still does the right thing as the now new dive site will
@ -950,7 +952,7 @@ bool QMLManager::checkLocation(DiveSiteChange &res, const DiveObjectHelper &myDi
appendTextToLog(QString("wasn't able to parse gps string '%1'").arg(gps)); appendTextToLog(QString("wasn't able to parse gps string '%1'").arg(gps));
} }
} }
return res.changed; return changed | res.changed;
} }
bool QMLManager::checkDuration(const DiveObjectHelper &myDive, struct dive *d, QString duration) bool QMLManager::checkDuration(const DiveObjectHelper &myDive, struct dive *d, QString duration)