QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
AltModeCombo.qml
Go to the documentation of this file.
1import QtQuick
2
3import QGroundControl
4import QGroundControl.Controls
5
6QGCComboBox {
7 required property int altitudeMode
8 required property var vehicle
9
10 textRole: "modeName"
11
12 onActivated: (index) => {
13 let modeValue = altModeModel.get(index).modeValue
14 altitudeMode = modeValue
15 }
16
17 ListModel {
18 id: altModeModel
19
20 ListElement {
21 modeName: qsTr("Relative")
22 modeValue: QGroundControl.AltitudeModeRelative
23 }
24 ListElement {
25 modeName: qsTr("Absolute")
26 modeValue: QGroundControl.AltitudeModeAbsolute
27 }
28 ListElement {
29 modeName: qsTr("Terrain")
30 modeValue: QGroundControl.AltitudeModeTerrainFrame
31 }
32 ListElement {
33 modeName: qsTr("TerrainC")
34 modeValue: QGroundControl.AltitudeModeCalcAboveTerrain
35 }
36 }
37
38 Component.onCompleted: {
39 let removeModes = []
40
41 if (!QGroundControl.corePlugin.options.showMissionAbsoluteAltitude && altitudeMode != QGroundControl.AltitudeModeAbsolute) {
42 removeModes.push(QGroundControl.AltitudeModeAbsolute)
43 }
44 if (!vehicle.supports.terrainFrame) {
45 removeModes.push(QGroundControl.AltitudeModeTerrainFrame)
46 }
47
48 // Remove modes specified by consumer
49 for (var i=0; i<removeModes.length; i++) {
50 for (var j=0; j<altModeModel.count; j++) {
51 if (altModeModel.get(j).modeValue == removeModes[i]) {
52 altModeModel.remove(j)
53 break
54 }
55 }
56 }
57
58 model = altModeModel
59
60 // Find the specified alt mode in the model
61 for (var k=0; k<altModeModel.count; k++) {
62 if (altModeModel.get(k).modeValue == altitudeMode) {
63 currentIndex = k
64 break
65 }
66 }
67 }
68}