diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2017-10-18 09:02:28 +0200 |
---|---|---|
committer | Robert C. Helling <helling@atdotde.de> | 2017-10-18 23:20:44 +0200 |
commit | 27a8fd51ed95a4703c76b08b735ff9ce14d10d8f (patch) | |
tree | 8542f7111567d91a43676424b30dbbab36a0e881 /qt-models/diveplannermodel.cpp | |
parent | 7a82103c99467540fe5aaf46c3b1e67687dfd6f0 (diff) | |
download | subsurface-27a8fd51ed95a4703c76b08b735ff9ce14d10d8f.tar.gz |
Planner: Autom. move first datapoint gas to first gaslist position p2
This is a amendment to 24bd5a8dcebec886b8fbbf077fabfb2106dc7dcd
Move the cylinder also to first position if first planner datapoint
cylinder change because a row is added or deleted to the dive datapoints.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'qt-models/diveplannermodel.cpp')
-rw-r--r-- | qt-models/diveplannermodel.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 10d912846..36aee8a42 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -756,12 +756,15 @@ void DivePlannerPointsModel::editStop(int row, divedatapoint newData) * When moving divepoints rigorously, we might end up with index * out of range, thus returning the last one instead. */ + int old_first_cylid = divepoints[0].cylinderid; if (row >= divepoints.count()) return; divepoints[row] = newData; std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan); if (updateMaxDepth()) CylindersModel::instance()->updateBestMixes(); + if (divepoints[0].cylinderid != old_first_cylid) + CylindersModel::instance()->moveAtFirst(divepoints[0].cylinderid); emitDataChanged(); } @@ -790,6 +793,8 @@ void DivePlannerPointsModel::remove(const QModelIndex &index) if (!dp.entered) return; + int old_first_cylid = divepoints[0].cylinderid; + /* TODO: this seems so wrong. * We can't do this here if we plan to use QML on mobile * as mobile has no ControlModifier. @@ -809,6 +814,8 @@ void DivePlannerPointsModel::remove(const QModelIndex &index) } endRemoveRows(); CylindersModel::instance()->updateTrashIcon(); + if (divepoints[0].cylinderid != old_first_cylid) + CylindersModel::instance()->moveAtFirst(divepoints[0].cylinderid); } struct diveplan &DivePlannerPointsModel::getDiveplan() |