summaryrefslogtreecommitdiffstats
path: root/backend-shared
diff options
context:
space:
mode:
authorGravatar jan Iversen <jan@casacondor.com>2020-01-08 12:06:23 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-01-25 17:13:20 -0800
commitcd3c2266f9f687746770912bfc913c4f94bb124b (patch)
treea5094ecfa0f7c4fda4e97c7da7d093b5682750fe /backend-shared
parent55483767763ca5d7d7c8f299f8939bda38301f1b (diff)
downloadsubsurface-cd3c2266f9f687746770912bfc913c4f94bb124b.tar.gz
dive planner: correct bottomsac/decosac calc.
Move conversion cuft <-> liter from desktop-widget/diveplanner.cpp to plannerShared, to facilitate the same results in mobile diveplanner Use Backend for bottomsac/decosac and update to check for switch LITER <-> CUFT Add bottomsac/decosac to QMLinterface. Signed-off-by: jan Iversen <jan@casacondor.com>
Diffstat (limited to 'backend-shared')
-rw-r--r--backend-shared/plannershared.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/backend-shared/plannershared.cpp b/backend-shared/plannershared.cpp
index 113b0f7e2..542f1aae1 100644
--- a/backend-shared/plannershared.cpp
+++ b/backend-shared/plannershared.cpp
@@ -63,20 +63,42 @@ void plannerShared::set_min_switch_duration(int value)
double plannerShared::bottomsac()
{
- return qPrefDivePlanner::bottomsac() / 1000.0;
+ return (qPrefUnits::volume() == units::LITER) ?
+ qPrefDivePlanner::bottomsac() / 1000.0 :
+ ml_to_cuft(qPrefDivePlanner::bottomsac()
+#ifdef SUBSURFACE_MOBILE
+ * 100 // cuft without decimals (0 - 300)
+#endif
+ );
}
void plannerShared::set_bottomsac(double value)
{
+#ifdef SUBSURFACE_MOBILE
+ if (qPrefUnits::volume() == units::CUFT)
+ value /= 100; // cuft without decimals (0 - 300)
+#endif
+
// NO conversion, this is done in the planner model.
DivePlannerPointsModel::instance()->setBottomSac(value);
}
double plannerShared::decosac()
{
- return qPrefDivePlanner::decosac() / 1000.0;
+ return (qPrefUnits::volume() == units::LITER) ?
+ qPrefDivePlanner::decosac() / 1000.0 :
+ ml_to_cuft(qPrefDivePlanner::decosac()
+#ifdef SUBSURFACE_MOBILE
+ * 100 // cuft without decimals (0 - 300)
+#endif
+ );
}
void plannerShared::set_decosac(double value)
{
+#ifdef SUBSURFACE_MOBILE
+ if (qPrefUnits::volume() == units::CUFT)
+ value /= 100; // cuft without decimals (0 - 300)
+#endif
+
// NO conversion, this is done in the planner model.
DivePlannerPointsModel::instance()->setDecoSac(value);
}