diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-10-20 07:36:42 -0400 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-20 16:08:55 -0400 |
commit | 32ae3810ce3844bd517002477e41afb78e493f2f (patch) | |
tree | 851ac103bf9eb87622b107f0e0bfb64edfced636 /core/subsurface-qt | |
parent | 613a3112d27e2d40c3a4eeb7fb061f4739279157 (diff) | |
download | subsurface-32ae3810ce3844bd517002477e41afb78e493f2f.tar.gz |
Core: move cylinder list getter into helper function
Thie way we can use it from the dive list model.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/subsurface-qt')
-rw-r--r-- | core/subsurface-qt/DiveObjectHelper.cpp | 49 |
1 files changed, 27 insertions, 22 deletions
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(); } |