aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/tab-widgets/TabDiveInformation.cpp
diff options
context:
space:
mode:
authorGravatar willemferguson <willemferguson@zoology.up.ac.za>2019-11-11 08:19:05 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-11-11 22:57:48 +0100
commitebaac21ef54b7f972663cea0022460cf7c281265 (patch)
tree28309b053f99479eec07fdcc75290d04dbec9c8a /desktop-widgets/tab-widgets/TabDiveInformation.cpp
parente434b5aa4066990a1dbf67670e09b650d87be753 (diff)
downloadsubsurface-ebaac21ef54b7f972663cea0022460cf7c281265.tar.gz
Show altitude corresponding to surface pressure
In the information tab, presenting atmospheric pressure is a bit unintuitive because the diver cannot easily relate that to altitude. For the Atm. Pressure widget in the Information tab this code does: If the atmospheric pressure for a dive exists and the user selects the 'm' or 'ft' option from the combobox, then the estimated altitude is shown in the text box. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Diffstat (limited to 'desktop-widgets/tab-widgets/TabDiveInformation.cpp')
-rw-r--r--desktop-widgets/tab-widgets/TabDiveInformation.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp
index b97ca1cdf..d4c5ae1a6 100644
--- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp
+++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp
@@ -249,9 +249,11 @@ void TabDiveInformation::updateTextBox(int event) // Either the text box has bee
double altitudeVal; // maintained even though two independent events trigger saving the text box contents.
if (current_dive) {
switch (ui->atmPressType->currentIndex()) {
- case 0: // If an atm pressure has been specified in mbar:
+ case 0: // If atm pressure in mbar has been selected:
if (event == TEXT_EDITED) // this is only triggered by on_atmPressVal_editingFinished()
atmpress.mbar = ui->atmPressVal->text().toInt(); // use the specified mbar pressure
+ else // if no pressure has been typed, then show existing dive pressure
+ ui->atmPressVal->setText(QString::number(current_dive->surface_pressure.mbar));
break;
case 1: // If an altitude has been specified:
if (event == TEXT_EDITED) { // this is only triggered by on_atmPressVal_editingFinished()
@@ -264,7 +266,15 @@ void TabDiveInformation::updateTextBox(int event) // Either the text box has bee
ui->atmPressVal->setText(ui->atmPressVal->text().sprintf("%d",atmpress.mbar));
ui->atmPressType->setCurrentIndex(0); // reset combobox to mbar
} else { // i.e. event == COMBO_CHANGED, that is, "m" or "ft" was selected from combobox
- ui->atmPressVal->clear(); // Clear the text box so that altitude can be typed
+ // Show estimated altitude
+ bool ok;
+ double convertVal = 0.0010; // Metric conversion fro mm to m
+ int pressure_as_integer = ui->atmPressVal->text().toInt(&ok,10);
+ if (ok && ui->atmPressVal->text().length()) { // Show existing atm press as an altitude:
+ if (prefs.units.length == units::FEET) // For imperial units
+ convertVal = mm_to_feet(1); // convert from mm to ft
+ ui->atmPressVal->setText(QString::number((int)(pressure_to_altitude(pressure_as_integer) * convertVal)));
+ }
}
break;
case 2: // i.e. event = COMBO_CHANGED, that is, the option "Use dc" was selected from combobox