MissionItemEditor.qml 7.1 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

/// Mission item edit control
Rectangle {
14 15
    id: _root

Don Gagne's avatar
Don Gagne committed
16 17
    property var    missionItem

18 19 20 21
    signal clicked
    signal remove
    signal moveUp
    signal moveDown
Don Gagne's avatar
Don Gagne committed
22

23 24 25 26 27
// FIXME: THis doesn't work right for RTL
    height: missionItem.isCurrentItem ?
                ((missionItem.factCount + (missionItem.specifiesCoordinate ? 3 : 0)) * (latitudeField.height + _margin)) + commandPicker.height + deleteButton.height + (_margin * 6) :
                commandPicker.height + (_margin * 2)
    color:  missionItem.isCurrentItem ? qgcPal.buttonHighlight : qgcPal.windowShade
Don Gagne's avatar
Don Gagne committed
28

Don Gagne's avatar
Don Gagne committed
29 30
    readonly property real _editFieldWidth:     ScreenTools.defaultFontPixelWidth * 13
    readonly property real _margin:             ScreenTools.defaultFontPixelWidth / 3
Don Gagne's avatar
Don Gagne committed
31

Don Gagne's avatar
Don Gagne committed
32 33 34
    QGCPalette {
        id: qgcPal
        colorGroupEnabled: enabled
Don Gagne's avatar
Don Gagne committed
35 36
    }

Don Gagne's avatar
Don Gagne committed
37 38 39
    Item {
        anchors.margins:    _margin
        anchors.fill:       parent
Don Gagne's avatar
Don Gagne committed
40

Don Gagne's avatar
Don Gagne committed
41
        MissionItemIndexLabel {
42 43 44 45 46 47 48 49 50 51 52
            id:                     label
            anchors.verticalCenter: commandPicker.verticalCenter
            isCurrentItem:          missionItem.isCurrentItem
            label:                  missionItem.sequenceNumber
        }

        MouseArea {
            anchors.fill:   parent
            visible:        !missionItem.isCurrentItem

            onClicked: _root.clicked()
Don Gagne's avatar
Don Gagne committed
53
        }
Don Gagne's avatar
Don Gagne committed
54

55

Don Gagne's avatar
Don Gagne committed
56 57
        QGCComboBox {
            id:                 commandPicker
58
            anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 10
Don Gagne's avatar
Don Gagne committed
59 60 61 62
            anchors.left:       label.right
            anchors.right:      parent.right
            currentIndex:       missionItem.commandByIndex
            model:              missionItem.commandNames
Don Gagne's avatar
Don Gagne committed
63

Don Gagne's avatar
Don Gagne committed
64 65
            onActivated: missionItem.commandByIndex = index
        }
Don Gagne's avatar
Don Gagne committed
66

Don Gagne's avatar
Don Gagne committed
67 68 69 70 71 72 73
        Rectangle {
            anchors.margins:    _margin
            anchors.top:        commandPicker.bottom
            anchors.bottom:     parent.bottom
            anchors.left:       parent.left
            anchors.right:      parent.right
            color:              qgcPal.windowShadeDark
74
            visible:            missionItem.isCurrentItem
Don Gagne's avatar
Don Gagne committed
75

Don Gagne's avatar
Don Gagne committed
76 77 78
            Item {
                anchors.margins:    _margin
                anchors.fill:   parent
Don Gagne's avatar
Don Gagne committed
79

Don Gagne's avatar
Don Gagne committed
80 81 82 83 84 85
                QGCTextField {
                    id:             latitudeField
                    anchors.right:  parent.right
                    width:          _editFieldWidth
                    text:           missionItem.coordinate.latitude
                    visible:        missionItem.specifiesCoordinate
Don Gagne's avatar
Don Gagne committed
86

Don Gagne's avatar
Don Gagne committed
87 88
                    onAccepted:     missionItem.coordinate.latitude = text
                }
Don Gagne's avatar
Don Gagne committed
89

Don Gagne's avatar
Don Gagne committed
90 91 92 93 94 95 96 97
                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
98

Don Gagne's avatar
Don Gagne committed
99 100
                    onAccepted:         missionItem.coordinate.longtitude = text
                }
Don Gagne's avatar
Don Gagne committed
101

Don Gagne's avatar
Don Gagne committed
102 103 104 105 106 107 108 109 110 111 112 113 114
                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
115 116

                QGCLabel {
Don Gagne's avatar
Don Gagne committed
117 118 119 120
                    anchors.left:       parent.left
                    anchors.baseline:   latitudeField.baseline
                    text:               "Lat:"
                    visible:            missionItem.specifiesCoordinate
Don Gagne's avatar
Don Gagne committed
121 122
                }

Don Gagne's avatar
Don Gagne committed
123 124 125 126 127
                QGCLabel {
                    anchors.left:       parent.left
                    anchors.baseline:   longitudeField.baseline
                    text:               "Long:"
                    visible:            missionItem.specifiesCoordinate
Don Gagne's avatar
Don Gagne committed
128
                }
Don Gagne's avatar
Don Gagne committed
129 130 131 132 133 134 135 136 137 138 139 140 141

                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
142
                    anchors.top:        missionItem.specifiesCoordinate ? altitudeField.bottom : parent.top
Don Gagne's avatar
Don Gagne committed
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
                    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
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198

                Row {
                    anchors.topMargin:  _margin
                    anchors.top:        valueColumn.bottom

                    width:      parent.width
                    spacing:    _margin

                    readonly property real buttonWidth: (width - (_margin * 2)) / 3

                    QGCButton {
                        id:     deleteButton
                        width:  parent.buttonWidth
                        text:   "Delete"

                        onClicked: _root.remove()
                    }

                    QGCButton {
                        width:  parent.buttonWidth
                        text:   "Up"

                        onClicked: _root.moveUp()
                    }

                    QGCButton {
                        width:  parent.buttonWidth
                        text:   "Down"

                        onClicked: _root.moveDown()
                    }
                }
Don Gagne's avatar
Don Gagne committed
199 200 201
            } // Item
        } // Rectangle
    } // Item
Don Gagne's avatar
Don Gagne committed
202
} // Rectangle