planner: split addStop() into external and internal versions

The DivePlannerPointsModel::addStop() function is called by
the profile to add a planner-stop. It is also used internally
to create profiles.

If we ever want to include this in the undo system, we have
to split these into to versions. One will ultimately place
an undo command and update the profile, the other one doesn't.

For now, this makes the external interface simpler, as some
parameters are redundant.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-02-27 19:42:42 +01:00 committed by Dirk Hohndel
parent 71e117669d
commit 337d9318ad
3 changed files with 9 additions and 3 deletions

View file

@ -997,14 +997,14 @@ void ProfileWidget2::mouseDoubleClickEvent(QMouseEvent *event)
int minutes = lrint(timeAxis->valueAt(mappedPos) / 60); int minutes = lrint(timeAxis->valueAt(mappedPos) / 60);
int milimeters = lrint(profileYAxis->valueAt(mappedPos) / M_OR_FT(1, 1)) * M_OR_FT(1, 1); int milimeters = lrint(profileYAxis->valueAt(mappedPos) / M_OR_FT(1, 1)) * M_OR_FT(1, 1);
plannerModel->addStop(milimeters, minutes * 60, -1, 0, true, UNDEF_COMP_TYPE); plannerModel->addStop(milimeters, minutes * 60);
} }
} }
void ProfileWidget2::scrollViewTo(const QPoint &pos) void ProfileWidget2::scrollViewTo(const QPoint &pos)
{ {
/* since we cannot use translate() directly on the scene we hack on /* since we cannot use translate() directly on the scene we hack on
* the scroll bars (hidden) functionality */ * the scroll bars (hidden) functionality */
if (!zoomLevel || currentState == EMPTY) if (!zoomLevel || currentState == EMPTY)
return; return;
QScrollBar *vs = verticalScrollBar(); QScrollBar *vs = verticalScrollBar();

View file

@ -750,6 +750,11 @@ void DivePlannerPointsModel::addDefaultStop()
addStop(0, 0, -1, 0, true, UNDEF_COMP_TYPE); addStop(0, 0, -1, 0, true, UNDEF_COMP_TYPE);
} }
void DivePlannerPointsModel::addStop(int milimeters, int seconds)
{
addStop(milimeters, seconds, -1, 0, true, UNDEF_COMP_TYPE);
}
// cylinderid_in == -1 means same gas as before. // cylinderid_in == -1 means same gas as before.
// divemode == UNDEF_COMP_TYPE means determine from previous point. // divemode == UNDEF_COMP_TYPE means determine from previous point.
int DivePlannerPointsModel::addStop(int milimeters, int seconds, int cylinderid_in, int ccpoint, bool entered, enum divemode_t divemode) int DivePlannerPointsModel::addStop(int milimeters, int seconds, int cylinderid_in, int ccpoint, bool entered, enum divemode_t divemode)

View file

@ -61,7 +61,7 @@ public:
struct deco_state final_deco_state; struct deco_state final_deco_state;
void loadFromDive(dive *d); void loadFromDive(dive *d);
int addStop(int millimeters, int seconds, int cylinderid_in, int ccpoint, bool entered, enum divemode_t); void addStop(int millimeters, int seconds);
public public
slots: slots:
void addDefaultStop(); void addDefaultStop();
@ -117,6 +117,7 @@ signals:
private: private:
explicit DivePlannerPointsModel(QObject *parent = 0); explicit DivePlannerPointsModel(QObject *parent = 0);
void clear(); void clear();
int addStop(int millimeters, int seconds, int cylinderid_in, int ccpoint, bool entered, enum divemode_t);
void setupStartTime(); void setupStartTime();
void setupCylinders(); void setupCylinders();
int lastEnteredPoint() const; int lastEnteredPoint() const;