From 6ce5704435a761aeb7a8b7cb7bc9049ed3ee4ac9 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 22 Sep 2013 12:37:49 -0700 Subject: 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 --- qt-gui.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'qt-gui.cpp') 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) -- cgit v1.2.3-70-g09d2