2017-04-27 20:30:36 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-12-04 01:38:04 +01:00
|
|
|
import QtQuick 2.3
|
2017-03-31 16:15:14 +02:00
|
|
|
import QtQuick.Controls 2.0
|
2015-12-04 01:38:04 +01:00
|
|
|
import QtQuick.Dialogs 1.2
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
import org.subsurfacedivelog.mobile 1.0
|
2017-03-31 16:15:14 +02:00
|
|
|
import org.kde.kirigami 2.0 as Kirigami
|
2015-12-04 01:38:04 +01:00
|
|
|
|
|
|
|
Item {
|
2016-01-12 01:15:02 +01:00
|
|
|
id: detailsEdit
|
|
|
|
property int dive_id
|
|
|
|
property int number
|
2016-01-05 06:59:04 -08:00
|
|
|
property alias dateText: txtDate.text
|
2015-12-26 22:57:47 -08:00
|
|
|
property alias locationText: txtLocation.text
|
2016-04-15 05:17:39 -07:00
|
|
|
property alias gpsText: txtGps.text
|
2015-12-26 22:57:47 -08:00
|
|
|
property alias airtempText: txtAirTemp.text
|
|
|
|
property alias watertempText: txtWaterTemp.text
|
2016-05-16 19:59:05 +02:00
|
|
|
property alias suitIndex: suitBox.currentIndex
|
2017-04-14 17:09:09 -07:00
|
|
|
property alias suitText: suitBox.text
|
2016-05-16 19:59:05 +02:00
|
|
|
property alias buddyIndex: buddyBox.currentIndex
|
2017-04-14 17:09:09 -07:00
|
|
|
property alias buddyText: buddyBox.text
|
2016-05-16 19:59:05 +02:00
|
|
|
property alias divemasterIndex: divemasterBox.currentIndex
|
2017-04-14 17:09:09 -07:00
|
|
|
property alias divemasterText: divemasterBox.text
|
2016-08-30 16:24:19 +02:00
|
|
|
property alias cylinderIndex: cylinderBox.currentIndex
|
2017-04-14 17:09:09 -07:00
|
|
|
property alias cylinderText: cylinderBox.text
|
2015-12-26 22:57:47 -08:00
|
|
|
property alias notesText: txtNotes.text
|
2016-01-01 00:23:15 -08:00
|
|
|
property alias durationText: txtDuration.text
|
2016-01-01 00:32:30 -08:00
|
|
|
property alias depthText: txtDepth.text
|
2016-01-28 18:26:37 -08:00
|
|
|
property alias weightText: txtWeight.text
|
2016-02-09 17:20:17 +01:00
|
|
|
property alias startpressureText: txtStartPressure.text
|
|
|
|
property alias endpressureText: txtEndPressure.text
|
2016-02-13 18:34:31 +01:00
|
|
|
property alias gasmixText: txtGasMix.text
|
2016-04-15 05:17:39 -07:00
|
|
|
property alias gpsCheckbox: checkboxGPS.checked
|
2016-05-20 18:48:36 +02:00
|
|
|
property alias suitModel: suitBox.model
|
|
|
|
property alias divemasterModel: divemasterBox.model
|
|
|
|
property alias buddyModel: buddyBox.model
|
2016-08-30 16:24:19 +02:00
|
|
|
property alias cylinderModel: cylinderBox.model
|
2016-01-28 18:26:37 -08:00
|
|
|
|
2016-02-13 21:25:10 -08:00
|
|
|
function saveData() {
|
|
|
|
// apply the changes to the dive_table
|
|
|
|
manager.commitChanges(dive_id, detailsEdit.dateText, detailsEdit.locationText, detailsEdit.gpsText, detailsEdit.durationText,
|
2017-04-04 21:49:02 +02:00
|
|
|
detailsEdit.depthText, detailsEdit.airtempText, detailsEdit.watertempText, suitBox.text, buddyBox.text,
|
|
|
|
divemasterBox.text, detailsEdit.weightText, detailsEdit.notesText, detailsEdit.startpressureText,
|
|
|
|
detailsEdit.endpressureText, detailsEdit.gasmixText, cylinderBox.text)
|
2016-02-28 15:49:21 +01:00
|
|
|
// trigger the profile to be redrawn
|
|
|
|
QMLProfile.diveId = dive_id
|
|
|
|
|
2016-02-13 21:25:10 -08:00
|
|
|
// apply the changes to the dive detail view - since the edit could have changed the order
|
|
|
|
// first make sure that we are looking at the correct dive - our model allows us to look
|
|
|
|
// up the index based on the unique dive_id
|
2016-03-02 09:02:00 -08:00
|
|
|
var newIdx = diveModel.getIdxForId(dive_id)
|
|
|
|
diveDetailsListView.currentIndex = newIdx
|
2016-02-13 21:25:10 -08:00
|
|
|
diveDetailsListView.currentItem.modelData.date = detailsEdit.dateText
|
|
|
|
diveDetailsListView.currentItem.modelData.location = detailsEdit.locationText
|
|
|
|
diveDetailsListView.currentItem.modelData.duration = detailsEdit.durationText
|
|
|
|
diveDetailsListView.currentItem.modelData.depth = detailsEdit.depthText
|
|
|
|
diveDetailsListView.currentItem.modelData.airtemp = detailsEdit.airtempText
|
|
|
|
diveDetailsListView.currentItem.modelData.watertemp = detailsEdit.watertempText
|
2016-05-16 19:59:05 +02:00
|
|
|
diveDetailsListView.currentItem.modelData.suit = suitBox.currentText
|
|
|
|
diveDetailsListView.currentItem.modelData.buddy = buddyBox.currentText
|
|
|
|
diveDetailsListView.currentItem.modelData.divemaster = divemasterBox.currentText
|
2016-08-30 16:24:19 +02:00
|
|
|
diveDetailsListView.currentItem.modelData.cylinder = cylinderBox.currentText
|
2016-02-13 21:25:10 -08:00
|
|
|
diveDetailsListView.currentItem.modelData.notes = detailsEdit.notesText
|
|
|
|
diveDetailsPage.state = "view"
|
|
|
|
Qt.inputMethod.hide()
|
2016-03-02 04:47:51 -08:00
|
|
|
// now make sure we directly show the saved dive (this may be a new dive, or it may have moved)
|
2016-03-02 09:02:00 -08:00
|
|
|
showDiveIndex(newIdx)
|
2016-02-13 21:25:10 -08:00
|
|
|
}
|
|
|
|
|
2016-01-20 14:07:06 -08:00
|
|
|
height: editArea.height
|
2016-04-07 12:07:44 -07:00
|
|
|
width: diveDetailsPage.width - diveDetailsPage.leftPadding - diveDetailsPage.rightPadding
|
2015-12-04 01:38:04 +01:00
|
|
|
ColumnLayout {
|
2016-01-20 14:07:06 -08:00
|
|
|
id: editArea
|
2016-03-08 21:26:54 +01:00
|
|
|
spacing: Kirigami.Units.smallSpacing
|
2016-04-07 12:07:44 -07:00
|
|
|
width: parent.width - 2 * Kirigami.Units.gridUnit
|
2015-12-04 01:38:04 +01:00
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
id: editorDetails
|
|
|
|
width: parent.width
|
|
|
|
columns: 2
|
|
|
|
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Heading {
|
2015-12-04 01:38:04 +01:00
|
|
|
Layout.columnSpan: 2
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Dive %1").arg(number)
|
2016-01-05 06:59:04 -08:00
|
|
|
}
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2016-01-05 06:59:04 -08:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Date:")
|
2016-01-05 06:59:04 -08:00
|
|
|
}
|
2017-03-31 16:15:14 +02:00
|
|
|
TextField {
|
2016-01-05 06:59:04 -08:00
|
|
|
id: txtDate;
|
|
|
|
Layout.fillWidth: true
|
2015-12-04 01:38:04 +01:00
|
|
|
}
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2015-12-04 01:38:04 +01:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Location:")
|
2015-12-04 01:38:04 +01:00
|
|
|
}
|
2017-03-31 16:15:14 +02:00
|
|
|
TextField {
|
2016-01-12 01:15:02 +01:00
|
|
|
id: txtLocation;
|
2015-12-04 01:38:04 +01:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-04-15 05:17:39 -07:00
|
|
|
Kirigami.Label {
|
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Coordinates:")
|
2016-04-15 05:17:39 -07:00
|
|
|
}
|
2017-03-31 16:15:14 +02:00
|
|
|
TextField {
|
2016-04-15 05:17:39 -07:00
|
|
|
id: txtGps
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2016-01-01 17:23:29 -08:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Use current\nGPS location:")
|
2016-04-17 22:57:14 -07:00
|
|
|
visible: manager.locationServiceAvailable
|
2016-01-01 17:23:29 -08:00
|
|
|
}
|
|
|
|
CheckBox {
|
|
|
|
id: checkboxGPS
|
2016-04-17 22:57:14 -07:00
|
|
|
visible: manager.locationServiceAvailable
|
2016-01-01 17:23:29 -08:00
|
|
|
onCheckedChanged: {
|
|
|
|
if (checked)
|
|
|
|
gpsText = manager.getCurrentPosition()
|
|
|
|
}
|
|
|
|
}
|
2015-12-26 22:57:47 -08:00
|
|
|
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2016-01-01 00:32:30 -08:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Depth:")
|
2016-01-01 00:32:30 -08:00
|
|
|
}
|
2017-03-31 16:15:14 +02:00
|
|
|
TextField {
|
2016-01-01 00:32:30 -08:00
|
|
|
id: txtDepth
|
|
|
|
Layout.fillWidth: true
|
2016-02-20 21:50:11 -08:00
|
|
|
validator: RegExpValidator { regExp: /[^-]*/ }
|
2016-01-01 00:32:30 -08:00
|
|
|
}
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2016-01-01 00:23:15 -08:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Duration:")
|
2016-01-01 00:23:15 -08:00
|
|
|
}
|
2017-03-31 16:15:14 +02:00
|
|
|
TextField {
|
2016-01-01 00:23:15 -08:00
|
|
|
id: txtDuration
|
|
|
|
Layout.fillWidth: true
|
2016-02-20 21:50:11 -08:00
|
|
|
validator: RegExpValidator { regExp: /[^-]*/ }
|
2016-01-01 00:23:15 -08:00
|
|
|
}
|
|
|
|
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2015-12-04 01:38:04 +01:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Air Temp:")
|
2015-12-04 01:38:04 +01:00
|
|
|
}
|
2017-03-31 16:15:14 +02:00
|
|
|
TextField {
|
2015-12-04 01:38:04 +01:00
|
|
|
id: txtAirTemp
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2015-12-04 01:38:04 +01:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Water Temp:")
|
2015-12-04 01:38:04 +01:00
|
|
|
}
|
2017-03-31 16:15:14 +02:00
|
|
|
TextField {
|
2015-12-04 01:38:04 +01:00
|
|
|
id: txtWaterTemp
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2015-12-04 01:38:04 +01:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Suit:")
|
2015-12-04 01:38:04 +01:00
|
|
|
}
|
2017-03-31 17:41:43 +02:00
|
|
|
HintsTextEdit {
|
2016-05-16 19:59:05 +02:00
|
|
|
id: suitBox
|
2017-03-18 14:20:40 -07:00
|
|
|
model: diveDetailsListView.currentItem ? diveDetailsListView.currentItem.modelData.dive.suitList : null
|
2016-05-16 19:59:05 +02:00
|
|
|
inputMethodHints: Qt.ImhNoPredictiveText
|
2015-12-04 01:38:04 +01:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2015-12-04 01:38:04 +01:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Buddy:")
|
2015-12-04 01:38:04 +01:00
|
|
|
}
|
2017-03-31 17:41:43 +02:00
|
|
|
HintsTextEdit {
|
2016-05-16 19:59:05 +02:00
|
|
|
id: buddyBox
|
2017-03-18 14:20:40 -07:00
|
|
|
model: diveDetailsListView.currentItem ? diveDetailsListView.currentItem.modelData.dive.buddyList : null
|
2016-05-16 19:59:05 +02:00
|
|
|
inputMethodHints: Qt.ImhNoPredictiveText
|
2015-12-04 01:38:04 +01:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2015-12-04 01:38:04 +01:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2017-02-27 12:14:22 +01:00
|
|
|
text: qsTr("Divemaster:")
|
2015-12-04 01:38:04 +01:00
|
|
|
}
|
2017-03-31 17:41:43 +02:00
|
|
|
HintsTextEdit {
|
2016-05-16 19:59:05 +02:00
|
|
|
id: divemasterBox
|
2017-03-18 14:20:40 -07:00
|
|
|
model: diveDetailsListView.currentItem ? diveDetailsListView.currentItem.modelData.dive.divemasterList : null
|
2016-05-16 19:59:05 +02:00
|
|
|
inputMethodHints: Qt.ImhNoPredictiveText
|
2015-12-04 01:38:04 +01:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2016-01-28 18:26:37 -08:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Weight:")
|
2016-01-28 18:26:37 -08:00
|
|
|
}
|
2017-03-31 16:15:14 +02:00
|
|
|
TextField {
|
2016-01-28 18:26:37 -08:00
|
|
|
id: txtWeight
|
2017-03-31 16:15:14 +02:00
|
|
|
readOnly: text === "cannot edit multiple weight systems"
|
2016-01-28 18:26:37 -08:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-08-30 16:24:19 +02:00
|
|
|
Kirigami.Label {
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: qsTr("Cylinder:")
|
|
|
|
}
|
2017-03-31 17:41:43 +02:00
|
|
|
HintsTextEdit {
|
2016-08-30 16:24:19 +02:00
|
|
|
id: cylinderBox
|
2017-03-18 14:20:40 -07:00
|
|
|
model: diveDetailsListView.currentItem ? diveDetailsListView.currentItem.modelData.dive.cylinderList : null
|
2016-08-30 16:24:19 +02:00
|
|
|
inputMethodHints: Qt.ImhNoPredictiveText
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2016-02-13 18:34:31 +01:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Gas mix:")
|
2016-02-13 18:34:31 +01:00
|
|
|
}
|
2017-03-31 16:15:14 +02:00
|
|
|
TextField {
|
2016-02-13 18:34:31 +01:00
|
|
|
id: txtGasMix
|
|
|
|
Layout.fillWidth: true
|
2016-04-07 22:56:37 -07:00
|
|
|
validator: RegExpValidator { regExp: /(EAN100|EAN\d\d|AIR|100|\d{1,2}|\d{1,2}\/\d{1,2})/i }
|
2016-02-13 18:34:31 +01:00
|
|
|
}
|
|
|
|
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2016-02-09 17:20:17 +01:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Start Pressure:")
|
2016-02-09 17:20:17 +01:00
|
|
|
}
|
2017-03-31 16:15:14 +02:00
|
|
|
TextField {
|
2016-02-09 17:20:17 +01:00
|
|
|
id: txtStartPressure
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2016-02-09 17:20:17 +01:00
|
|
|
Layout.alignment: Qt.AlignRight
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("End Pressure:")
|
2016-02-09 17:20:17 +01:00
|
|
|
}
|
2017-03-31 16:15:14 +02:00
|
|
|
TextField {
|
2016-02-09 17:20:17 +01:00
|
|
|
id: txtEndPressure
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 21:26:54 +01:00
|
|
|
Kirigami.Label {
|
2016-01-21 13:09:10 -08:00
|
|
|
Layout.columnSpan: 2
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
2016-05-03 21:24:00 +02:00
|
|
|
text: qsTr("Notes:")
|
2015-12-04 01:38:04 +01:00
|
|
|
}
|
|
|
|
TextArea {
|
2016-01-21 13:09:10 -08:00
|
|
|
Layout.columnSpan: 2
|
|
|
|
width: parent.width
|
2015-12-04 01:38:04 +01:00
|
|
|
id: txtNotes
|
2016-01-06 23:03:07 -08:00
|
|
|
textFormat: TextEdit.RichText
|
2015-12-04 01:38:04 +01:00
|
|
|
focus: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2016-03-08 21:26:54 +01:00
|
|
|
Layout.minimumHeight: Kirigami.Units.gridUnit * 6
|
2015-12-04 01:38:04 +01:00
|
|
|
selectByMouse: true
|
|
|
|
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Item {
|
2016-03-08 21:26:54 +01:00
|
|
|
height: Kirigami.Units.gridUnit * 3
|
2015-12-04 01:38:04 +01:00
|
|
|
width: height // just to make sure the spacer doesn't produce scrollbars, but also isn't null
|
|
|
|
}
|
|
|
|
}
|
2015-12-07 22:24:56 -08:00
|
|
|
}
|