aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/equipment.c10
-rw-r--r--core/equipment.h1
-rw-r--r--qt-models/cylindermodel.cpp6
3 files changed, 12 insertions, 5 deletions
diff --git a/core/equipment.c b/core/equipment.c
index 3d169a338..c3b9fa494 100644
--- a/core/equipment.c
+++ b/core/equipment.c
@@ -392,6 +392,16 @@ cylinder_t *get_or_create_cylinder(struct dive *d, int idx)
return &d->cylinders.cylinders[idx];
}
+cylinder_t create_new_cylinder(const struct dive *d)
+{
+ cylinder_t cyl = empty_cylinder;
+ fill_default_cylinder(d, &cyl);
+ cyl.start = cyl.type.workingpressure;
+ cyl.manually_added = true;
+ cyl.cylinder_use = OC_GAS;
+ return cyl;
+}
+
#ifdef DEBUG_CYL
void dump_cylinders(struct dive *dive, bool verbose)
{
diff --git a/core/equipment.h b/core/equipment.h
index 4ed809eff..289eb75a1 100644
--- a/core/equipment.h
+++ b/core/equipment.h
@@ -92,6 +92,7 @@ extern void set_weightsystem(struct dive *dive, int idx, weightsystem_t ws);
extern void reset_cylinders(struct dive *dive, bool track_gas);
extern int gas_volume(const cylinder_t *cyl, pressure_t p); /* Volume in mliter of a cylinder at pressure 'p' */
extern int find_best_gasmix_match(struct gasmix mix, const struct cylinder_table *cylinders);
+extern cylinder_t create_new_cylinder(const struct dive *dive); /* dive is needed to fill out MOD, which depends on salinity. */
#ifdef DEBUG_CYL
extern void dump_cylinders(struct dive *dive, bool verbose);
#endif
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp
index da8b2eb1e..428d3c868 100644
--- a/qt-models/cylindermodel.cpp
+++ b/qt-models/cylindermodel.cpp
@@ -448,11 +448,7 @@ int CylindersModel::rowCount(const QModelIndex&) const
void CylindersModel::add()
{
int row = rows;
- cylinder_t cyl = empty_cylinder;
- fill_default_cylinder(&displayed_dive, &cyl);
- cyl.start = cyl.type.workingpressure;
- cyl.manually_added = true;
- cyl.cylinder_use = OC_GAS;
+ cylinder_t cyl = create_new_cylinder(&displayed_dive);
beginInsertRows(QModelIndex(), row, row);
add_to_cylinder_table(&displayed_dive.cylinders, row, cyl);
rows++;