diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-09-30 19:58:38 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-09-30 19:28:55 -0400 |
commit | cbf02ac7abddf5c0f8ff5ed8464a9adf2bd0652e (patch) | |
tree | 1fa369e12026ae8bbb9ae211bff3d4a88e4c1409 | |
parent | 63a2307cfb586ba555f6592897fa940ca7f0498a (diff) | |
download | subsurface-cbf02ac7abddf5c0f8ff5ed8464a9adf2bd0652e.tar.gz |
Fix multi-dive edit regarding Dive Sites
Now it correctly sets the same dive site instead of
creating a new one for each dive.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/maintab.cpp | 20 | ||||
-rw-r--r-- | qt-ui/maintab.h | 2 |
2 files changed, 12 insertions, 10 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index a70f3901e..a1923850f 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -856,28 +856,27 @@ void MainTab::updateDisplayedDiveSite() // when this is called we already have updated the current_dive and know that it exists // there is no point in calling this function if there is no current dive -void MainTab::updateDiveSite(int divenr) +uint32_t MainTab::updateDiveSite(uint32_t pickedUuid, int divenr) { qDebug() << "accepting the change and updating the actual dive site data"; struct dive *cd = get_dive(divenr); if (!cd) - return; + return 0; if (ui.location->text().isEmpty()) { qDebug() << "No location data set, not updating the dive site."; - return; + return 0; } - uint32_t pickedUuid = ui.location->currDiveSiteUuid(); if (pickedUuid == 0) - return; + return 0; const uint32_t origUuid = cd->dive_site_uuid; struct dive_site *origDs = get_dive_site_by_uuid(origUuid); struct dive_site *newDs = NULL; if (pickedUuid == origUuid) { - return; + return origUuid; } if (pickedUuid == RECENTLY_ADDED_DIVESITE) { @@ -905,6 +904,7 @@ void MainTab::updateDiveSite(int divenr) cd->dive_site_uuid = pickedUuid; qDebug() << "Setting the dive site id on the dive:" << pickedUuid; + return pickedUuid; } void MainTab::acceptChanges() @@ -930,7 +930,7 @@ void MainTab::acceptChanges() record_dive(added_dive); addedId = added_dive->id; // make sure that the dive site is handled as well - updateDiveSite(get_idx_by_uniq_id(added_dive->id)); + updateDiveSite(ui.location->currDiveSiteUuid(), get_idx_by_uniq_id(added_dive->id)); // unselect everything as far as the UI is concerned and select the new // dive - we'll have to undo/redo this later after we resort the dive_table @@ -1055,9 +1055,11 @@ void MainTab::acceptChanges() // update the dive site for the selected dives that had the same dive site as the current dive uint32_t oldUuid = cd->dive_site_uuid; + uint32_t newUuid = 0; MODIFY_SELECTED_DIVES( - if (mydive->dive_site_uuid == current_dive->dive_site_uuid) - updateDiveSite(get_idx_by_uniq_id(mydive->id)); + if (mydive->dive_site_uuid == current_dive->dive_site_uuid) { + newUuid = updateDiveSite(newUuid == 0 ? ui.location->currDiveSiteUuid() : newUuid, get_idx_by_uniq_id(mydive->id)); + } ); if (!is_dive_site_used(oldUuid, false)) { if (verbose) { diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 502ea6910..1fffc2194 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -123,7 +123,7 @@ private: dive_trip_t displayedTrip; bool acceptingEdit; void updateDisplayedDiveSite(); - void updateDiveSite(int divenr); + uint32_t updateDiveSite(uint32_t pickedUuid, int divenr); }; #endif // MAINTAB_H |