From b949bad026c8bab7611998fb0fcf9f6008dbd7e9 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 28 Apr 2020 14:50:40 +0200 Subject: core: always keep an empty cylinder at the end of the cylinder array This will be temporarilly used by the planner to mark consumption of air at the surface. Do this by creating a new function add_cylinder, which replaces add_to_cylinder_table() and takes care of always adding a dummy cylinder at the end of the table. Make the original add_to_cylinder_table() local, so that it cannot be accessed anymore. Signed-off-by: Berthold Stoeger --- qt-models/cylindermodel.cpp | 2 +- qt-models/diveplannermodel.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'qt-models') diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index 6759670c6..0055849ff 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -490,7 +490,7 @@ void CylindersModel::add() int row = d->cylinders.nr; cylinder_t cyl = create_new_cylinder(d); beginInsertRows(QModelIndex(), row, row); - add_to_cylinder_table(&d->cylinders, row, cyl); + add_cylinder(&d->cylinders, row, cyl); endInsertRows(); emit dataChanged(createIndex(row, 0), createIndex(row, COLUMNS - 1)); } diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index f9823c12d..c6821109b 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -174,14 +174,14 @@ void DivePlannerPointsModel::setupCylinders() cylinder_t cyl = empty_cylinder; fill_default_cylinder(&displayed_dive, &cyl); cyl.start = cyl.type.workingpressure; - add_to_cylinder_table(&displayed_dive.cylinders, 0, cyl); + add_cylinder(&displayed_dive.cylinders, 0, cyl); } else { cylinder_t cyl = empty_cylinder; // roughly an AL80 cyl.type.description = copy_qstring(tr("unknown")); cyl.type.size.mliter = 11100; cyl.type.workingpressure.mbar = 207000; - add_to_cylinder_table(&displayed_dive.cylinders, 0, cyl); + add_cylinder(&displayed_dive.cylinders, 0, cyl); } reset_cylinders(&displayed_dive, false); cylinders.updateDive(&displayed_dive); -- cgit v1.2.3-70-g09d2