From 32ae3810ce3844bd517002477e41afb78e493f2f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 20 Oct 2019 07:36:42 -0400 Subject: Core: move cylinder list getter into helper function Thie way we can use it from the dive list model. Signed-off-by: Dirk Hohndel --- core/subsurface-qt/DiveObjectHelper.cpp | 49 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'core') diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp index f13319084..5146a6ea1 100644 --- a/core/subsurface-qt/DiveObjectHelper.cpp +++ b/core/subsurface-qt/DiveObjectHelper.cpp @@ -215,6 +215,32 @@ QStringList getFirstGas(const dive *d) return gas; } +QStringList getFullCylinderList() +{ + QStringList cylinders; + int i = 0; + struct dive *d; + for_each_dive (i, d) { + for (int j = 0; j < MAX_CYLINDERS; j++) { + QString cyl = d->cylinder[j].type.description; + if (cyl.isEmpty()) + continue; + cylinders << cyl; + } + } + + for (int ti = 0; ti < MAX_TANK_INFO && tank_info[ti].name != NULL; ti++) { + QString cyl = tank_info[ti].name; + if (cyl.isEmpty()) + continue; + cylinders << cyl; + } + + cylinders.removeDuplicates(); + cylinders.sort(); + return cylinders; +} + // Qt's metatype system insists on generating a default constructed object, even if that makes no sense. DiveObjectHelper::DiveObjectHelper() { @@ -293,26 +319,5 @@ QString DiveObjectHelper::time() const QStringList DiveObjectHelper::cylinderList() const { - QStringList cylinders; - int i = 0; - struct dive *d; - for_each_dive (i, d) { - for (int j = 0; j < MAX_CYLINDERS; j++) { - QString cyl = d->cylinder[j].type.description; - if (cyl.isEmpty()) - continue; - cylinders << cyl; - } - } - - for (int ti = 0; ti < MAX_TANK_INFO && tank_info[ti].name != NULL; ti++) { - QString cyl = tank_info[ti].name; - if (cyl.isEmpty()) - continue; - cylinders << cyl; - } - - cylinders.removeDuplicates(); - cylinders.sort(); - return cylinders; + return getFullCylinderList(); } -- cgit v1.2.3-70-g09d2