summaryrefslogtreecommitdiffstats
path: root/core/subsurface-qt
diff options
context:
space:
mode:
authorGravatar Jocke <j.bygdell@gmail.com>2018-07-17 11:49:42 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-08-11 11:19:07 -0700
commitc33a952582b986c8d99b4a0e41701560e45dad7d (patch)
treea01ba373a6f7b0d522d58838184f4ccdac9b6688 /core/subsurface-qt
parent891e8acaa84adc213725f12778f469d40f29dde5 (diff)
downloadsubsurface-c33a952582b986c8d99b4a0e41701560e45dad7d.tar.gz
Mobile: return pressures for all used cylinders
Return all pressure values for all used cylinders as a list. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Diffstat (limited to 'core/subsurface-qt')
-rw-r--r--core/subsurface-qt/DiveObjectHelper.cpp20
-rw-r--r--core/subsurface-qt/DiveObjectHelper.h8
2 files changed, 18 insertions, 10 deletions
diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp
index 23fa8a09f..15291554d 100644
--- a/core/subsurface-qt/DiveObjectHelper.cpp
+++ b/core/subsurface-qt/DiveObjectHelper.cpp
@@ -35,9 +35,9 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx)
return fmt;
}
-static QString getPressures(struct dive *dive, enum returnPressureSelector ret)
+static QString getPressures(struct dive *dive, int i, enum returnPressureSelector ret)
{
- cylinder_t *cyl = &dive->cylinder[0];
+ cylinder_t *cyl = &dive->cylinder[i];
QString fmt;
if (ret == START_PRESSURE) {
if (cyl->start.mbar)
@@ -405,15 +405,23 @@ QStringList DiveObjectHelper::getCylinder() const
return getCylinder;
}
-QString DiveObjectHelper::startPressure() const
+QStringList DiveObjectHelper::startPressure() const
{
- QString startPressure = getPressures(m_dive, START_PRESSURE);
+ QStringList startPressure;
+ for (int i = 0; i < MAX_CYLINDERS; i++) {
+ if (is_cylinder_used(m_dive, i))
+ startPressure << getPressures(m_dive, i, START_PRESSURE);
+ }
return startPressure;
}
-QString DiveObjectHelper::endPressure() const
+QStringList DiveObjectHelper::endPressure() const
{
- QString endPressure = getPressures(m_dive, END_PRESSURE);
+ QStringList endPressure;
+ for (int i = 0; i < MAX_CYLINDERS; i++) {
+ if (is_cylinder_used(m_dive, i))
+ endPressure << getPressures(m_dive, i, END_PRESSURE);
+ }
return endPressure;
}
diff --git a/core/subsurface-qt/DiveObjectHelper.h b/core/subsurface-qt/DiveObjectHelper.h
index 118197ac3..d36ef550e 100644
--- a/core/subsurface-qt/DiveObjectHelper.h
+++ b/core/subsurface-qt/DiveObjectHelper.h
@@ -46,8 +46,8 @@ class DiveObjectHelper : public QObject {
Q_PROPERTY(int otu READ otu CONSTANT)
Q_PROPERTY(QString sumWeight READ sumWeight CONSTANT)
Q_PROPERTY(QStringList getCylinder READ getCylinder CONSTANT)
- Q_PROPERTY(QString startPressure READ startPressure CONSTANT)
- Q_PROPERTY(QString endPressure READ endPressure CONSTANT)
+ Q_PROPERTY(QStringList startPressure READ startPressure CONSTANT)
+ Q_PROPERTY(QStringList endPressure READ endPressure CONSTANT)
Q_PROPERTY(QStringList firstGas READ firstGas CONSTANT)
public:
DiveObjectHelper(struct dive *dive = NULL);
@@ -90,8 +90,8 @@ public:
int otu() const;
QString sumWeight() const;
QStringList getCylinder() const;
- QString startPressure() const;
- QString endPressure() const;
+ QStringList startPressure() const;
+ QStringList endPressure() const;
QStringList firstGas() const;
private: