2015-12-04 00:38:04 +00:00
|
|
|
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
|
2016-03-08 20:26:54 +00:00
|
|
|
import org.kde.kirigami 1.0 as Kirigami
|
2015-12-04 00:38:04 +00:00
|
|
|
|
|
|
|
Item {
|
2016-01-12 00:15:02 +00:00
|
|
|
id: detailsEdit
|
|
|
|
property int dive_id
|
|
|
|
property int number
|
2016-01-05 14:59:04 +00:00
|
|
|
property alias dateText: txtDate.text
|
2015-12-27 06:57:47 +00:00
|
|
|
property alias locationText: txtLocation.text
|
2016-04-15 12:17:39 +00:00
|
|
|
property alias gpsText: txtGps.text
|
2015-12-27 06:57:47 +00:00
|
|
|
property alias airtempText: txtAirTemp.text
|
|
|
|
property alias watertempText: txtWaterTemp.text
|
|
|
|
property alias suitText: txtSuit.text
|
|
|
|
property alias buddyText: txtBuddy.text
|
|
|
|
property alias divemasterText: txtDiveMaster.text
|
|
|
|
property alias notesText: txtNotes.text
|
2016-01-01 08:23:15 +00:00
|
|
|
property alias durationText: txtDuration.text
|
2016-01-01 08:32:30 +00:00
|
|
|
property alias depthText: txtDepth.text
|
2016-01-29 02:26:37 +00:00
|
|
|
property alias weightText: txtWeight.text
|
2016-02-09 16:20:17 +00:00
|
|
|
property alias startpressureText: txtStartPressure.text
|
|
|
|
property alias endpressureText: txtEndPressure.text
|
2016-02-13 17:34:31 +00:00
|
|
|
property alias gasmixText: txtGasMix.text
|
2016-04-15 12:17:39 +00:00
|
|
|
property alias gpsCheckbox: checkboxGPS.checked
|
2016-01-29 02:26:37 +00:00
|
|
|
|
2016-02-14 05:25:10 +00:00
|
|
|
function saveData() {
|
|
|
|
// apply the changes to the dive_table
|
|
|
|
manager.commitChanges(dive_id, detailsEdit.dateText, detailsEdit.locationText, detailsEdit.gpsText, detailsEdit.durationText,
|
|
|
|
detailsEdit.depthText, detailsEdit.airtempText, detailsEdit.watertempText, detailsEdit.suitText,
|
|
|
|
detailsEdit.buddyText, detailsEdit.divemasterText, detailsEdit.weightText, detailsEdit.notesText,
|
|
|
|
detailsEdit.startpressureText, detailsEdit.endpressureText, detailsEdit.gasmixText)
|
2016-02-28 14:49:21 +00:00
|
|
|
// trigger the profile to be redrawn
|
|
|
|
QMLProfile.diveId = dive_id
|
|
|
|
|
2016-02-14 05:25:10 +00: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 17:02:00 +00:00
|
|
|
var newIdx = diveModel.getIdxForId(dive_id)
|
|
|
|
diveDetailsListView.currentIndex = newIdx
|
2016-02-14 05:25:10 +00: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
|
|
|
|
diveDetailsListView.currentItem.modelData.suit = detailsEdit.suitText
|
|
|
|
diveDetailsListView.currentItem.modelData.buddy = detailsEdit.buddyText
|
|
|
|
diveDetailsListView.currentItem.modelData.divemaster = detailsEdit.divemasterText
|
|
|
|
diveDetailsListView.currentItem.modelData.notes = detailsEdit.notesText
|
|
|
|
diveDetailsPage.state = "view"
|
|
|
|
Qt.inputMethod.hide()
|
2016-03-02 12:47:51 +00:00
|
|
|
// now make sure we directly show the saved dive (this may be a new dive, or it may have moved)
|
2016-03-02 17:02:00 +00:00
|
|
|
showDiveIndex(newIdx)
|
2016-02-14 05:25:10 +00:00
|
|
|
}
|
|
|
|
|
2016-01-20 22:07:06 +00:00
|
|
|
height: editArea.height
|
2016-04-07 19:07:44 +00:00
|
|
|
width: diveDetailsPage.width - diveDetailsPage.leftPadding - diveDetailsPage.rightPadding
|
2015-12-04 00:38:04 +00:00
|
|
|
ColumnLayout {
|
2016-01-20 22:07:06 +00:00
|
|
|
id: editArea
|
2016-03-08 20:26:54 +00:00
|
|
|
spacing: Kirigami.Units.smallSpacing
|
2016-04-07 19:07:44 +00:00
|
|
|
width: parent.width - 2 * Kirigami.Units.gridUnit
|
2015-12-04 00:38:04 +00:00
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
id: editorDetails
|
|
|
|
width: parent.width
|
|
|
|
columns: 2
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Heading {
|
2015-12-04 00:38:04 +00:00
|
|
|
Layout.columnSpan: 2
|
2016-01-05 14:59:04 +00:00
|
|
|
text: "Dive " + number
|
|
|
|
}
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2016-01-05 14:59:04 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Date:"
|
|
|
|
}
|
2016-04-08 14:30:08 +00:00
|
|
|
StyledTextField {
|
2016-01-05 14:59:04 +00:00
|
|
|
id: txtDate;
|
|
|
|
Layout.fillWidth: true
|
2015-12-04 00:38:04 +00:00
|
|
|
}
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2015-12-04 00:38:04 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Location:"
|
|
|
|
}
|
2016-04-08 14:30:08 +00:00
|
|
|
StyledTextField {
|
2016-01-12 00:15:02 +00:00
|
|
|
id: txtLocation;
|
2015-12-04 00:38:04 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-04-15 12:17:39 +00:00
|
|
|
Kirigami.Label {
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Coordinates:"
|
|
|
|
}
|
|
|
|
StyledTextField {
|
|
|
|
id: txtGps
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2016-01-02 01:23:29 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Use current\nGPS location:"
|
2016-04-18 05:57:14 +00:00
|
|
|
visible: manager.locationServiceAvailable
|
2016-01-02 01:23:29 +00:00
|
|
|
}
|
|
|
|
CheckBox {
|
|
|
|
id: checkboxGPS
|
2016-04-18 05:57:14 +00:00
|
|
|
visible: manager.locationServiceAvailable
|
2016-01-02 01:23:29 +00:00
|
|
|
onCheckedChanged: {
|
|
|
|
if (checked)
|
|
|
|
gpsText = manager.getCurrentPosition()
|
|
|
|
}
|
|
|
|
}
|
2015-12-27 06:57:47 +00:00
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2016-01-01 08:32:30 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Depth:"
|
|
|
|
}
|
2016-04-08 14:30:08 +00:00
|
|
|
StyledTextField {
|
2016-01-01 08:32:30 +00:00
|
|
|
id: txtDepth
|
|
|
|
Layout.fillWidth: true
|
2016-02-21 05:50:11 +00:00
|
|
|
validator: RegExpValidator { regExp: /[^-]*/ }
|
2016-01-01 08:32:30 +00:00
|
|
|
}
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2016-01-01 08:23:15 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Duration:"
|
|
|
|
}
|
2016-04-08 14:30:08 +00:00
|
|
|
StyledTextField {
|
2016-01-01 08:23:15 +00:00
|
|
|
id: txtDuration
|
|
|
|
Layout.fillWidth: true
|
2016-02-21 05:50:11 +00:00
|
|
|
validator: RegExpValidator { regExp: /[^-]*/ }
|
2016-01-01 08:23:15 +00:00
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2015-12-04 00:38:04 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Air Temp:"
|
|
|
|
}
|
2016-04-08 14:30:08 +00:00
|
|
|
StyledTextField {
|
2015-12-04 00:38:04 +00:00
|
|
|
id: txtAirTemp
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2015-12-04 00:38:04 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Water Temp:"
|
|
|
|
}
|
2016-04-08 14:30:08 +00:00
|
|
|
StyledTextField {
|
2015-12-04 00:38:04 +00:00
|
|
|
id: txtWaterTemp
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2015-12-04 00:38:04 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Suit:"
|
|
|
|
}
|
2016-04-08 14:30:08 +00:00
|
|
|
StyledTextField {
|
2015-12-04 00:38:04 +00:00
|
|
|
id: txtSuit
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2015-12-04 00:38:04 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Buddy:"
|
|
|
|
}
|
2016-04-08 14:30:08 +00:00
|
|
|
StyledTextField {
|
2015-12-04 00:38:04 +00:00
|
|
|
id: txtBuddy
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2015-12-04 00:38:04 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Dive Master:"
|
|
|
|
}
|
2016-04-08 14:30:08 +00:00
|
|
|
StyledTextField {
|
2015-12-04 00:38:04 +00:00
|
|
|
id: txtDiveMaster
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2016-01-29 02:26:37 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Weight:"
|
|
|
|
}
|
2016-04-08 14:30:08 +00:00
|
|
|
StyledTextField {
|
2016-01-29 02:26:37 +00:00
|
|
|
id: txtWeight
|
2016-04-08 14:30:08 +00:00
|
|
|
fixed: text === "cannot edit multiple weight systems"
|
2016-01-29 02:26:37 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2016-02-13 17:34:31 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Gas mix:"
|
|
|
|
}
|
2016-04-08 14:30:08 +00:00
|
|
|
StyledTextField {
|
2016-02-13 17:34:31 +00:00
|
|
|
id: txtGasMix
|
2016-04-08 14:30:08 +00:00
|
|
|
fixed: (text == "cannot edit multiple gases" ? true : false)
|
2016-02-13 17:34:31 +00:00
|
|
|
Layout.fillWidth: true
|
2016-04-08 05:56:37 +00:00
|
|
|
validator: RegExpValidator { regExp: /(EAN100|EAN\d\d|AIR|100|\d{1,2}|\d{1,2}\/\d{1,2})/i }
|
2016-02-13 17:34:31 +00:00
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2016-02-09 16:20:17 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "Start Pressure:"
|
|
|
|
}
|
2016-04-08 14:30:08 +00:00
|
|
|
StyledTextField {
|
2016-02-09 16:20:17 +00:00
|
|
|
id: txtStartPressure
|
2016-04-08 14:30:08 +00:00
|
|
|
fixed: (text == "cannot edit multiple cylinders" ? true : false)
|
2016-02-09 16:20:17 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2016-02-09 16:20:17 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
text: "End Pressure:"
|
|
|
|
}
|
2016-04-08 14:30:08 +00:00
|
|
|
StyledTextField {
|
2016-02-09 16:20:17 +00:00
|
|
|
id: txtEndPressure
|
|
|
|
readOnly: (text == "cannot edit multiple cylinders" ? true : false)
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.Label {
|
2016-01-21 21:09:10 +00:00
|
|
|
Layout.columnSpan: 2
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
2015-12-04 00:38:04 +00:00
|
|
|
text: "Notes:"
|
|
|
|
}
|
|
|
|
TextArea {
|
2016-01-21 21:09:10 +00:00
|
|
|
Layout.columnSpan: 2
|
|
|
|
width: parent.width
|
2015-12-04 00:38:04 +00:00
|
|
|
id: txtNotes
|
2016-01-07 07:03:07 +00:00
|
|
|
textFormat: TextEdit.RichText
|
2015-12-04 00:38:04 +00:00
|
|
|
focus: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2016-03-08 20:26:54 +00:00
|
|
|
Layout.minimumHeight: Kirigami.Units.gridUnit * 6
|
2015-12-04 00:38:04 +00:00
|
|
|
selectByMouse: true
|
|
|
|
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Item {
|
2016-03-08 20:26:54 +00:00
|
|
|
height: Kirigami.Units.gridUnit * 3
|
2015-12-04 00:38:04 +00:00
|
|
|
width: height // just to make sure the spacer doesn't produce scrollbars, but also isn't null
|
|
|
|
}
|
|
|
|
}
|
2015-12-08 06:24:56 +00:00
|
|
|
}
|