MissionItemEditor.qml 5.59 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
import QGroundControl.Palette       1.0

Don Gagne's avatar
Don Gagne committed
11 12 13 14 15

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

Don Gagne's avatar
Don Gagne committed
16 17
    height: ((missionItem.factCount + 3) * (latitudeField.height + _margin)) + commandPicker.height + (_margin * 5)
    color:  missionItem.isCurrentItem ? qgcPal.buttonHighlight : qgcPal.windowShade
Don Gagne's avatar
Don Gagne committed
18 19


Don Gagne's avatar
Don Gagne committed
20 21
    readonly property real _editFieldWidth:     ScreenTools.defaultFontPixelWidth * 13
    readonly property real _margin:             ScreenTools.defaultFontPixelWidth / 3
Don Gagne's avatar
Don Gagne committed
22

Don Gagne's avatar
Don Gagne committed
23 24 25
    QGCPalette {
        id: qgcPal
        colorGroupEnabled: enabled
Don Gagne's avatar
Don Gagne committed
26 27
    }

Don Gagne's avatar
Don Gagne committed
28 29 30
    Item {
        anchors.margins:    _margin
        anchors.fill:       parent
Don Gagne's avatar
Don Gagne committed
31

Don Gagne's avatar
Don Gagne committed
32 33 34 35 36
        MissionItemIndexLabel {
            id:             label
            isCurrentItem:  missionItem.isCurrentItem
            label:          missionItem.sequenceNumber
        }
Don Gagne's avatar
Don Gagne committed
37

Don Gagne's avatar
Don Gagne committed
38 39 40 41 42 43 44
        QGCComboBox {
            id:                 commandPicker
            anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 4
            anchors.left:       label.right
            anchors.right:      parent.right
            currentIndex:       missionItem.commandByIndex
            model:              missionItem.commandNames
Don Gagne's avatar
Don Gagne committed
45

Don Gagne's avatar
Don Gagne committed
46 47
            onActivated: missionItem.commandByIndex = index
        }
Don Gagne's avatar
Don Gagne committed
48

Don Gagne's avatar
Don Gagne committed
49 50 51 52 53 54 55
        Rectangle {
            anchors.margins:    _margin
            anchors.top:        commandPicker.bottom
            anchors.bottom:     parent.bottom
            anchors.left:       parent.left
            anchors.right:      parent.right
            color:              qgcPal.windowShadeDark
Don Gagne's avatar
Don Gagne committed
56

Don Gagne's avatar
Don Gagne committed
57 58 59
            Item {
                anchors.margins:    _margin
                anchors.fill:   parent
Don Gagne's avatar
Don Gagne committed
60

Don Gagne's avatar
Don Gagne committed
61 62 63 64 65 66
                QGCTextField {
                    id:             latitudeField
                    anchors.right:  parent.right
                    width:          _editFieldWidth
                    text:           missionItem.coordinate.latitude
                    visible:        missionItem.specifiesCoordinate
Don Gagne's avatar
Don Gagne committed
67

Don Gagne's avatar
Don Gagne committed
68 69
                    onAccepted:     missionItem.coordinate.latitude = text
                }
Don Gagne's avatar
Don Gagne committed
70

Don Gagne's avatar
Don Gagne committed
71 72 73 74 75 76 77 78
                QGCTextField {
                    id:                 longitudeField
                    anchors.topMargin:  _margin
                    anchors.top:        latitudeField.bottom
                    anchors.right:      parent.right
                    width:              _editFieldWidth
                    text:               missionItem.coordinate.longitude
                    visible:            missionItem.specifiesCoordinate
Don Gagne's avatar
Don Gagne committed
79

Don Gagne's avatar
Don Gagne committed
80 81
                    onAccepted:         missionItem.coordinate.longtitude = text
                }
Don Gagne's avatar
Don Gagne committed
82

Don Gagne's avatar
Don Gagne committed
83 84 85 86 87 88 89 90 91 92 93 94 95
                QGCTextField {
                    id:                 altitudeField
                    anchors.topMargin:  _margin
                    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
                }
Don Gagne's avatar
Don Gagne committed
96 97

                QGCLabel {
Don Gagne's avatar
Don Gagne committed
98 99 100 101
                    anchors.left:       parent.left
                    anchors.baseline:   latitudeField.baseline
                    text:               "Lat:"
                    visible:            missionItem.specifiesCoordinate
Don Gagne's avatar
Don Gagne committed
102 103
                }

Don Gagne's avatar
Don Gagne committed
104 105 106 107 108
                QGCLabel {
                    anchors.left:       parent.left
                    anchors.baseline:   longitudeField.baseline
                    text:               "Long:"
                    visible:            missionItem.specifiesCoordinate
Don Gagne's avatar
Don Gagne committed
109
                }
Don Gagne's avatar
Don Gagne committed
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150

                QGCLabel {
                    anchors.left:       parent.left
                    anchors.baseline:   altitudeField.baseline
                    text:               "Alt:"
                    visible:            missionItem.specifiesCoordinate
                }

                Column {
                    id:                 valueColumn
                    anchors.topMargin:  _margin
                    anchors.left:       parent.left
                    anchors.right:      parent.right
                    anchors.top:        missionItem.specifiesCoordinate ? altitudeField.bottom : commandPicker.bottom
                    spacing:            _margin

                    Repeater {
                        model: missionItem.facts

                        Item {
                            width:  valueColumn.width
                            height: textField.height

                            QGCLabel {
                                anchors.baseline:   textField.baseline
                                text:               object.name
                            }

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