aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2013-06-19 18:22:09 -1000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-19 21:52:58 -0700
commitbc24b9320f4a0994161dcefdd4d34406f461bb9d (patch)
tree02363af230dd4a0bf080bc9f6c5b0e08b8c88d53 /qt-ui
parent45d9ca09de0bae43f54b7ab0fb08d8c6406be7a2 (diff)
downloadsubsurface-bc24b9320f4a0994161dcefdd4d34406f461bb9d.tar.gz
Don't show '0.0%' gas percentages
It's just distracting. Leave it empty. No helium should be visually very different from actual trimix, and for oxygen, zero means something different anyway (it's air). In neither case is '0.0%' a good string to show, just show it as empty. 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.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 4ef8bc6ca..c2cce5615 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -59,6 +59,16 @@ int CylindersModel::columnCount(const QModelIndex& parent) const
return COLUMNS;
}
+static QVariant percent_string(fraction_t fraction)
+{
+ int permille = fraction.permille;
+
+ if (!permille)
+ return QVariant();
+
+ return QString("%1%").arg(permille / 10.0, 0, 'f', 1);
+}
+
QVariant CylindersModel::data(const QModelIndex& index, int role) const
{
QVariant ret;
@@ -109,10 +119,10 @@ QVariant CylindersModel::data(const QModelIndex& index, int role) const
ret = get_pressure_string(cyl->end, TRUE);
break;
case O2:
- ret = QString("%1%").arg(cyl->gasmix.o2.permille / 10.0, 0, 'f', 1);
+ ret = percent_string(cyl->gasmix.o2);
break;
case HE:
- ret = QString("%1%").arg(cyl->gasmix.he.permille / 10.0, 0, 'f', 1);
+ ret = percent_string(cyl->gasmix.he);
break;
}
break;