Planner: Fix Editing of Plans in Multi-Divecomputer Dives.

Currently editing of planned dives that have been merged with actual
(logged) dives only works if the 'Planned dive' divecomputer is the
first divecomputer, and this divecomputer is selected when clicking
'Edit planned dive'. In other cases the profile of the first
divecomputer is overlaid with the profile of the planned dive, and the
first divecomputer's profile is overwritten when saving the dive plan.
Fix this problem.

Triggered by @SeppoTakalo's comment (https://github.com/subsurface/subsurface/issues/1913#issuecomment-2075562119): Users don't like that planned dives show up as their own entries in the dive list, so being able to merge them with the actual dive after it has been executed is a good feature - but this wasn't working well until now.

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2024-04-26 08:16:08 +12:00
parent a83349015a
commit 528532572f
11 changed files with 114 additions and 106 deletions

View file

@ -157,11 +157,11 @@ void ProfileWidget::setEnabledToolbar(bool enabled)
b->setEnabled(enabled);
}
void ProfileWidget::setDive(const struct dive *d)
void ProfileWidget::setDive(const struct dive *d, int dcNr)
{
stack->setCurrentIndex(1); // show profile
bool freeDiveMode = d->dc.divemode == FREEDIVE;
bool freeDiveMode = get_dive_dc_const(d, dcNr)->divemode == FREEDIVE;
ui.profCalcCeiling->setDisabled(freeDiveMode);
ui.profCalcCeiling->setDisabled(freeDiveMode);
ui.profCalcAllTissues ->setDisabled(freeDiveMode);
@ -217,12 +217,12 @@ void ProfileWidget::plotDive(dive *dIn, int dcIn)
setEnabledToolbar(d != nullptr);
if (editedDive) {
view->plotDive(editedDive.get(), editedDc);
setDive(editedDive.get());
setDive(editedDive.get(), dc);
} else if (d) {
view->setProfileState(d, dc);
view->resetZoom(); // when switching dive, reset the zoomLevel
view->plotDive(d, dc);
setDive(d);
setDive(d, dc);
} else {
view->clear();
stack->setCurrentIndex(0);
@ -274,11 +274,12 @@ void ProfileWidget::divesChanged(const QVector<dive *> &dives, DiveField field)
plotCurrentDive();
}
void ProfileWidget::setPlanState(const struct dive *d, int dc)
void ProfileWidget::setPlanState(const struct dive *d, int dcNr)
{
exitEditMode();
view->setPlanState(d, dc);
setDive(d);
dc = dcNr;
view->setPlanState(d, dcNr);
setDive(d, dcNr);
}
void ProfileWidget::unsetProfHR()