diff options
Diffstat (limited to 'qthelper.cpp')
-rw-r--r-- | qthelper.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/qthelper.cpp b/qthelper.cpp index 68f8c5058..36d1d02c7 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -76,3 +76,21 @@ void DiveComputerList::rmDC(QString m, uint32_t d) const DiveComputerNode *existNode = this->getExact(m, d); dcMap.remove(m, *existNode); } + +QString weight_string(int weight_in_grams) +{ + QString str; + if (get_units()->weight == units::KG) { + int gr = weight_in_grams % 1000; + int kg = weight_in_grams / 1000; + if (kg >= 20.0) { + str = QString("0"); + } else { + str = QString("%1.%2").arg(kg).arg((unsigned)(gr) / 100); + } + } else { + double lbs = grams_to_lbs(weight_in_grams); + str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1 ); + } + return (str); +} |