summaryrefslogtreecommitdiff
path: root/src/SetPointPage.qml
diff options
context:
space:
mode:
authorArseniy Movshev <dodoradio@outlook.com>2023-01-08 00:13:02 +0000
committerArseniy Movshev <dodoradio@outlook.com>2023-01-15 16:58:12 +0000
commit1f81686f00869dce6cc33e1bc92bf24370ef3e12 (patch)
treeaae5631666d35e87ba707219faba512f31b3934a /src/SetPointPage.qml
parent7dfd22e942567bf151a8d373a64e6aed2e662b89 (diff)
switch to using json as the carrier format for waypoints
Diffstat (limited to '')
-rw-r--r--src/SetPointPage.qml49
1 files changed, 39 insertions, 10 deletions
diff --git a/src/SetPointPage.qml b/src/SetPointPage.qml
index 1b5f571..fbd9131 100644
--- a/src/SetPointPage.qml
+++ b/src/SetPointPage.qml
@@ -13,9 +13,24 @@ Item {
id: waypointList
key: "/map/waypointList"
defaultValue: ""
+ Component.onCompleted: {
+ var waypointArray = JSON.parse(waypointList.value)
+ if (editMode) {
+ var currWaypointData = waypointArray[editIndex]
+ root.coord = QtPositioning.coordinate(currWaypointData[1][0],currWaypointData[1][1])
+ root.selectedIcon = currWaypointData[0]
+ root.selectedColor = currWaypointData[2]
+ } else {
+ editIndex = waypointArray.length
+ selectedColor = colours.primary
+ }
+ }
}
property string selectedIcon: "ios-locate-outline"
+ property string selectedColor
property variant coord
+ property bool editMode: false
+ property int editIndex
Flickable {
anchors.fill: parent
contentHeight: contentColumn.implicitHeight
@@ -77,29 +92,43 @@ Item {
Row {
height: root.width*0.2
width: parent.width
+ anchors.horizontalCenter: parent.horizontalCenter
Asteroid.IconButton {
height: parent.height
width: height
- iconName: "ios-checkmark-circle-outline"
- anchors.horizontalCenter: parent.horizontalCenter
- onClicked: appendWayPoint()
+ iconName: "ios-trash-circle"
+ visible: editMode
+ onClicked: removeWaypoint(editIndex)
}
Asteroid.IconButton {
height: parent.height
width: height
- iconName: "ios-trash-circle"
- anchors.horizontalCenter: parent.horizontalCenter
- onClicked: removeWaypoint()
+ iconName: "ios-checkmark-circle-outline"
+ onClicked: commitChanges(editIndex)
}
}
Item { width: parent.width ; height: root.width*0.2 }
}
}
- function appendWayPoint() { //the colours.primary is currently a placeholder. it would be nice to let users select colours, but I CBA to write a colour picker right now.
- var newWayPointString = selectedIcon + ";" + coord.latitude + "," + coord.longitude + ";" + colours.primary + ";" + textBox.text + ";" + Date.now() + ">"
- console.log(newWayPointString)
- waypointList.value = waypointList.value + newWayPointString
+ function commitChanges(index) {
+ var waypointArray = JSON.parse(waypointList.value)
+ var writebuffer = {}
+ writebuffer[0] = selectedIcon
+ writebuffer[1] = [coord.latitude,coord.longitude]
+ writebuffer[2] = selectedColor //the colours.primary is currently a placeholder. it would be nice to let users select colours, but I CBA to write a colour picker right now
+ writebuffer[3] = textBox.text
+ writebuffer[4] = Date.now()
+ waypointArray[index] = writebuffer
+ waypointList.value = JSON.stringify(waypointArray)
+ setPointControls.visible = false
+ mapControls.visible = true
+ pageStack.pop(pageStack.currentLayer)
+ }
+ function removeWaypoint(index) {
+ var waypointArray = JSON.parse(waypointList.value)
+ waypointArray.splice(index)
+ waypointList.value = JSON.stringify(waypointArray)
setPointControls.visible = false
mapControls.visible = true
pageStack.pop(pageStack.currentLayer)