From 27a8fd51ed95a4703c76b08b735ff9ce14d10d8f Mon Sep 17 00:00:00 2001 From: Stefan Fuchs Date: Wed, 18 Oct 2017 09:02:28 +0200 Subject: 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 --- qt-models/diveplannermodel.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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() -- cgit v1.2.3-70-g09d2