Make 'Choose dive site' work as 'Rename'

But it will actually create a new dive site, not just rename the existing
one.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-09-30 19:29:03 -03:00 committed by Dirk Hohndel
parent 2794af4166
commit 0847447cda

View file

@ -885,13 +885,17 @@ void MainTab::updateDiveSite(int divenr)
}
newDs = get_dive_site_by_uuid(pickedUuid);
copy_dive_site(newDs, &displayed_dive_site);
// Copy everything from the displayed_dive_site, so we have the latitude, longitude, notes, etc.
// The user *might* be using wrongly the 'choose dive site' just to edit the name of it, sigh.
if(origDs) {
copy_dive_site(origDs, newDs);
free(newDs->name);
newDs->name = copy_string(qPrintable(ui.location->text().constData()));
newDs->uuid = pickedUuid;
}
if (origDs && pickedUuid != origDs->uuid && same_string(origDs->notes, "SubsurfaceWebservice")) {
// this is a special case - let's keep the GPS data and
// remove the original dive site if this was the only user
newDs->latitude.udeg = origDs->latitude.udeg;
newDs->longitude.udeg = origDs->longitude.udeg;
if (!is_dive_site_used(origDs->uuid, false)) {
if (verbose)
qDebug() << "delete the autogenerated dive site" << origDs->name;