[PATCH] Don't add half a kilo/pound when adding weights

subsurface at henrik.synth.no subsurface at henrik.synth.no
Tue May 14 04:53:07 PDT 2013


From: Henrik Brautaset Aronsen <subsurface at henrik.synth.no>

The weight management widget added 500 grams / 0.5 lbs
when a new entry was added.

Signed-off-by: Henrik Brautaset Aronsen <subsurface at henrik.synth.no>
---
 qt-ui/models.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 4c45f14..9bc8db0 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -167,9 +167,9 @@ QVariant WeightModel::data(const QModelIndex& index, int role) const
 			if (get_units()->weight == units::KG) {
 				int gr = ws->weight.grams % 1000;
 				int kg = ws->weight.grams / 1000;
-				ret = QString("%1.%2").arg(kg).arg((unsigned)(gr + 500) / 100);
+				ret = QString("%1.%2").arg(kg).arg((unsigned) gr / 100);
 			} else {
-				ret = QString("%1").arg((unsigned)(grams_to_lbs(ws->weight.grams) + 0.5));
+				ret = QString("%1").arg((unsigned)(grams_to_lbs(ws->weight.grams)));
 			}
 			break;
 		}
-- 
1.8.2.2



More information about the subsurface mailing list