From 2235da57a795cd7ffd0ef17ffec274f1a03d6c21 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 14 Nov 2013 18:06:08 -0200 Subject: [PATCH] Fix adding DivePoints on the planner via the table. Somewhere we broke this, most probably in the code that activated the planner to be used together as an 'add dive'. This commit makes the code workable again. There's one thing, though. if the model is empty, this will add something in the first point - it's behaving strangely. I'll try to fix this in a way that's invisible to the user, but overall, why are we inserting something in the first(0,0) time and depth? Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 9bbce05f4..2efc035da 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -1149,6 +1149,12 @@ bool DivePlannerPointsModel::addGas(int o2, int he) int DivePlannerPointsModel::addStop(int milimeters, int minutes, int o2, int he, int ccpoint) { int row = divepoints.count(); + if (minutes == 0 && milimeters == 0 && row != 0){ + /* this is only possible if the user clicked on the 'plus' sign on the DivePoints Table */ + struct divedatapoint& t = divepoints.last(); + milimeters = t.depth; + minutes = t.time + 600; // 10 minutes. + } if (o2 != -1) if (!addGas(o2, he)) qDebug("addGas failed"); // FIXME add error propagation