summaryrefslogtreecommitdiffstats
path: root/qt-gui.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-09-22 12:37:49 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-09-22 12:37:49 -0700
commit6ce5704435a761aeb7a8b7cb7bc9049ed3ee4ac9 (patch)
tree4d54b92c43a3b4e026ccabd6cd69bee3b4de61f2 /qt-gui.cpp
parentff58fd7dcadf5af1333e4137449812cc5ad2524b (diff)
downloadsubsurface-6ce5704435a761aeb7a8b7cb7bc9049ed3ee4ac9.tar.gz
Support imperial measurements in dive planner / add dive
This was not as hard as I assumed it would be. I may still change the horizontal dimension to be the more logical seconds instead of minutes, but for now this achieves the main goal. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-gui.cpp')
-rw-r--r--qt-gui.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/qt-gui.cpp b/qt-gui.cpp
index e35c22996..cb06bf8d5 100644
--- a/qt-gui.cpp
+++ b/qt-gui.cpp
@@ -195,17 +195,22 @@ void set_dc_nickname(struct dive *dive)
}
}
-QString get_depth_string(depth_t depth, bool showunit)
+QString get_depth_string(int mm, bool showunit, bool showdecimal)
{
if (prefs.units.length == units::METERS) {
- double meters = depth.mm / 1000.0;
- return QString("%1%2").arg(meters, 0, 'f', meters >= 20.0 ? 0 : 1 ).arg(showunit ? _("m") : "");
+ double meters = mm / 1000.0;
+ return QString("%1%2").arg(meters, 0, 'f', (showdecimal && meters < 20.0) ? 1 : 0 ).arg(showunit ? _("m") : "");
} else {
- double feet = mm_to_feet(depth.mm);
- return QString("%1%2").arg(feet, 0, 'f', 1). arg(showunit ? _("ft") : "");
+ double feet = mm_to_feet(mm);
+ return QString("%1%2").arg(feet, 0, 'f', showdecimal ? 1 : 0). arg(showunit ? _("ft") : "");
}
}
+QString get_depth_string(depth_t depth, bool showunit, bool showdecimal)
+{
+ return get_depth_string(depth.mm, showunit, showdecimal);
+}
+
QString get_depth_unit()
{
if (prefs.units.length == units::METERS)