diff options
author | Robert C. Helling <helling@atdotde.de> | 2014-04-24 16:42:10 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-08 12:25:38 -0700 |
commit | 00e7ef2cf88e1a96bf14317af79ab2c9b3468ed2 (patch) | |
tree | 1495bc5c42235357a3f22d3988dff94ca8cc4d2c /qt-ui | |
parent | 84414baece62b401ce3a3f7fa5366bfff278cc65 (diff) | |
download | subsurface-00e7ef2cf88e1a96bf14317af79ab2c9b3468ed2.tar.gz |
Planner: Change when we recalculate deco
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/diveplanner.cpp | 24 | ||||
-rw-r--r-- | qt-ui/diveplanner.h | 1 |
2 files changed, 19 insertions, 6 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 94fcc1b1c..8a85070e6 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -454,6 +454,15 @@ QStringList &DivePlannerPointsModel::getGasList() return list; } +void DivePlannerPointsModel::removeDeco() +{ + QVector<int> computedPoints; + for (int i = 0; i < plannerModel->rowCount(); i++) + if (!plannerModel->at(i).entered) + computedPoints.push_back(i); + removeSelectedPoints(computedPoints); +} + void DivePlannerGraphics::drawProfile() { if (!plannerModel->recalcQ()) @@ -514,11 +523,7 @@ void DivePlannerGraphics::drawProfile() poly.append(QPointF(lastx, lasty)); bool oldRecalc = plannerModel->setRecalc(false); - QVector<int> computedPoints; - for (int i = 0; i < plannerModel->rowCount(); i++) - if (!plannerModel->at(i).entered) - computedPoints.push_back(i); - plannerModel->removeSelectedPoints(computedPoints); + plannerModel->removeDeco(); unsigned int lastdepth = 0; for (dp = diveplan.dp; dp != NULL; dp = dp->next) { @@ -1529,7 +1534,8 @@ void DivePlannerPointsModel::createTemporaryPlan() #if DEBUG_PLAN dump_plan(&diveplan); #endif - plan(&diveplan, &cache, &tempDive, isPlanner()); + if (plannerModel->recalcQ()) + plan(&diveplan, &cache, &tempDive, isPlanner()); if (mode == ADD) { // copy the samples and events, but don't overwrite the cylinders copy_samples(tempDive, current_dive); @@ -1569,7 +1575,11 @@ void DivePlannerPointsModel::createPlan() if (!diveplan.dp) return cancelPlan(); + bool oldRecalc = plannerModel->setRecalc(false); + removeDeco(); createTemporaryPlan(); + plannerModel->setRecalc(oldRecalc); + //TODO: C-based function here? plan(&diveplan, &cache, &tempDive, isPlanner()); copy_cylinders(stagingDive, tempDive); @@ -1601,8 +1611,10 @@ void DivePlannerPointsModel::createPlan() setPlanMode(NOTHING); free(stagingDive); stagingDive = NULL; + oldRecalc = plannerModel->setRecalc(false); CylindersModel::instance()->setDive(current_dive); CylindersModel::instance()->update(); + plannerModel->setRecalc(oldRecalc); } ExpanderGraphics::ExpanderGraphics(QGraphicsItem *parent) : QGraphicsRectItem(parent), diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 91f8744d8..85b585537 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -58,6 +58,7 @@ public: QStringList &getGasList(); QVector<QPair<int, int> > collectGases(dive *d); int lastEnteredPoint(); + void removeDeco(); static bool addingDeco; public |