From 535a6b9b2529925bba8b665ce7523a74647d5f53 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 5 Feb 2016 22:52:30 -0800 Subject: Simplify sumWeight function Signed-off-by: Dirk Hohndel --- subsurface-core/subsurface-qt/DiveObjectHelper.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'subsurface-core/subsurface-qt') 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 -- cgit v1.2.3-70-g09d2