profile: remove redundant replot() calls in key events

When moving "dive handlers" with the cursor keys, the
profile was replot twice:

- First the recalculation of the planner model was suspended.
- The "stop" was moved.
- This led to a replot by a signal from the planner model.
  However, the old profile was shown, since the recalculation
  was suspended.
- The recalculation was reenabled.
- The profile war replot, resulting now in the correct profile.

A classical case of bit rot.

Instead, don't suspend calculation in the first place. This
shows the correct profile on the first replot and the second
replot can be removed.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-02-23 20:11:44 +01:00 committed by Dirk Hohndel
parent a3d8191896
commit 457be51ff6

View file

@ -1813,8 +1813,6 @@ void ProfileWidget2::keyDownAction()
if ((currentState != ADD && currentState != PLAN) || !plannerModel)
return;
bool oldRecalc = plannerModel->setRecalc(false);
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
int row = handleIndex(handler);
@ -1824,8 +1822,6 @@ void ProfileWidget2::keyDownAction()
plannerModel->editStop(row, dp);
}
}
plannerModel->setRecalc(oldRecalc);
replot();
}
void ProfileWidget2::keyUpAction()
@ -1833,7 +1829,6 @@ void ProfileWidget2::keyUpAction()
if ((currentState != ADD && currentState != PLAN) || !plannerModel)
return;
bool oldRecalc = plannerModel->setRecalc(false);
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
int row = handleIndex(handler);
@ -1846,8 +1841,6 @@ void ProfileWidget2::keyUpAction()
plannerModel->editStop(row, dp);
}
}
plannerModel->setRecalc(oldRecalc);
replot();
}
void ProfileWidget2::keyLeftAction()
@ -1855,7 +1848,6 @@ void ProfileWidget2::keyLeftAction()
if ((currentState != ADD && currentState != PLAN) || !plannerModel)
return;
bool oldRecalc = plannerModel->setRecalc(false);
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
int row = handleIndex(handler);
@ -1868,8 +1860,6 @@ void ProfileWidget2::keyLeftAction()
plannerModel->editStop(row, dp);
}
}
plannerModel->setRecalc(oldRecalc);
replot();
}
void ProfileWidget2::keyRightAction()
@ -1877,7 +1867,6 @@ void ProfileWidget2::keyRightAction()
if ((currentState != ADD && currentState != PLAN) || !plannerModel)
return;
bool oldRecalc = plannerModel->setRecalc(false);
Q_FOREACH (QGraphicsItem *i, scene()->selectedItems()) {
if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler *>(i)) {
int row = handleIndex(handler);
@ -1887,8 +1876,6 @@ void ProfileWidget2::keyRightAction()
plannerModel->editStop(row, dp);
}
}
plannerModel->setRecalc(oldRecalc);
replot();
}
void ProfileWidget2::keyDeleteAction()