summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-07-19 19:26:59 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-11 16:22:27 -0700
commit61467ea0d59b04f141a68452ee16c70760421d72 (patch)
tree6232d18a2c513bac988bbcb7ec262d0e96ed15a0 /desktop-widgets
parent403dd5a8918d4acab33cdd0a400570003244ca5e (diff)
downloadsubsurface-61467ea0d59b04f141a68452ee16c70760421d72.tar.gz
Cleanup: let MainTab::updateDiveSite() take dive * instead of id
Both callers have a dive * and transform that into an id, the callee transforms it right back to the dive *. Simply pass the dive directly. This will allow us to use the function for dives that have not yet been added. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp19
-rw-r--r--desktop-widgets/tab-widgets/maintab.h2
2 files changed, 9 insertions, 12 deletions
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index b6ac56ed7..766d32414 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -714,10 +714,9 @@ void MainTab::refreshDisplayedDiveSite()
// 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
-uint32_t MainTab::updateDiveSite(uint32_t pickedUuid, int divenr)
+uint32_t MainTab::updateDiveSite(uint32_t pickedUuid, dive *d)
{
- struct dive *cd = get_dive(divenr);
- if (!cd)
+ if (!d)
return 0;
if (ui.location->text().isEmpty())
@@ -726,7 +725,7 @@ uint32_t MainTab::updateDiveSite(uint32_t pickedUuid, int divenr)
if (pickedUuid == 0)
return 0;
- const uint32_t origUuid = cd->dive_site_uuid;
+ const uint32_t origUuid = d->dive_site_uuid;
struct dive_site *origDs = get_dive_site_by_uuid(origUuid);
struct dive_site *newDs = NULL;
bool createdNewDive = false;
@@ -767,7 +766,7 @@ uint32_t MainTab::updateDiveSite(uint32_t pickedUuid, int divenr)
}
}
- cd->dive_site_uuid = pickedUuid;
+ d->dive_site_uuid = pickedUuid;
qDebug() << "Setting the dive site id on the dive:" << pickedUuid;
return pickedUuid;
}
@@ -795,7 +794,7 @@ void MainTab::acceptChanges()
record_dive(added_dive);
addedId = added_dive->id;
// make sure that the dive site is handled as well
- updateDiveSite(ui.location->currDiveSiteUuid(), get_idx_by_uniq_id(added_dive->id));
+ updateDiveSite(ui.location->currDiveSiteUuid(), added_dive);
// 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
@@ -840,9 +839,8 @@ void MainTab::acceptChanges()
MODIFY_SELECTED_DIVES(EDIT_VALUE(airtemp.mkelvin));
if (displayed_dc->divemode != current_dc->divemode) {
MODIFY_SELECTED_DIVES(
- if (get_dive_dc(mydive, dc_number)->divemode == current_dc->divemode || copyPaste) {
+ if (get_dive_dc(mydive, dc_number)->divemode == current_dc->divemode || copyPaste)
get_dive_dc(mydive, dc_number)->divemode = displayed_dc->divemode;
- }
);
MODIFY_SELECTED_DIVES(update_setpoint_events(mydive, get_dive_dc(mydive, dc_number)));
do_replot = true;
@@ -926,9 +924,8 @@ void MainTab::acceptChanges()
uint32_t oldUuid = cd->dive_site_uuid;
uint32_t newUuid = 0;
MODIFY_SELECTED_DIVES(
- 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 (mydive->dive_site_uuid == current_dive->dive_site_uuid)
+ newUuid = updateDiveSite(newUuid == 0 ? ui.location->currDiveSiteUuid() : newUuid, mydive);
);
if (!is_dive_site_used(oldUuid, false)) {
if (verbose) {
diff --git a/desktop-widgets/tab-widgets/maintab.h b/desktop-widgets/tab-widgets/maintab.h
index 238c060f8..d56661e77 100644
--- a/desktop-widgets/tab-widgets/maintab.h
+++ b/desktop-widgets/tab-widgets/maintab.h
@@ -125,7 +125,7 @@ private:
dive_trip_t *currentTrip;
dive_trip_t displayedTrip;
bool acceptingEdit;
- uint32_t updateDiveSite(uint32_t pickedUuid, int divenr);
+ uint32_t updateDiveSite(uint32_t pickedUuid, dive *d);
QList<TabBase*> extraWidgets;
};