planner: remove displayed_dive from DivePlannerModel

To remove global state, make the dive that DivePlannerModel
works on a member variable. Pass the dive in createSimpleDive()
and loadFromDive(). Moreover, this should pave the way to more
fine-grained undo in the planner. Ultimately, the planner
should not be modal.

Attention: for now, the dive must still be displayed_dive,
because of the convoluted way in which the profile and the
planner work on the same dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-01-26 07:48:22 +01:00 committed by Dirk Hohndel
parent e419ebf55a
commit 1ec0790d50
4 changed files with 72 additions and 63 deletions

View file

@ -1514,10 +1514,11 @@ void MainWindow::editCurrentDive()
return;
disableShortcuts();
copy_dive(current_dive, &displayed_dive); // Work on a copy of the dive
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD);
graphics->setAddState();
setApplicationState(ApplicationState::EditDive);
DivePlannerPointsModel::instance()->loadFromDive(current_dive);
DivePlannerPointsModel::instance()->loadFromDive(&displayed_dive);
mainTab->enableEdition();
}