diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-06-19 15:40:15 -1000 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-06-19 21:39:12 -0700 |
commit | 02f2768148ecc6d4b547506fe841a5dc8f3bedd2 (patch) | |
tree | 37394397a0dce80b82dbce6e224a49c119ebd150 /qt-ui | |
parent | d126977e16372c385f0939bcfd25a5b0f7924063 (diff) | |
download | subsurface-02f2768148ecc6d4b547506fe841a5dc8f3bedd2.tar.gz |
O2/He percentages aren't integral
We do gas mixes in permille, not in percent. Some people really like
using the value they got from the analyzer, which is generally something
like 29.4% or whatever. So don't truncate percentages to integers.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/models.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 1b882f3bf..489f91bb6 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -85,8 +85,8 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const // sizes take working pressure into account... if (cyl->type.size.mliter) { if (prefs.units.volume == prefs.units.CUFT) { - int cuft = 0.5 + ml_to_cuft(gas_volume(cyl, cyl->type.workingpressure)); - ret = QString("%1cuft").arg(cuft); + double cuft = ml_to_cuft(gas_volume(cyl, cyl->type.workingpressure)); + ret = QString("%1cuft").arg(cuft, 0, 'f', 1); } else { ret = QString("%1l").arg(cyl->type.size.mliter / 1000.0, 0, 'f', 1); } @@ -102,13 +102,13 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const break; case END: if (cyl->end.mbar) - ret = get_pressure_string(cyl->end, TRUE ); + ret = get_pressure_string(cyl->end, TRUE); break; case O2: - ret = QString("%1%").arg((cyl->gasmix.o2.permille + 5) / 10); + ret = QString("%1%").arg(cyl->gasmix.o2.permille / 10.0, 0, 'f', 1); break; case HE: - ret = QString("%1%").arg((cyl->gasmix.he.permille + 5) / 10); + ret = QString("%1%").arg(cyl->gasmix.he.permille / 10.0, 0, 'f', 1); break; } break; @@ -227,14 +227,14 @@ bool CylindersModel::setData(const QModelIndex& index, const QVariant& value, in } break; case O2: - if (CHANGED(toInt, "%", "%")) { - cyl->gasmix.o2.permille = value.toInt() * 10; + if (CHANGED(toDouble, "%", "%")) { + cyl->gasmix.o2.permille = value.toDouble() * 10 + 0.5; mark_divelist_changed(TRUE); } break; case HE: - if (CHANGED(toInt, "%", "%")) { - cyl->gasmix.he.permille = value.toInt() * 10; + if (CHANGED(toDouble, "%", "%")) { + cyl->gasmix.he.permille = value.toDouble() * 10 + 0.5; mark_divelist_changed(TRUE); } break; @@ -408,7 +408,7 @@ bool WeightModel::setData(const QModelIndex& index, const QVariant& value, int r if (prefs.units.weight == prefs.units.LBS) ws->weight.grams = lbs_to_grams(value.toDouble()); else - ws->weight.grams = value.toDouble() * 1000.0; + ws->weight.grams = value.toDouble() * 1000.0 + 0.5; // now update the ws_info WSInfoModel *wsim = WSInfoModel::instance(); QModelIndexList matches = wsim->match(wsim->index(0,0), Qt::DisplayRole, ws->description); |