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

@ -39,7 +39,7 @@ public:
void removeSelectedPoints(const QVector<int> &rows);
void setPlanMode(Mode mode);
bool isPlanner() const;
void createSimpleDive();
void createSimpleDive(struct dive *d);
Mode currentMode() const;
bool setRecalc(bool recalc);
bool recalcQ() const;
@ -130,6 +130,7 @@ private:
void computeVariations(struct diveplan *diveplan, const struct deco_state *ds);
void computeVariationsFreeDeco(struct diveplan *diveplan, struct deco_state *ds);
int analyzeVariations(struct decostop *min, struct decostop *mid, struct decostop *max, const char *unit);
struct dive *d;
CylindersModel cylinders;
Mode mode;
bool recalc;