This page is designed to be used with the planner, but also with dive edit in mind.
It includes a ListModel for cylinder types. Ideally it would share qt-models/tankinfomodel with the desktop app instead. Signed-off-by: Rick Walsh <[email protected]> --- qt-mobile/qml/CylinderDetailsEdit.qml | 242 ++++++++++++++++++++++++++++++++++ qt-mobile/qml/mobile-resources.qrc | 1 + 2 files changed, 243 insertions(+) create mode 100644 qt-mobile/qml/CylinderDetailsEdit.qml diff --git a/qt-mobile/qml/CylinderDetailsEdit.qml b/qt-mobile/qml/CylinderDetailsEdit.qml new file mode 100644 index 0000000..69eebed --- /dev/null +++ b/qt-mobile/qml/CylinderDetailsEdit.qml @@ -0,0 +1,242 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 +import QtQuick.Dialogs 1.2 +import QtQuick.Layouts 1.1 +import org.subsurfacedivelog.mobile 1.0 +import org.kde.plasma.mobilecomponents 0.2 as MobileComponents + +MobileComponents.Page { + id: cylinderDetailsWindow + width: parent.width + objectName: "CylinderDetails" + signal cylinderOk() + + + // Properties correlate to subsurface-core types cylinder_t, cylinder_type_t, gasmix + property alias cylinderSizeText: txtCylinderSize.text + property int cylinderSizeMl: 1000 * Number(cylinderSizeText) + property int cylinderWorkingPressureMbar: 1000 * Number(txtCylinderWorkingPressure.text) + property string cylinderDescriptionText + property alias pcO2Text: txtPcO2.text + property alias pcHeText: txtPcHe.text + property int o2Pm: 10 * (Number(pcO2Text) > 0 ? pcO2Text : 21) + property int hePm: 10 * Number(pcHeText) + property int pressureStartMbar: 10 * Number(txtPressureStart.text) + property int pressureEndMbar: 10 * Number(txtPressureEnd.text) + property int gasDepthMm: 1000 * 3 * Math.floor(Number(10 * 1.6 * 1000 / o2Pm - 10) / 3) + property alias gasNameText: txtGasName.text + property int gasIndex + + property bool isPlanner: false + + function setGas(gasDescription) { + gasIndex = cylinderComboBox.find(gasDescription) + cylinderComboBox.currentIndex = gasIndex + if (gasIndex >= 0) + cylinderSizeText = (Number(cylinderTypeModel.get(gasIndex).sizeml) * 0.001).toFixed(2) //round to 2 dp + + } + ColumnLayout { + anchors { + left: parent.left + right: parent.right + top: parent.top + } + spacing: MobileComponents.Units.smallSpacing + + + GridLayout { + id: cylinderEditorDetails + width: parent.width + columns: 2 + + MobileComponents.Heading { + Layout.columnSpan: 2 + text: "Cylinder" + } + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "Type:" + } + ComboBox { + id: cylinderComboBox + model: cylinderTypeModel + textRole: "cylinderType" + onCurrentIndexChanged: { + cylinderDescriptionText = cylinderTypeModel.get(currentIndex).cylinderType + cylinderSizeText = (Number(cylinderTypeModel.get(currentIndex).sizeml) * 0.001).toFixed(2) //round to 2 dp + } + } + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "Size:" + } + TextField { + id: txtCylinderSize + inputMethodHints: Qt.ImhFormattedNumbersOnly + validator: DoubleValidator {bottom: 0; top: 1000; decimals:2; notation: DoubleValidator.StandardNotation} + Layout.fillWidth: true + onEditingFinished: cylinderDescriptionText = cylinderSizeText + "ℓ" + } + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "Working pressure:" + visible: !isPlanner + } + TextField { + id: txtCylinderWorkingPressure + inputMethodHints: Qt.ImhFormattedNumbersOnly + Layout.fillWidth: true + visible: !isPlanner + } + + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "Start pressure:" + } + TextField { + id: txtPressureStart + inputMethodHints: Qt.ImhFormattedNumbersOnly + Layout.fillWidth: true + } + + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "End pressure:" + visible: !isPlanner + } + TextField { + id: txtPressureEnd + inputMethodHints: Qt.ImhFormattedNumbersOnly + Layout.fillWidth: true + visible: !isPlanner + } + + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "O2:" + } + TextField { + id: txtPcO2 + inputMethodHints: Qt.ImhFormattedNumbersOnly + validator: DoubleValidator {bottom: 0; top: 100; decimals:1; notation: DoubleValidator.StandardNotation} + Layout.fillWidth: true + } + + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "He:" + } + TextField { + id: txtPcHe + inputMethodHints: Qt.ImhFormattedNumbersOnly + validator: DoubleValidator {bottom: 0; top: 100; decimals:1; notation: DoubleValidator.StandardNotation} + Layout.fillWidth: true + } + + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "Gasmix:" + } + MobileComponents.Label { + id: txtGasName + text: { + if (hePm == 0) { + if (o2Pm == 210) + return "air" + else if (o2Pm == 1000) + return "oxygen" + else + return "EAN" + 0.1 * o2Pm + } else { + return 0.1 * o2Pm + "/" + 0.1 * hePm + } + } + } + MobileComponents.Label { + Layout.alignment: Qt.AlignRight + text: "Switch depth:" + } + MobileComponents.Label { + id: txtGasDepth + text: 0.001 * gasDepthMm + "m" + } + Button { + id: okButton + text: "OK" + activeFocusOnPress: true // Without activeFocusOnPress, MOD won't be calculated if user hits ok after entering O2 + onClicked: { + if (o2Pm + hePm > 1000) { + // That smells odd + msgInvalidGas.open() + } else { + print(cylinderDescriptionText) + cylinderDetailsWindow.cylinderOk() + stackView.pop(); + } + } + } + Button { + id: cancelButton + text: "Cancel" + + onClicked: { + stackView.pop(); + } + } + } + Item { + height: MobileComponents.Units.gridUnit * 3 + width: height // just to make sure the spacer doesn't produce scrollbars, but also isn't null + } + } + Component.onCompleted: { + print("cylinderComboBox index:" + cylinderComboBox.find(cylinderDescriptionText)) + cylinderComboBox.currentIndex = cylinderComboBox.find(cylinderDescriptionText) + } + MessageDialog { + id: msgInvalidGas + title: "Invalid gas" + text: "Select a gas mix where O2 + He do not exceed 100%" + } + // TODO: populate cylinder model from the dive log with existing code + ListModel { + id: cylinderTypeModel + ListElement {property string cylinderType: "AL80"; property int sizeml: 11094; property int workPresBar: 207} + ListElement {property string cylinderType: "D12.2 232 bar"; property int sizeml: 24400; property int workPresBar: 232} + ListElement {property string cylinderType: "10.0ℓ"; property int sizeml: 10000} + ListElement {property string cylinderType: "11.1ℓ"; property int sizeml: 11100} + ListElement {property string cylinderType: "AL40"; property int sizeml: 5547; property int workPresBar: 207} + ListElement {property string cylinderType: "AL50"; property int sizeml: 6934; property int workPresBar: 207} + ListElement {property string cylinderType: "AL63"; property int sizeml: 8737; property int workPresBar: 207} + ListElement {property string cylinderType: "AL72"; property int sizeml: 9985; property int workPresBar: 207} + ListElement {property string cylinderType: "AL100"; property int sizeml: 12607; property int workPresBar: 228} + ListElement {property string cylinderType: "ALU7"; property int sizeml: 7000; property int workPresBar: 200} + ListElement {property string cylinderType: "LP85"; property int sizeml: 13395; property int workPresBar: 182} + ListElement {property string cylinderType: "LP95"; property int sizeml: 14971; property int workPresBar: 182} + ListElement {property string cylinderType: "LP108"; property int sizeml: 17020; property int workPresBar: 182} + ListElement {property string cylinderType: "LP121"; property int sizeml: 19069; property int workPresBar: 182} + ListElement {property string cylinderType: "HP65"; property int sizeml: 7857; property int workPresBar: 237} + ListElement {property string cylinderType: "HP80"; property int sizeml: 9670; property int workPresBar: 237} + ListElement {property string cylinderType: "HP100"; property int sizeml: 12087; property int workPresBar: 237} + ListElement {property string cylinderType: "HP119"; property int sizeml: 14384; property int workPresBar: 237} + ListElement {property string cylinderType: "HP130"; property int sizeml: 15713; property int workPresBar: 237} + ListElement {property string cylinderType: "3ℓ 232 bar"; property int sizeml: 3000; property int workPresBar: 232} + ListElement {property string cylinderType: "3ℓ 300 bar"; property int sizeml: 3000; property int workPresBar: 300} + ListElement {property string cylinderType: "10ℓ 300 bar"; property int sizeml: 10000; property int workPresBar: 300} + ListElement {property string cylinderType: "12ℓ 200 bar"; property int sizeml: 12000; property int workPresBar: 200} + ListElement {property string cylinderType: "12ℓ 232 bar"; property int sizeml: 12000; property int workPresBar: 232} + ListElement {property string cylinderType: "12ℓ 300 bar"; property int sizeml: 12000; property int workPresBar: 300} + ListElement {property string cylinderType: "15ℓ 200 bar"; property int sizeml: 15000; property int workPresBar: 200} + ListElement {property string cylinderType: "15ℓ 232 bar"; property int sizeml: 15000; property int workPresBar: 232} + ListElement {property string cylinderType: "D7 300 bar"; property int sizeml: 14000; property int workPresBar: 300} + ListElement {property string cylinderType: "D8.5 232 bar"; property int sizeml: 17000; property int workPresBar: 232} + ListElement {property string cylinderType: "D12 232 bar"; property int sizeml: 24000; property int workPresBar: 232} + ListElement {property string cylinderType: "D13 232 bar"; property int sizeml: 26000; property int workPresBar: 232} + ListElement {property string cylinderType: "D15 232 bar"; property int sizeml: 30000; property int workPresBar: 232} + ListElement {property string cylinderType: "D16 232 bar"; property int sizeml: 32000; property int workPresBar: 232} + ListElement {property string cylinderType: "D18 232 bar"; property int sizeml: 36000; property int workPresBar: 232} + ListElement {property string cylinderType: "D20 232 bar"; property int sizeml: 40000; property int workPresBar: 232} + } +} diff --git a/qt-mobile/qml/mobile-resources.qrc b/qt-mobile/qml/mobile-resources.qrc index e57fa5e..77ec4ff 100644 --- a/qt-mobile/qml/mobile-resources.qrc +++ b/qt-mobile/qml/mobile-resources.qrc @@ -9,6 +9,7 @@ <file>DiveDetailsEdit.qml</file> <file>DiveDetailsView.qml</file> <file>DownloadFromDiveComputer.qml</file> + <file>CylinderDetailsEdit.qml</file> <file>GpsList.qml</file> <file>Log.qml</file> <file>TopBar.qml</file> -- 2.5.0 _______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
