Planner: Autom. move first datapoint gas to first gaslist position

In the planner it is best practise to start the dive with the first
gas in the gaslist. Otherwise one would get a gaschange event at the
very beginning of a dive.
This change implements the following feature:
Automatically move a gas to position 0 in the gaslist if the user selects
this gas for the first dive data point.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
Stefan Fuchs 2017-10-11 21:29:47 +02:00 committed by Robert C. Helling
parent 73d2ab8099
commit 24bd5a8dce
3 changed files with 25 additions and 0 deletions

View file

@ -581,6 +581,27 @@ void CylindersModel::remove(const QModelIndex &index)
dataChanged(index, index);
}
void CylindersModel::moveAtFirst(int cylid)
{
int mapping[MAX_CYLINDERS];
cylinder_t temp_cyl;
beginMoveRows(QModelIndex(), cylid, cylid, QModelIndex(), 0);
memmove(&temp_cyl, &displayed_dive.cylinder[cylid], sizeof(temp_cyl));
for (int i = cylid - 1; i >= 0; i--) {
memmove(&displayed_dive.cylinder[i + 1], &displayed_dive.cylinder[i], sizeof(temp_cyl));
mapping[i] = i + 1;
}
memmove(&displayed_dive.cylinder[0], &temp_cyl, sizeof(temp_cyl));
mapping[cylid] = 0;
for (int i = cylid + 1; i < MAX_CYLINDERS; i++)
mapping[i] = i;
changed = true;
endMoveRows();
cylinder_renumber(&displayed_dive, mapping);
DivePlannerPointsModel::instance()->cylinderRenumber(mapping);
}
void CylindersModel::updateDecoDepths(pressure_t olddecopo2)
{
pressure_t decopo2;