aboutsummaryrefslogtreecommitdiffstats
path: root/subsurface-core
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-02-05 22:52:30 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-02-05 22:52:30 -0800
commit535a6b9b2529925bba8b665ce7523a74647d5f53 (patch)
treef63c6718408451adff3743e4d3b6c8922d180099 /subsurface-core
parent587456190f57815f2de44b9f003a3d88d622788a (diff)
downloadsubsurface-535a6b9b2529925bba8b665ce7523a74647d5f53.tar.gz
Simplify sumWeight function
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core')
-rw-r--r--subsurface-core/subsurface-qt/DiveObjectHelper.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
index b4460b4de..745379494 100644
--- a/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
+++ b/subsurface-core/subsurface-qt/DiveObjectHelper.cpp
@@ -246,18 +246,11 @@ int DiveObjectHelper::rating() const
QString DiveObjectHelper::sumWeight() const
{
- int sum = 0;
- QString sumWeight;
+ weight_t sum = { 0 };
for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++){
- sum += m_dive->weightsystem[i].weight.grams;
+ sum.grams += 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;
+ return get_weight_string(sum, true);
}
QString DiveObjectHelper::getCylinder() const