QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
MissionItemStatus.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7import QGroundControl.FactControls
8
9Rectangle {
10 id: root
11 radius: ScreenTools.defaultFontPixelWidth * 0.5
12 color: qgcPal.window
13 opacity: 0.80
14 clip: true
15
16 property var missionItems ///< List of all available mission items
17 property real maxWidth: parent.width
18
19 signal setCurrentSeqNum(int seqNum)
20
21 readonly property real _margins: ScreenTools.defaultFontPixelWidth
22
23 onMaxWidthChanged: {
24 var calcLength = (statusListView.count + 1) * (statusListView.count ? statusListView.contentItem.children[0].width : 1)
25 root.width = root.maxWidth > calcLength ? calcLength : root.maxWidth
26 }
27
28 QGCPalette { id: qgcPal }
29
30 QGCLabel {
31 id: label
32 anchors.top: parent.bottom
33 width: parent.height
34 text: qsTr("Terrain Altitude")
35 horizontalAlignment: Text.AlignHCenter
36 rotation: -90
37 transformOrigin: Item.TopLeft
38 }
39
40 QGCListView {
41 id: statusListView
42 anchors.margins: _margins
43 anchors.top: parent.top
44 anchors.bottom: parent.bottom
45 anchors.leftMargin: ScreenTools.defaultFontPixelHeight
46 anchors.left: parent.left
47 anchors.right: parent.right
48 model: missionItems
49 highlightMoveDuration: 250
50 orientation: ListView.Horizontal
51 spacing: 0
52 clip: true
53 currentIndex: _missionController.currentPlanViewSeqNum
54
55 onCountChanged: {
56 var calcLength = (statusListView.count + 1) * (statusListView.count ? statusListView.contentItem.children[0].width : 1)
57 root.width = root.maxWidth > calcLength ? calcLength : root.maxWidth
58 }
59
60 delegate: Item {
61 height: statusListView.height
62 width: display ? (indicator.width + spacing) : 0
63 visible: display
64
65 property real availableHeight: height - indicator.height
66 property bool _coordValid: object.coordinate.isValid
67 property bool _terrainAvailable: !isNaN(object.terrainPercent)
68 property real _terrainPercent: _terrainAvailable ? object.terrainPercent : 1
69
70 readonly property bool display: object.specifiesCoordinate && !object.isStandaloneCoordinate
71 readonly property real spacing: ScreenTools.defaultFontPixelWidth * ScreenTools.smallFontPointRatio
72
73 Rectangle {
74 anchors.bottom: parent.bottom
75 anchors.horizontalCenter: parent.horizontalCenter
76 width: indicator.width
77 height: _terrainAvailable ? Math.max(availableHeight * _terrainPercent, 1) : parent.height
78 color: _terrainAvailable ? (object.terrainCollision ? "red": qgcPal.text) : "yellow"
79 visible: _coordValid
80 }
81
82 MissionItemIndexLabel {
83 id: indicator
84 anchors.horizontalCenter: parent.horizontalCenter
85 y: availableHeight - (availableHeight * object.altPercent)
86 small: true
87 checked: object.isCurrentItem
88 label: object.abbreviation.charAt(0)
89 index: object.abbreviation.charAt(0) > 'A' && object.abbreviation.charAt(0) < 'z' ? -1 : object.sequenceNumber
90 showSequenceNumbers: false
91 }
92
93 Rectangle {
94 id: indexBackground
95 anchors.leftMargin: -2
96 anchors.rightMargin: -2
97 anchors.fill: indexLabel
98 color: qgcPal.window
99 opacity: 0.3
100 visible: indexLabel.visible
101 transform: Rotation { angle: 90; origin.x: indexBackground.width / 2; origin.y: indexBackground.height / 2 }
102 }
103
104 QGCLabel {
105 id: indexLabel
106 anchors.centerIn: parent
107 text: object.sequenceNumber
108 visible: indicator.index != -1
109 transform: Rotation { angle: 90; origin.x: indexLabel.width / 2; origin.y: indexLabel.height / 2 }
110 }
111
112 MouseArea {
113 anchors.fill: parent
114 onClicked: root.setCurrentSeqNum(object.sequenceNumber)
115 }
116 }
117 }
118}