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>
This commit is contained in:
jan Iversen 2020-01-08 12:06:23 +01:00 committed by Dirk Hohndel
parent 5548376776
commit cd3c2266f9
6 changed files with 49 additions and 18 deletions

View file

@ -22,8 +22,8 @@ Kirigami.ScrollablePage {
spinDescrate.value = Backend.descrate
}
onVolumeChanged: {
spinBottomsac.value = Planner.bottomsac
spinDecosac.value = Planner.decosac
spinBottomsac.value = Backend.bottomsac
spinDecosac.value = Backend.decosac
}
}
Column {
@ -227,14 +227,16 @@ Kirigami.ScrollablePage {
TemplateSpinBox {
id: spinBottomsac
from: 1
to: 99
to: (Backend.volume === Enums.LITER) ? 85 : 300
stepSize: 1
value: Planner.bottomsac
value: Backend.bottomsac
textFromValue: function (value, locale) {
return value + volumeUnit
return (Backend.volume === Enums.LITER) ?
value + volumeUnit :
(value / 100).toFixed(2) + volumeUnit
}
onValueModified: {
Planner.bottomsac = value
Backend.bottomsac = value
}
}
TemplateLabel {
@ -243,14 +245,16 @@ Kirigami.ScrollablePage {
TemplateSpinBox {
id: spinDecosac
from: 1
to: 99
to: (Backend.volume === Enums.LITER) ? 85 : 300
stepSize: 1
value: Planner.decosac
value: Backend.decosac
textFromValue: function (value, locale) {
return value + volumeUnit
return (Backend.volume === Enums.LITER) ?
value + volumeUnit :
(value / 100).toFixed(2) + volumeUnit
}
onValueModified: {
Planner.decosac = value
Backend.decosac = value
}
}
TemplateLabel {

View file

@ -65,6 +65,10 @@ void QMLInterface::setup(QQmlContext *ct)
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::problemsolvingtimeChanged,
instance(), &QMLInterface::problemsolvingtimeChanged);
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::bottomsacChanged,
instance(), &QMLInterface::bottomsacChanged);
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::decosacChanged,
instance(), &QMLInterface::decosacChanged);
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::display_runtimeChanged,
instance(), &QMLInterface::display_runtimeChanged);
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::display_durationChanged,

View file

@ -6,6 +6,7 @@
#include "core/settings/qPrefDivePlanner.h"
#include "core/settings/qPrefTechnicalDetails.h"
#include "qt-models/diveplannermodel.h"
#include "backend-shared/plannershared.h"
#include <QObject>
#include <QQmlContext>