mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: add create_new_cylinder() function
Turn the code in CylindersModel that creates a new cylinder for addition into its own function to avoid code duplication. This will be used from the undo commands. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f1e08fd470
commit
e008b42a59
3 changed files with 12 additions and 5 deletions
|
@ -392,6 +392,16 @@ cylinder_t *get_or_create_cylinder(struct dive *d, int idx)
|
||||||
return &d->cylinders.cylinders[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
|
#ifdef DEBUG_CYL
|
||||||
void dump_cylinders(struct dive *dive, bool verbose)
|
void dump_cylinders(struct dive *dive, bool verbose)
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 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 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 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
|
#ifdef DEBUG_CYL
|
||||||
extern void dump_cylinders(struct dive *dive, bool verbose);
|
extern void dump_cylinders(struct dive *dive, bool verbose);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -448,11 +448,7 @@ int CylindersModel::rowCount(const QModelIndex&) const
|
||||||
void CylindersModel::add()
|
void CylindersModel::add()
|
||||||
{
|
{
|
||||||
int row = rows;
|
int row = rows;
|
||||||
cylinder_t cyl = empty_cylinder;
|
cylinder_t cyl = create_new_cylinder(&displayed_dive);
|
||||||
fill_default_cylinder(&displayed_dive, &cyl);
|
|
||||||
cyl.start = cyl.type.workingpressure;
|
|
||||||
cyl.manually_added = true;
|
|
||||||
cyl.cylinder_use = OC_GAS;
|
|
||||||
beginInsertRows(QModelIndex(), row, row);
|
beginInsertRows(QModelIndex(), row, row);
|
||||||
add_to_cylinder_table(&displayed_dive.cylinders, row, cyl);
|
add_to_cylinder_table(&displayed_dive.cylinders, row, cyl);
|
||||||
rows++;
|
rows++;
|
||||||
|
|
Loading…
Add table
Reference in a new issue