summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-09 20:33:33 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-09 20:33:33 +0900
commit6d5b2d75927b23183f8864bebf894b7bf4828311 (patch)
treeb3ad7fee4535f7365cd54d70064216806a2d259b /qt-ui/diveplanner.cpp
parentedecb0fcf904bb8d5901094b2e96079da644694d (diff)
downloadsubsurface-6d5b2d75927b23183f8864bebf894b7bf4828311.tar.gz
Adjust planner to work with the new semantic
Insert the dive data point at 0,0 manually at the beginning of the plan. Now everything should work. We still can't edit a plan created like this, but at least we can once again plan things. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r--qt-ui/diveplanner.cpp36
1 files changed, 17 insertions, 19 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index c2103b093..0701cb6d6 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -487,18 +487,16 @@ void DivePlannerGraphics::drawProfile()
}
// Re-position the user generated dive handlers
- for (int i = 0; i < plannerModel->rowCount(); i++) {
+ for (int i = 1; i < plannerModel->rowCount(); i++) {
divedatapoint dp = plannerModel->at(i);
DiveHandler *h = handles.at(i);
h->setPos(timeLine->posAtValue(dp.time / 60), depthLine->posAtValue(dp.depth));
- QPointF p1 = (i == 0) ? QPointF(timeLine->posAtValue(0), depthLine->posAtValue(0)) : handles[i-1]->pos();
+ QPointF p1 = handles[i-1]->pos();
QPointF p2 = handles[i]->pos();
QLineF line(p1, p2);
- if (i > 0) {
- QPointF pos = line.pointAt(0.5);
- gases[i]->setPos(pos);
- gases[i]->setText(strForAir(plannerModel->at(i-1)));
- }
+ QPointF pos = line.pointAt(0.5);
+ gases[i]->setPos(pos);
+ gases[i]->setText(strForAir(plannerModel->at(i-1)));
}
// (re-) create the profile with different colors for segments that were
@@ -1104,21 +1102,21 @@ bool divePointsLessThan(const divedatapoint& p1, const divedatapoint& p2)
int DivePlannerPointsModel::addStop(int milimeters, int minutes, int o2, int he, int ccpoint)
{
int row = divepoints.count();
-#if 0 // this seems bogus
- if(milimeters == 0 && minutes == 0) {
- if(row == 0) {
- milimeters = M_OR_FT(10,30);
- minutes = 600;
- } else {
- divedatapoint p = at(row-1);
- milimeters = p.depth;
- minutes = p.time + 600;
- }
+ if(row == 0) {
+ beginInsertRows(QModelIndex(), row, row);
+ divedatapoint point;
+ point.depth = 0;
+ point.time = 0;
+ point.o2 = o2;
+ point.he = he;
+ point.po2 = ccpoint;
+ divepoints.append( point );
+ endInsertRows();
+ row++;
}
-#endif
// check if there's already a new stop before this one:
- for (int i = 0; i < divepoints.count(); i++) {
+ for (int i = 0; i < row; i++) {
const divedatapoint& dp = divepoints.at(i);
if (dp.time == minutes) {
row = i;