diff options
author | jan Iversen <jan@casacondor.com> | 2020-01-23 16:27:41 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-01-25 17:26:53 -0800 |
commit | 74d13b0554543054033852ee34f315cb9d558bc1 (patch) | |
tree | 9a25f4ba3f96565d784e100cce587b0037787dc1 | |
parent | 14931db0a9ca53956afdb162f8818a5ed61060a4 (diff) | |
download | subsurface-74d13b0554543054033852ee34f315cb9d558bc1.tar.gz |
diveplanner: move mobile specific calc to diveplannermodel
setBottomSac, setDecoSac and setFactor in diveplannermodel
receives display value which are then converted.
subsurface-mobile have slightly different values, move the
correction of these from plannershared to diveplannermodel, in
order to keep the whole convert in one place.
Signed-off-by: jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | backend-shared/plannershared.cpp | 13 | ||||
-rw-r--r-- | qt-models/diveplannermodel.cpp | 12 |
2 files changed, 12 insertions, 13 deletions
diff --git a/backend-shared/plannershared.cpp b/backend-shared/plannershared.cpp index c2eb88ea3..df8a76452 100644 --- a/backend-shared/plannershared.cpp +++ b/backend-shared/plannershared.cpp @@ -83,11 +83,6 @@ double plannerShared::bottomsac() } 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); } @@ -104,11 +99,6 @@ double plannerShared::decosac() } 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); } @@ -124,9 +114,6 @@ double plannerShared::sacfactor() } void plannerShared::set_sacfactor(double value) { -#ifdef SUBSURFACE_MOBILE - value /= 10.0; -#endif // NO conversion, this is done in the planner model. DivePlannerPointsModel::instance()->setSacFactor(value); } diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 7694b185e..f290bebfc 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -7,6 +7,7 @@ #include "core/device.h" #include "core/qthelper.h" #include "core/settings/qPrefDivePlanner.h" +#include "core/settings/qPrefUnit.h" #if not defined(SUBSURFACE_MOBILE) && not defined(SUBSURFACE_TESTING) #include "commands/command.h" #endif // SUBSURFACE_MOBILE SUBSURFACE_TESTING @@ -433,6 +434,10 @@ void DivePlannerPointsModel::emitDataChanged() void DivePlannerPointsModel::setBottomSac(double sac) { +#ifdef SUBSURFACE_MOBILE + if (qPrefUnits::volume() == units::CUFT) + sac /= 100; // cuft without decimals (0 - 300) +#endif diveplan.bottomsac = units_to_sac(sac); qPrefDivePlanner::set_bottomsac(diveplan.bottomsac); emitDataChanged(); @@ -440,6 +445,10 @@ void DivePlannerPointsModel::setBottomSac(double sac) void DivePlannerPointsModel::setDecoSac(double sac) { +#ifdef SUBSURFACE_MOBILE + if (qPrefUnits::volume() == units::CUFT) + sac /= 100; // cuft without decimals (0 - 300) +#endif diveplan.decosac = units_to_sac(sac); qPrefDivePlanner::set_decosac(diveplan.decosac); emitDataChanged(); @@ -447,6 +456,9 @@ void DivePlannerPointsModel::setDecoSac(double sac) void DivePlannerPointsModel::setSacFactor(double factor) { +#ifdef SUBSURFACE_MOBILE + factor /= 10.0; +#endif qPrefDivePlanner::set_sacfactor((int) round(factor * 100)); emitDataChanged(); } |