mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: connect to DivePointsPlannerModel in separate function
The connection to the DivePointsPlannerModel was done in two distinct functions: setAddState() and setPlanState(), which means that these could easily get out-of-sync. Factor this out into a single function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
dee1fea683
commit
94633d2156
2 changed files with 16 additions and 14 deletions
|
@ -1264,6 +1264,17 @@ void ProfileWidget2::setToolTipVisibile(bool visible)
|
||||||
toolTipItem->setVisible(visible);
|
toolTipItem->setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProfileWidget2::connectPlannerModel()
|
||||||
|
{
|
||||||
|
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
||||||
|
connect(plannerModel, &DivePlannerPointsModel::dataChanged, this, &ProfileWidget2::replot);
|
||||||
|
connect(plannerModel, &DivePlannerPointsModel::cylinderModelEdited, this, &ProfileWidget2::replot);
|
||||||
|
connect(plannerModel, &DivePlannerPointsModel::modelReset, this, &ProfileWidget2::pointsReset);
|
||||||
|
connect(plannerModel, &DivePlannerPointsModel::rowsInserted, this, &ProfileWidget2::pointInserted);
|
||||||
|
connect(plannerModel, &DivePlannerPointsModel::rowsRemoved, this, &ProfileWidget2::pointsRemoved);
|
||||||
|
connect(plannerModel, &DivePlannerPointsModel::rowsMoved, this, &ProfileWidget2::pointsMoved);
|
||||||
|
}
|
||||||
|
|
||||||
void ProfileWidget2::setAddState()
|
void ProfileWidget2::setAddState()
|
||||||
{
|
{
|
||||||
if (currentState == ADD)
|
if (currentState == ADD)
|
||||||
|
@ -1283,13 +1294,8 @@ void ProfileWidget2::setAddState()
|
||||||
actionsForKeys[Qt::Key_Escape]->setShortcut(Qt::Key_Escape);
|
actionsForKeys[Qt::Key_Escape]->setShortcut(Qt::Key_Escape);
|
||||||
actionsForKeys[Qt::Key_Delete]->setShortcut(Qt::Key_Delete);
|
actionsForKeys[Qt::Key_Delete]->setShortcut(Qt::Key_Delete);
|
||||||
|
|
||||||
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
connectPlannerModel();
|
||||||
connect(plannerModel, &DivePlannerPointsModel::dataChanged, this, &ProfileWidget2::replot);
|
|
||||||
connect(plannerModel, &DivePlannerPointsModel::cylinderModelEdited, this, &ProfileWidget2::replot);
|
|
||||||
connect(plannerModel, &DivePlannerPointsModel::modelReset, this, &ProfileWidget2::pointsReset);
|
|
||||||
connect(plannerModel, &DivePlannerPointsModel::rowsInserted, this, &ProfileWidget2::pointInserted);
|
|
||||||
connect(plannerModel, &DivePlannerPointsModel::rowsRemoved, this, &ProfileWidget2::pointsRemoved);
|
|
||||||
connect(plannerModel, &DivePlannerPointsModel::rowsMoved, this, &ProfileWidget2::pointsMoved);
|
|
||||||
/* show the same stuff that the profile shows. */
|
/* show the same stuff that the profile shows. */
|
||||||
currentState = ADD; /* enable the add state. */
|
currentState = ADD; /* enable the add state. */
|
||||||
diveCeiling->setVisible(true);
|
diveCeiling->setVisible(true);
|
||||||
|
@ -1316,13 +1322,8 @@ void ProfileWidget2::setPlanState()
|
||||||
actionsForKeys[Qt::Key_Escape]->setShortcut(Qt::Key_Escape);
|
actionsForKeys[Qt::Key_Escape]->setShortcut(Qt::Key_Escape);
|
||||||
actionsForKeys[Qt::Key_Delete]->setShortcut(Qt::Key_Delete);
|
actionsForKeys[Qt::Key_Delete]->setShortcut(Qt::Key_Delete);
|
||||||
|
|
||||||
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
connectPlannerModel();
|
||||||
connect(plannerModel, &DivePlannerPointsModel::dataChanged, this, &ProfileWidget2::replot);
|
|
||||||
connect(plannerModel, &DivePlannerPointsModel::cylinderModelEdited, this, &ProfileWidget2::replot);
|
|
||||||
connect(plannerModel, &DivePlannerPointsModel::modelReset, this, &ProfileWidget2::pointsReset);
|
|
||||||
connect(plannerModel, &DivePlannerPointsModel::rowsInserted, this, &ProfileWidget2::pointInserted);
|
|
||||||
connect(plannerModel, &DivePlannerPointsModel::rowsRemoved, this, &ProfileWidget2::pointsRemoved);
|
|
||||||
connect(plannerModel, &DivePlannerPointsModel::rowsMoved, this, &ProfileWidget2::pointsMoved);
|
|
||||||
/* show the same stuff that the profile shows. */
|
/* show the same stuff that the profile shows. */
|
||||||
currentState = PLAN; /* enable the add state. */
|
currentState = PLAN; /* enable the add state. */
|
||||||
diveCeiling->setVisible(true);
|
diveCeiling->setVisible(true);
|
||||||
|
|
|
@ -256,6 +256,7 @@ private:
|
||||||
std::vector<std::unique_ptr<DiveHandler>> handles;
|
std::vector<std::unique_ptr<DiveHandler>> handles;
|
||||||
int handleIndex(const DiveHandler *h) const;
|
int handleIndex(const DiveHandler *h) const;
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
|
void connectPlannerModel();
|
||||||
void repositionDiveHandlers();
|
void repositionDiveHandlers();
|
||||||
int fixHandlerIndex(DiveHandler *activeHandler);
|
int fixHandlerIndex(DiveHandler *activeHandler);
|
||||||
DiveHandler *createHandle();
|
DiveHandler *createHandle();
|
||||||
|
|
Loading…
Add table
Reference in a new issue