summaryrefslogtreecommitdiffstats
path: root/qt-ui/models.cpp
diff options
context:
space:
mode:
authorGravatar Benjamin <nystire@gmail.com>2013-10-04 21:39:33 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-04 11:57:28 -0700
commitae713763c79afb483afec12d02730e0c5a8af309 (patch)
tree0d1dae49cccdfa464e7675d40c3d41d522a194f6 /qt-ui/models.cpp
parentf63605e02e4656b60c6c095f4289dbffa293bc2d (diff)
downloadsubsurface-ae713763c79afb483afec12d02730e0c5a8af309.tar.gz
Add a helper function to calculate weight display string
Add a helper function to unify the calculation of the weight display string, instead of having the same calculation in two places in the code. Signed-off-by: Benjamin Fogel <nystire@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/models.cpp')
-rw-r--r--qt-ui/models.cpp12
1 files changed, 1 insertions, 11 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 752f3ddf3..62e8d380a 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -1107,17 +1107,7 @@ QString DiveItem::displaySac() const
QString DiveItem::displayWeight() const
{
- QString str;
-
- if (get_units()->weight == units::KG) {
- int gr = weight() % 1000;
- int kg = weight() / 1000;
- str = QString("%1.%2").arg(kg).arg((unsigned)(gr) / 100);
- } else {
- double lbs = grams_to_lbs(weight());
- str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1 );
- }
-
+ QString str = weight_string(weight());
return str;
}