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