From 45392615cdd926fe3220c616f2f91d1295ae5c44 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 16 Jul 2015 10:43:37 -0700 Subject: Dive edit: handle dive sites more sanely while editing While we edit things, displayed_dive_site is the authoratative source of data that should be displayed. Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index c9a606dd3..9b40d31fd 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -494,7 +494,17 @@ void MainTab::updateDiveInfo(bool clear) ui.DiveType->setCurrentIndex(get_dive_dc(&displayed_dive, dc_number)->divemode); if (!clear) { - struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); + struct dive_site *ds = NULL; + // if we are showing a dive and editing it, let's refer to the displayed_dive_site as that + // already may contain changes, otherwise start with the dive site referred to by the displayed + // dive + if (rememberEM == DIVE) { + ds = &displayed_dive_site; + } else { + ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); + if (ds) + copy_dive_site(ds, &displayed_dive_site); + } ui.geocodeButton->setVisible(ds && dive_site_has_gps_location(ds)); if (ds) { // construct the location tags @@ -520,8 +530,6 @@ void MainTab::updateDiveInfo(bool clear) } ui.location->setText(ds->name); ui.locationTags->setText(locationTag); - if (displayed_dive.dive_site_uuid) - copy_dive_site(get_dive_site_by_uuid(displayed_dive.dive_site_uuid), &displayed_dive_site); } else { ui.location->clear(); clear_dive_site(&displayed_dive_site); -- cgit v1.2.3-70-g09d2