CopterGeoFenceEditor.qml 2.66 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
import QtQuick          2.2
import QtQuick.Controls 1.2

import QGroundControl               1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controls      1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0
import QGroundControl.FlightMap     1.0
import QGroundControl.FactSystem    1.0

Column {
    id:         editorColumn
    width:      availableWidth
    spacing:    _margin

    //property real availableWidth - Available width for control - Must be passed in from Loader

    readonly property real _margin:         ScreenTools.defaultFontPixelWidth / 2
    readonly property real _editFieldWidth: Math.min(width - _margin * 2, ScreenTools.defaultFontPixelWidth * 15)

    QGCLabel {
        anchors.left:   parent.left
        anchors.right:  parent.right
        wrapMode:       Text.WordWrap
        text:           qsTr("Click in map to set breach return point.")
        visible:        geoFenceController.breachReturnSupported
    }

    QGCLabel { text: qsTr("Fence Settings:") }

    Rectangle {
        anchors.left:   parent.left
        anchors.right:  parent.right
        height:         1
        color:          qgcPal.text
    }

    Repeater {
        model: geoFenceController.params

        Item {
            width:  editorColumn.width
            height: textField.height

Don Gagne's avatar
Don Gagne committed
46 47
            property bool showCombo: modelData.enumStrings.length > 0

48 49 50 51 52 53 54 55 56 57 58 59
            QGCLabel {
                id:                 textFieldLabel
                anchors.baseline:   textField.baseline
                text:               geoFenceController.paramLabels[index]
            }

            FactTextField {
                id:             textField
                anchors.right:  parent.right
                width:          _editFieldWidth
                showUnits:      true
                fact:           modelData
Don Gagne's avatar
Don Gagne committed
60
                visible:        !parent.showCombo
61 62 63 64 65 66 67
            }

            FactComboBox {
                id:             comboField
                anchors.right:  parent.right
                width:          _editFieldWidth
                indexModel:     false
Don Gagne's avatar
Don Gagne committed
68 69
                fact:           showCombo ? modelData : _nullFact
                visible:        parent.showCombo
70 71 72 73 74 75 76 77 78 79

                property var _nullFact: Fact { }
            }
        }
    }

    QGCMapPolygonControls {
        anchors.left:   parent.left
        anchors.right:  parent.right
        flightMap:      editorMap
80
        polygon:        geoFenceController.polygon
81 82
        sectionLabel:   qsTr("Fence Polygon:")
        visible:        geoFenceController.polygonSupported
83 84

        onPolygonEditCompleted: geoFenceController.validateBreachReturn()
85 86
    }
}