summaryrefslogtreecommitdiffstats
path: root/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
diff options
context:
space:
mode:
authorGravatar Joakim Bygdell <j.bygdell@gmail.com>2016-02-09 17:19:06 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-02-09 12:10:50 -0800
commitf3b35d175a381a57447b2ff33a8cd6d0db69b924 (patch)
tree58a080b6b05a3c4a55fce989969061d0db4c335e /subsurface-core/subsurface-qt/DiveObjectHelper.cpp
parent9c5b97e6cfe738fe2ac9f2b3f72ed624230aef0a (diff)
downloadsubsurface-f3b35d175a381a57447b2ff33a8cd6d0db69b924.tar.gz
QML UI: add function to get cylinder pressures
Since we only show the first cylinder we can also only edit the first cylinder. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core/subsurface-qt/DiveObjectHelper.cpp')
-rw-r--r--subsurface-core/subsurface-qt/DiveObjectHelper.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
index 2f058f47f..8a44c0ec5 100644
--- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
+++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
@@ -7,7 +7,7 @@
#include "../helpers.h"
static QString EMPTY_DIVE_STRING = QStringLiteral("--");
-
+enum returnPressureSelector {START_PRESSURE, END_PRESSURE};
static QString getFormattedWeight(struct dive *dive, unsigned int idx)
{
@@ -33,6 +33,17 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx)
return fmt;
}
+static QString getPressures(struct dive *dive, enum returnPressureSelector ret)
+{
+ cylinder_t *cyl = &dive->cylinder[0];
+ QString fmt;
+ if (ret == START_PRESSURE)
+ fmt = get_pressure_string(cyl->start, true);
+ if (ret == END_PRESSURE)
+ fmt = get_pressure_string(cyl->end, true);
+ return fmt;
+}
+
DiveObjectHelper::DiveObjectHelper(struct dive *d) :
m_dive(d)
{
@@ -269,3 +280,15 @@ QString DiveObjectHelper::getCylinder() const
}
return getCylinder;
}
+
+QString DiveObjectHelper::startPressure() const
+{
+ QString startPressure = getPressures(m_dive, START_PRESSURE);
+ return startPressure;
+}
+
+QString DiveObjectHelper::endPressure() const
+{
+ QString endPressure = getPressures(m_dive, END_PRESSURE);
+ return endPressure;
+}