2015-07-21 12:00:29 +00:00
|
|
|
import QtQuick 2.3
|
2015-12-04 02:38:58 +00:00
|
|
|
import QtQuick.Controls 1.4
|
2015-07-27 16:55:18 +00:00
|
|
|
import QtQuick.Controls.Styles 1.2
|
2015-07-21 12:00:29 +00:00
|
|
|
import QtQuick.Dialogs 1.2
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
import org.subsurfacedivelog.mobile 1.0
|
2015-11-29 20:13:57 +00:00
|
|
|
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
|
2015-07-21 12:00:29 +00:00
|
|
|
|
2015-11-29 20:13:57 +00:00
|
|
|
MobileComponents.Page {
|
2015-07-21 12:00:29 +00:00
|
|
|
id: diveDetailsWindow
|
|
|
|
width: parent.width
|
2015-08-20 08:44:01 +00:00
|
|
|
objectName: "DiveDetails"
|
2015-07-21 12:00:29 +00:00
|
|
|
|
|
|
|
property string location
|
2015-12-26 21:22:50 +00:00
|
|
|
property string gps
|
2015-12-04 01:28:48 +00:00
|
|
|
property string depth
|
2015-07-21 12:00:29 +00:00
|
|
|
property string dive_id
|
2015-12-04 01:28:48 +00:00
|
|
|
property string diveNumber
|
|
|
|
property string duration
|
2015-07-21 12:00:29 +00:00
|
|
|
property string airtemp
|
|
|
|
property string watertemp
|
|
|
|
property string suit
|
2015-12-04 01:28:48 +00:00
|
|
|
property int rating
|
2015-07-21 12:00:29 +00:00
|
|
|
property string buddy
|
|
|
|
property string divemaster;
|
|
|
|
property string notes;
|
2015-07-27 19:26:51 +00:00
|
|
|
property string date
|
|
|
|
property string number
|
2015-12-04 01:28:48 +00:00
|
|
|
property string weight
|
|
|
|
state: "view"
|
2015-07-21 12:00:29 +00:00
|
|
|
|
2015-12-04 00:38:04 +00:00
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "view"
|
|
|
|
PropertyChanges { target: detailsView; opacity: 1 }
|
|
|
|
PropertyChanges { target: detailsEdit; opacity: 0 }
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "edit"
|
|
|
|
PropertyChanges { target: detailsView; opacity: 0 }
|
|
|
|
PropertyChanges { target: detailsEdit; opacity: 1 }
|
|
|
|
}
|
|
|
|
]
|
2016-01-07 02:11:24 +00:00
|
|
|
property list<Action> viewActions: [
|
2015-12-04 02:32:52 +00:00
|
|
|
Action {
|
2016-01-07 02:11:24 +00:00
|
|
|
id: editSelector
|
|
|
|
text: "Edit"
|
|
|
|
iconName: "document-edit"
|
2015-12-04 02:32:52 +00:00
|
|
|
onTriggered: {
|
2016-01-07 02:11:24 +00:00
|
|
|
diveDetailsWindow.state = "edit"
|
|
|
|
contextDrawer.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
property list<Action> editActions: [
|
|
|
|
Action {
|
|
|
|
id: cancelSelector
|
|
|
|
text: "Cancel"
|
|
|
|
iconName: "dialog-cancel"
|
|
|
|
onTriggered: {
|
|
|
|
// reset the fields in the edit screen
|
|
|
|
detailsEdit.dateText = date
|
|
|
|
detailsEdit.locationText = location
|
|
|
|
detailsEdit.durationText = duration
|
|
|
|
detailsEdit.depthText = depth
|
|
|
|
detailsEdit.airtempText = airtemp
|
|
|
|
detailsEdit.watertempText = watertemp
|
|
|
|
detailsEdit.suitText = suit
|
|
|
|
detailsEdit.buddyText = buddy
|
|
|
|
detailsEdit.divemasterText = divemaster
|
|
|
|
detailsEdit.notesText = notes
|
|
|
|
// back to view state and close the drawer
|
|
|
|
diveDetailsWindow.state = "view"
|
|
|
|
contextDrawer.close()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Action {
|
|
|
|
id: saveSelector
|
|
|
|
text: "Save"
|
|
|
|
iconName: "document-save"
|
|
|
|
onTriggered: {
|
|
|
|
// 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.notesText)
|
|
|
|
// apply the changes to the dive detail view
|
|
|
|
date = detailsEdit.dateText
|
|
|
|
location = detailsEdit.locationText
|
|
|
|
duration = detailsEdit.durationText
|
|
|
|
depth = detailsEdit.depthText
|
|
|
|
airtemp = detailsEdit.airtempText
|
|
|
|
watertemp = detailsEdit.watertempText
|
|
|
|
suit = detailsEdit.suitText
|
|
|
|
buddy = detailsEdit.buddyText
|
|
|
|
divemaster = detailsEdit.divemasterText
|
|
|
|
notes = detailsEdit.notesText
|
|
|
|
// back to view state and close the drawer
|
|
|
|
diveDetailsWindow.state = "view"
|
2016-01-01 02:09:10 +00:00
|
|
|
contextDrawer.close()
|
2015-12-04 02:32:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2016-01-07 02:11:24 +00:00
|
|
|
contextualActions: diveDetailsWindow.state === "view" ? viewActions : editActions
|
2015-12-04 02:32:52 +00:00
|
|
|
|
2015-11-30 00:12:47 +00:00
|
|
|
ScrollView {
|
2015-11-11 23:40:13 +00:00
|
|
|
anchors.fill: parent
|
2015-11-30 00:12:47 +00:00
|
|
|
Flickable {
|
|
|
|
id: flick
|
|
|
|
anchors.fill: parent
|
|
|
|
contentHeight: content.height
|
2015-12-07 17:10:55 +00:00
|
|
|
interactive: contentHeight > height
|
2015-11-30 00:12:47 +00:00
|
|
|
clip: true
|
|
|
|
Item {
|
|
|
|
id: content
|
|
|
|
width: flick.width
|
|
|
|
height: childrenRect.height + MobileComponents.Units.smallSpacing * 2
|
|
|
|
|
2015-12-04 00:38:04 +00:00
|
|
|
DiveDetailsEdit {
|
|
|
|
id: detailsEdit
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
top: parent.top
|
2015-12-07 17:10:55 +00:00
|
|
|
margins: MobileComponents.Units.gridUnit / 2
|
2015-12-04 00:38:04 +00:00
|
|
|
}
|
2015-12-07 17:10:55 +00:00
|
|
|
visible: opacity > 0
|
2015-12-04 00:38:04 +00:00
|
|
|
|
|
|
|
Behavior on opacity {
|
|
|
|
NumberAnimation { duration: MobileComponents.Units.shortDuration }
|
|
|
|
}
|
|
|
|
}
|
2015-12-04 01:28:48 +00:00
|
|
|
DiveDetailsView {
|
2015-12-04 00:38:04 +00:00
|
|
|
id: detailsView
|
2015-11-30 00:12:47 +00:00
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
top: parent.top
|
2015-12-07 17:10:55 +00:00
|
|
|
margins: MobileComponents.Units.gridUnit / 2
|
2015-11-30 00:12:47 +00:00
|
|
|
}
|
2015-12-07 17:10:55 +00:00
|
|
|
visible: opacity > 0
|
2015-11-30 00:12:47 +00:00
|
|
|
|
2015-12-04 00:38:04 +00:00
|
|
|
Behavior on opacity {
|
|
|
|
NumberAnimation { duration: MobileComponents.Units.shortDuration }
|
|
|
|
}
|
|
|
|
|
2015-07-21 12:00:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|