QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RallyTabPage.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3
4import QGroundControl
5import QGroundControl.Controls
6
7import "PlanPanelLogic.js" as Logic
8
9/// Rally Points tab: the list of points and the inspector of the current one
10ColumnLayout {
11 id: root
12
13 required property var planMasterController
14
15 readonly property var controller: planMasterController.rallyPointController
16 readonly property var points: controller.points
17 readonly property var current: controller.currentRallyPoint
18 readonly property bool supported: controller.supported
19 readonly property int currentIndex: indexOfPoint(current)
20
21 function indexOfPoint(point) {
22 for (let i = 0; i < points.count; i++) {
23 if (points.get(i) === point) {
24 return i
25 }
26 }
27 return -1
28 }
29
30 function select(point) {
31 controller.currentRallyPoint = point
32 }
33
34 function step(delta) {
35 if (!mainWindow.allowViewSwitch()) {
36 return
37 }
38 const index = Logic.steppedIndex(currentIndex, delta, points.count)
39 if (index >= 0) {
40 select(points.get(index))
41 }
42 }
43
44 function deleteCurrent() {
45 if (current) {
46 controller.removePoint(current)
47 }
48 }
49
50 function openInspector() {
51 listInspector.openInspector()
52 }
53
54 objectName: "planPanel_page_rally"
55 spacing: ScreenTools.defaultFontPixelHeight * 0.3
56
57 QGCPalette { id: qgcPal }
58
59 Connections {
60 target: root.controller
61
62 function onCurrentRallyPointChanged() {
63 if (root.controller.currentRallyPoint) {
64 root.openInspector()
65 }
66 }
67 }
68
69 QGCLabel {
70 objectName: "planPanel_rallyHeader"
71 Layout.fillWidth: true
72 Layout.margins: ScreenTools.defaultFontPixelWidth
73 wrapMode: Text.WordWrap
74 color: qgcPal.textSecondary
75 font.pointSize: ScreenTools.smallFontPointSize
76 text: root.supported ?
77 qsTr("Rally Points provide alternate landing points when performing a Return to Launch (RTL). Click in the map to add a point.") :
78 qsTr("This vehicle does not support Rally Points.")
79 }
80
81 PlanListInspector {
82 id: listInspector
83
84 objectName: "planPanel_rallyListInspector"
85 Layout.fillWidth: true
86 Layout.fillHeight: true
87 visible: root.supported
88 hasSelection: root.current !== null
89 listComponent: rallyListComponent
90 inspectorComponent: rallyInspectorComponent
91 }
92
93 Component {
94 id: rallyListComponent
95
96 RallyPointList {
97 page: root
98 }
99 }
100
101 Component {
102 id: rallyInspectorComponent
103
104 RallyPointInspector {
105 page: root
106 drillIn: listInspector.layoutMode === "drillIn"
107 }
108 }
109}