From e008b42a591b83eb1304a552fdd950287ddbc375 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 1 Mar 2020 16:26:47 +0100 Subject: 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 --- qt-models/cylindermodel.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'qt-models') 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++; -- cgit v1.2.3-70-g09d2