Have divedatapoint store cylinder id instead of gasmix

Determining the correct cylinder index from a known gas mix can be
complicated, but it is trivial to look up the gasmix from the cylinder_t
structure.

It makes sense to remember which cylinder is being used. This simplifies
handling changing a cylinder's gas mix, either directly by the user, or
indirectly in the planner. It also permits tracking of multiple cylinders of
the same mix, e.g. independent twins / sidemount.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Rick Walsh 2016-07-06 22:40:28 +10:00 committed by Dirk Hohndel
parent 066f79223c
commit b1ed04a7f4
11 changed files with 98 additions and 142 deletions

View file

@ -296,8 +296,6 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
}
break;
}
if (addDiveMode)
DivePlannerPointsModel::instance()->tanksUpdated();
dataChanged(index, index);
return true;
}
@ -391,8 +389,8 @@ void CylindersModel::remove(const QModelIndex &index)
}
if (same_gas == -1 &&
((DivePlannerPointsModel::instance()->currentMode() != DivePlannerPointsModel::NOTHING &&
DivePlannerPointsModel::instance()->tankInUse(cyl->gasmix)) ||
(DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING &&
DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
(DivePlannerPointsModel::instance()->currentMode() == DivePlannerPointsModel::NOTHING &&
is_cylinder_used(&displayed_dive, index.row())))) {
emit warningMessage(TITLE_OR_TEXT(
tr("Cylinder cannot be removed"),