diff options
author | Robert C. Helling <helling@atdotde.de> | 2014-05-06 15:28:32 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-08 13:13:49 -0700 |
commit | e3ef1b7a1ea58d7f6f912dc00412d7ee954cb5fe (patch) | |
tree | 5d766766991600395f4dc28d647503d7fb351f3c /qt-ui/diveplanner.cpp | |
parent | a422aa29860840d7ac7738b25789501ff9f530e1 (diff) | |
download | subsurface-e3ef1b7a1ea58d7f6f912dc00412d7ee954cb5fe.tar.gz |
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 <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
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<int> 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<int> 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; |