From 0847447cda75a0d932b682e08ffd0ef73affb046 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 30 Sep 2015 19:29:03 -0300 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 8857e3b4f..a70f3901e 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -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; -- cgit v1.2.3-70-g09d2