From e3ef1b7a1ea58d7f6f912dc00412d7ee954cb5fe Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Tue, 6 May 2014 15:28:32 +0200 Subject: Planner: show gas for the NEXT segment For deco stops show the gas of the next segment in the table. In recalculation remove old deco stops earlier. In struct diveplan, the items are "segments" with a beginning, a duration, and a gas. In contrast, the UI of the planner uses "waypoints" which are the boundaries between segments. It is conventional at least for deco stops to display the gas of the _next_ segment in the runtime table (i.e. the gas possibly to be switched to). Furthermore, in addStop, the old deco stops have to be removed earlier as otherwise a new waypoint later than a previous generated gas switch inherits the gas of the old switch. Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'qt-ui/diveplanner.cpp') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 8a85070e6..cef6610ac 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -456,11 +456,13 @@ QStringList &DivePlannerPointsModel::getGasList() void DivePlannerPointsModel::removeDeco() { + bool oldrec = setRecalc(false); QVector computedPoints; for (int i = 0; i < plannerModel->rowCount(); i++) if (!plannerModel->at(i).entered) computedPoints.push_back(i); removeSelectedPoints(computedPoints); + setRecalc(oldrec); } void DivePlannerGraphics::drawProfile() @@ -539,7 +541,7 @@ void DivePlannerGraphics::drawProfile() lines << item; if (dp->depth) { if (dp->depth == lastdepth || dp->o2 != dp->next->o2 || dp->he != dp->next->he) - plannerModel->addStop(dp->depth, dp->time, dp->o2, dp->he, 0, false); + plannerModel->addStop(dp->depth, dp->time, dp->next->o2, dp->next->he, 0, false); lastdepth = dp->depth; } } @@ -1087,7 +1089,6 @@ QVariant DivePlannerPointsModel::data(const QModelIndex &index, int role) const else return p.time / 60; case GAS: - return dpGasToStr(p); } } else if (role == Qt::DecorationRole) { @@ -1275,6 +1276,9 @@ int DivePlannerPointsModel::lastEnteredPoint() int DivePlannerPointsModel::addStop(int milimeters, int seconds, int o2, int he, int ccpoint, bool entered) { + if (recalcQ()) + removeDeco(); + int row = divepoints.count(); if (seconds == 0 && milimeters == 0 && row != 0) { /* this is only possible if the user clicked on the 'plus' sign on the DivePoints Table */ @@ -1333,16 +1337,6 @@ int DivePlannerPointsModel::addStop(int milimeters, int seconds, int o2, int he, } } - // Get rid of deco stops before adding waypoints - bool oldRecalc = setRecalc(false); - if (oldRecalc) { - QVector computedPoints; - for (int i = 0; i < plannerModel->rowCount(); i++) - if (!plannerModel->at(i).entered) - computedPoints.push_back(i); - plannerModel->removeSelectedPoints(computedPoints); - } - setRecalc(oldRecalc); // add the new stop beginInsertRows(QModelIndex(), row, row); divedatapoint point; -- cgit v1.2.3-70-g09d2