summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2017-01-15 16:07:35 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-01-16 03:22:33 -0800
commita8e8d56ec016fc19727e45cd7208bb55ca4821af (patch)
treef72240ad540aa62728c6b16c7b032c18baaacaee
parent7725842383b66fba50c41dbf9f981be38a467135 (diff)
downloadsubsurface-a8e8d56ec016fc19727e45cd7208bb55ca4821af.tar.gz
Tweak cylinder equipment tooltips
While playing around with the current subsurface, I realized that while we give the gas volume and Z factor for the beginning/end pressures in the newly added tooltips, there is no way to actually see that same information for the working pressure. So if you have filled in cylinder type information, but don't have any actual gas usage information, there will be no cylinder tooltips at all. But you might still want to know what the actual volume for a particular cylinder is, and what the Z value for that working pressure is. So this tweaks the tool-tips a bit. When mousing over the pressure fields (ie "working pressure", "start" and "end"), it now always gives the cylinder gas volume and Z factor for that pressure, so for example on an AL72 that has a working pressure of 3000 psi and that contains air the tooltip will say: 69 cuft, Z=1.040 when you mouse over the working pressure field (that's obviously with imperial units, in metric you'll see liters of gas). When mousing over the type/size field, it gives the used gas amounts, ie something like this: 37 cuft (82 cuft -> 45 cuft) but if the cylinder doesn't have starting/ending pressures (and thus no used gas information), this patch will make subsurface show the working pressure data instead, so that you at least get something. This all seems more useful than what my first version gave. NOTE! This makes commit adaeb506b7a1 ("Show both the nominal and "real" size for an imperial cylinder") kind of pointless. You now see the real size in the tooltip when you mouse over the size, and now it actually works both for imperial and metric people, so the tooltip is in many ways the better model. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-models/cylindermodel.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp
index c2c94f765..530ea6356 100644
--- a/qt-models/cylindermodel.cpp
+++ b/qt-models/cylindermodel.cpp
@@ -63,6 +63,8 @@ static QString gas_volume_string(int ml, const char *tail)
return QString("%1 %2 %3").arg(vol, 0, 'f', decimals).arg(unit).arg(tail);
}
+static QVariant gas_wp_tooltip(cylinder_t *cyl);
+
static QVariant gas_usage_tooltip(cylinder_t *cyl)
{
pressure_t startp = cyl->start.mbar ? cyl->start : cyl->sample_start;
@@ -75,7 +77,7 @@ static QVariant gas_usage_tooltip(cylinder_t *cyl)
used = (end && start > end) ? start - end : 0;
if (!used)
- return QVariant();
+ return gas_wp_tooltip(cyl);
return gas_volume_string(used, "(") +
gas_volume_string(start, " -> ") +
@@ -94,6 +96,11 @@ static QVariant gas_volume_tooltip(cylinder_t *cyl, pressure_t p)
return gas_volume_string(vol, "(Z=") + QString("%1)").arg(Z, 0, 'f', 3);
}
+static QVariant gas_wp_tooltip(cylinder_t *cyl)
+{
+ return gas_volume_tooltip(cyl, cyl->type.workingpressure);
+}
+
static QVariant gas_start_tooltip(cylinder_t *cyl)
{
return gas_volume_tooltip(cyl, cyl->start.mbar ? cyl->start : cyl->sample_start);
@@ -228,9 +235,11 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
case REMOVE:
ret = tr("Clicking here will remove this cylinder.");
break;
+ case TYPE:
case SIZE:
- case WORKINGPRESS:
return gas_usage_tooltip(cyl);
+ case WORKINGPRESS:
+ return gas_wp_tooltip(cyl);
case START:
return gas_start_tooltip(cyl);
case END: