From 5868b37e6bde1eaa6da09aac5e269557d94d7641 Mon Sep 17 00:00:00 2001 From: Henrik Brautaset Aronsen Date: Tue, 14 May 2013 09:45:01 +0200 Subject: [PATCH] Fix inaccurate weight and temperature display in dive list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A nonexisting temperature (mkelvin==0) was displayed as -273°C. Weight was always displayed with an extra 500 grams/0.5 lbs. Signed-off-by: Henrik Brautaset Aronsen Signed-off-by: Dirk Hohndel --- qt-ui/models.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 0b933aeb1..4c45f1489 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -540,6 +540,9 @@ QString DiveItem::displayTemperature() const { QString str; + if (!dive->watertemp.mkelvin) + return str; + if (get_units()->temperature == units::CELSIUS) str = QString::number(mkelvin_to_C(dive->watertemp.mkelvin), 'f', 1); else @@ -567,9 +570,9 @@ QString DiveItem::displayWeight() const if (get_units()->weight == units::KG) { int gr = weight() % 1000; int kg = weight() / 1000; - str = QString("%1.%2").arg(kg).arg((unsigned)(gr + 500) / 100); + str = QString("%1.%2").arg(kg).arg((unsigned)(gr) / 100); } else { - str = QString("%1").arg((unsigned)(grams_to_lbs(weight()) + 0.5)); + str = QString("%1").arg((unsigned)(grams_to_lbs(weight()))); } return str;