diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-07-15 21:26:33 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-07-15 21:27:49 -0700 |
commit | 874d3c4799a65062ca60518199f877341301e1a1 (patch) | |
tree | 9beda564f28a4eb014ae8a07a8cd2e007c9a5b4d /qt-ui/maintab.cpp | |
parent | 1dbb6071bd0826790e8afb5be1020f42e257681b (diff) | |
download | subsurface-874d3c4799a65062ca60518199f877341301e1a1.tar.gz |
Dive site handling: special case for auto generated dives
When we download GPS data from the webservice we can end up with dive
sites that are simply a place holder for the the GPS fix. If we replace
the name of one of those sites we should just delete the site (assuming it
isn't used in another dive, which is unlikely but theoretically possible).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r-- | qt-ui/maintab.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index e9da1a53a..9b4166b35 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -815,18 +815,6 @@ void MainTab::updateDisplayedDiveSite() qDebug() << "Updating Displayed Dive Site"; -#if 0 - // this code is special casing for divesites that were downloaded from the webservice - if(current_dive) { - struct dive_site *ds_from_dive = get_dive_site_by_uuid(current_dive->dive_site_uuid); - if (!dive_site_has_gps_location(ds_from_dive) && - same_string(displayed_dive_site.notes, "SubsurfaceWebservice")) { - ds_from_dive->latitude = displayed_dive_site.latitude; - ds_from_dive->longitude = displayed_dive_site.longitude; - delete_dive_site(displayed_dive_site.uuid); - } - } -#endif if(orig_uuid) { if (new_uuid && orig_uuid != new_uuid) { // the user picked a different site @@ -908,6 +896,16 @@ void MainTab::updateDiveSite(int divenr) newDs->uuid = createdUuid; // the copy overwrote the uuid cd->dive_site_uuid = createdUuid; qDebug() << "create a new dive site with name" << newName << "which is now named" << newDs->name << "and assign it as uuid" << createdUuid; + qDebug() << "original dive had site" << origUuid << "and" << (origDs ? QString("notes %1").arg(origDs->notes) : QString("no dive site")); + if (origDs && same_string(origDs->notes, "SubsurfaceWebservice")) { + // this is a special case - let's remove the original dive site if this was the only user + if (!is_dive_site_used(origDs->uuid, false)) { + qDebug() << "delete the autogenerated dive site" << origDs->name; + delete_dive_site(origDs->uuid); + free(newDs->notes); + newDs->notes = NULL; + } + } } else { qDebug() << "switched to dive site" << newName << "uuid" << newUuid << "for current dive"; cd->dive_site_uuid = newUuid; |