AltitudeFactTextField.qml 1.78 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1
import QtQuick                      2.3
2 3 4 5
import QGroundControl               1.0
import QGroundControl.FactSystem    1.0

FactTextField {
Don Gagne's avatar
Don Gagne committed
6 7 8 9
    unitsLabel:         fact ? fact.units : ""
    extraUnitsLabel:    fact ? _altitudeModeExtraUnits : ""
    showUnits:          true
    showHelp:           true
10 11 12 13

    property int altitudeMode: QGroundControl.AltitudeModeNone

    readonly property string _altModeNoneExtraUnits:            ""
Don Gagne's avatar
Don Gagne committed
14 15 16 17
    readonly property string _altModeRelativeExtraUnits:        qsTr("(Rel)")
    readonly property string _altModeAbsoluteExtraUnits:        qsTr("(AMSL)")
    readonly property string _altModeAboveTerrainExtraUnits:    qsTr("(Abv Terr)")
    readonly property string _altModeTerrainFrameExtraUnits:    qsTr("(TerrF)")
18

Don Gagne's avatar
Don Gagne committed
19 20 21
    property string _altitudeModeExtraUnits: _altModeNoneExtraUnits

    onAltitudeModeChanged: updateAltitudeModeExtraUnits()
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

    function updateAltitudeModeExtraUnits() {
        if (altitudeMode === QGroundControl.AltitudeModeNone) {
            _altitudeModeExtraUnits = _altModeNoneExtraUnits
        } else if (altitudeMode === QGroundControl.AltitudeModeRelative) {
            _altitudeModeExtraUnits = _altModeRelativeExtraUnits
        } else if (altitudeMode === QGroundControl.AltitudeModeAbsolute) {
            _altitudeModeExtraUnits = _altModeAbsoluteExtraUnits
        } else if (altitudeMode === QGroundControl.AltitudeModeAboveTerrain) {
            _altitudeModeExtraUnits = _altModeAboveTerrainExtraUnits
        } else if (missionItem.altitudeMode === QGroundControl.AltitudeModeTerrainFrame) {
            _altitudeModeExtraUnits = _altModeTerrainFrameExtraUnits
        } else {
            console.log("AltitudeFactTextField Internal error: Unknown altitudeMode", altitudeMode)
            _altitudeModeExtraUnits = ""
        }
    }
}