summaryrefslogtreecommitdiffstats
path: root/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
diff options
context:
space:
mode:
authorGravatar Joakim Bygdell <j.bygdell@gmail.com>2016-01-27 18:34:34 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-27 11:18:44 -0800
commit9342dedb265ed314e1657e82aef407176f7d1e04 (patch)
tree5597c80fe1138e7341c415337599903a644be646 /subsurface-core/subsurface-qt/DiveObjectHelper.cpp
parent4abe73ff2af49431d131f0d42fd10aa6f61b0125 (diff)
downloadsubsurface-9342dedb265ed314e1657e82aef407176f7d1e04.tar.gz
Move helper function to DiveObjectsHelper
As per Tomaz recomendation the helper functions from 19588ce and e072596 are moved from qmlmanager to DiveObjectsHelper. [Dirk Hohndel: merged with the latest code] 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.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
index e29bd3802..b4460b4de 100644
--- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
+++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
@@ -243,3 +243,31 @@ int DiveObjectHelper::rating() const
{
return m_dive->rating;
}
+
+QString DiveObjectHelper::sumWeight() const
+{
+ int sum = 0;
+ QString sumWeight;
+ for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++){
+ sum += m_dive->weightsystem[i].weight.grams;
+ }
+ if (informational_prefs.unit_system == IMPERIAL){
+ sumWeight = QString::number(grams_to_lbs(sum), 'f', 1) + " lbs";
+ }
+ else {
+ sumWeight = QString::number(sum / 1000, 'f', 1) + " kg";
+ }
+ return sumWeight;
+}
+
+QString DiveObjectHelper::getCylinder() const
+{
+ QString getCylinder;
+ if (m_dive->cylinder[1].type.description != NULL){
+ getCylinder = QObject::tr("Multiple");
+ }
+ else {
+ getCylinder = m_dive->cylinder[0].type.description;
+ }
+ return getCylinder;
+}