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:
Berthold Stoeger 2020-03-01 16:26:47 +01:00
parent f1e08fd470
commit e008b42a59
3 changed files with 12 additions and 5 deletions

View file

@ -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++;