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>
This commit is contained in:
Dirk Hohndel 2013-09-22 12:37:49 -07:00
parent ff58fd7dca
commit 6ce5704435
3 changed files with 61 additions and 48 deletions

View file

@ -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)