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 <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2013-11-14 18:06:08 -02:00 committed by Dirk Hohndel
parent a07c3d62af
commit 2235da57a7

View file

@ -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