MissionItemEditor.qml 4.78 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2 3 4 5 6
import QtQuick                  2.2
import QtQuick.Controls         1.2
import QtQuick.Controls.Styles  1.2

import QGroundControl.ScreenTools   1.0
import QGroundControl.Vehicle       1.0
Don Gagne's avatar
Don Gagne committed
7 8
import QGroundControl.Controls      1.0
import QGroundControl.FactControls  1.0
Don Gagne's avatar
Don Gagne committed
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121

/// Mission item edit control
Rectangle {
    property var    missionItem

    width:          _editFieldWidth + (ScreenTools.defaultFontPixelWidth * 10)
    height:         _valueColumn.y + _valueColumn.height + (radius / 2)
    border.width:   2
    border.color:   "white"
    color:          "white"
    radius:         ScreenTools.defaultFontPixelWidth

    readonly property real _editFieldWidth: ScreenTools.defaultFontPixelWidth * 13

    MissionItemIndexLabel {
        id:                 _label
        anchors.top:        parent.top
        anchors.right:      parent.right
        isCurrentItem:      missionItem.isCurrentItem
        label:              missionItem.sequenceNumber
    }

    QGCComboBox {
        id:                 _commandCombo
        anchors.margins:    parent.radius / 2
        anchors.left:       parent.left
        anchors.right:      _label.left
        anchors.top:        parent.top
        currentIndex:       missionItem.commandByIndex
        model:              missionItem.commandNames

        onActivated: missionItem.commandByIndex = index
    }

    Column {
        id:                 _coordinateColumn
        anchors.left:       parent.left
        anchors.right:      parent.right
        visible:            missionItem.specifiesCoordinate

    }

    QGCTextField {
        id:                 _latitudeField
        anchors.margins:    parent.radius / 2
        anchors.top:        _commandCombo.bottom
        anchors.right:      parent.right
        width:              _editFieldWidth
        text:               missionItem.coordinate.latitude
        visible:            missionItem.specifiesCoordinate

        onAccepted:         missionItem.coordinate.latitude = text
    }

    QGCTextField {
        id:                 _longitudeField
        anchors.margins:    parent.radius / 2
        anchors.top:        _latitudeField.bottom
        anchors.right:      parent.right
        width:              _editFieldWidth
        text:               missionItem.coordinate.longitude
        visible:            missionItem.specifiesCoordinate

        onAccepted:         missionItem.coordinate.longtitude = text
    }

    QGCTextField {
        id:                 _altitudeField
        anchors.margins:    parent.radius / 2
        anchors.top:        _longitudeField.bottom
        anchors.right:      parent.right
        width:              _editFieldWidth
        text:               missionItem.coordinate.altitude
        visible:            missionItem.specifiesCoordinate
        showUnits:          true
        unitsLabel:         "meters"

        onAccepted:         missionItem.coordinate.altitude = text
    }

    QGCLabel {
        anchors.margins:    parent.radius / 2
        anchors.left:       parent.left
        anchors.baseline:   _latitudeField.baseline
        color:              "black"
        text:               "Lat:"
        visible:            missionItem.specifiesCoordinate
    }

    QGCLabel {
        anchors.margins:    parent.radius / 2
        anchors.left:       parent.left
        anchors.baseline:   _longitudeField.baseline
        color:              "black"
        text:               "Long:"
        visible:            missionItem.specifiesCoordinate
    }

    QGCLabel {
        anchors.margins:    parent.radius / 2
        anchors.left:       parent.left
        anchors.baseline:   _altitudeField.baseline
        color:              "black"
        text:               "Alt:"
        visible:            missionItem.specifiesCoordinate
    }

    Column {
        id:                 _valueColumn
        anchors.margins:    parent.radius / 2
        anchors.left:       parent.left
        anchors.right:      parent.right
        anchors.top:        missionItem.specifiesCoordinate ? _altitudeField.bottom : _commandCombo.bottom
Don Gagne's avatar
Don Gagne committed
122
        spacing:            parent.radius / 2
Don Gagne's avatar
Don Gagne committed
123 124

        Repeater {
Don Gagne's avatar
Don Gagne committed
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
            model: missionItem.facts

            Item {
                width:  _valueColumn.width
                height: textField.height

                QGCLabel {
                    anchors.baseline:   textField.baseline
                    color:              "black"
                    text:               object.name
                }

                FactTextField {
                    id:             textField
                    anchors.right:  parent.right
                    width:          _editFieldWidth
                    showUnits:      true
                    fact:           object
                }
Don Gagne's avatar
Don Gagne committed
144 145
            }
        }
Don Gagne's avatar
Don Gagne committed
146 147
    } // Column - Values column
} // Rectangle