MissionItemEditor.qml 6.02 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
    height: missionItem.isCurrentItem ?
24 25 26
                (missionItem.textFieldFacts.count * (measureTextField.height + _margin)) +
                    (missionItem.checkboxFacts.count * (measureCheckbox.height + _margin)) +
                    commandPicker.height + deleteButton.height + (_margin * 9) :
27 28
                commandPicker.height + (_margin * 2)
    color:  missionItem.isCurrentItem ? qgcPal.buttonHighlight : qgcPal.windowShade
Don Gagne's avatar
Don Gagne committed
29

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

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

38 39 40 41 42 43 44 45 46 47
    QGCTextField {
        id:         measureTextField
        visible:    false
    }

    QGCCheckBox {
        id:         measureCheckbox
        visible:    false
    }

Don Gagne's avatar
Don Gagne committed
48 49 50
    Item {
        anchors.margins:    _margin
        anchors.fill:       parent
Don Gagne's avatar
Don Gagne committed
51

Don Gagne's avatar
Don Gagne committed
52
        MissionItemIndexLabel {
53 54 55
            id:                     label
            anchors.verticalCenter: commandPicker.verticalCenter
            isCurrentItem:          missionItem.isCurrentItem
Don Gagne's avatar
Don Gagne committed
56
            label:                  missionItem.sequenceNumber == 0 ? "H" : missionItem.sequenceNumber
57 58 59 60 61 62 63
        }

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

            onClicked: _root.clicked()
Don Gagne's avatar
Don Gagne committed
64
        }
Don Gagne's avatar
Don Gagne committed
65

66

Don Gagne's avatar
Don Gagne committed
67 68
        QGCComboBox {
            id:                 commandPicker
69
            anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 10
Don Gagne's avatar
Don Gagne committed
70 71 72 73
            anchors.left:       label.right
            anchors.right:      parent.right
            currentIndex:       missionItem.commandByIndex
            model:              missionItem.commandNames
Don Gagne's avatar
Don Gagne committed
74
            visible:            missionItem.sequenceNumber != 0
Don Gagne's avatar
Don Gagne committed
75

Don Gagne's avatar
Don Gagne committed
76 77
            onActivated: missionItem.commandByIndex = index
        }
Don Gagne's avatar
Don Gagne committed
78

Don Gagne's avatar
Don Gagne committed
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
        Rectangle {
            anchors.fill:   commandPicker
            color:          qgcPal.button
            visible:        missionItem.sequenceNumber == 0

            QGCLabel {
                id:                 homeLabel
                anchors.leftMargin: ScreenTools.defaultFontPixelWidth
                anchors.fill:       parent
                verticalAlignment:  Text.AlignVCenter
                text:               "Home"
                color:              qgcPal.buttonText
            }
        }

Don Gagne's avatar
Don Gagne committed
94
        Rectangle {
95
            anchors.topMargin:  _margin
Don Gagne's avatar
Don Gagne committed
96 97 98 99 100
            anchors.top:        commandPicker.bottom
            anchors.bottom:     parent.bottom
            anchors.left:       parent.left
            anchors.right:      parent.right
            color:              qgcPal.windowShadeDark
101
            visible:            missionItem.isCurrentItem
Don Gagne's avatar
Don Gagne committed
102

Don Gagne's avatar
Don Gagne committed
103 104 105
            Item {
                anchors.margins:    _margin
                anchors.fill:   parent
Don Gagne's avatar
Don Gagne committed
106

Don Gagne's avatar
Don Gagne committed
107
                Column {
108 109 110 111 112
                    id:             valuesColumn
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    anchors.top:    parent.top
                    spacing:        _margin
Don Gagne's avatar
Don Gagne committed
113 114

                    Repeater {
115
                        model: missionItem.textFieldFacts
Don Gagne's avatar
Don Gagne committed
116 117

                        Item {
118
                            width:  valuesColumn.width
Don Gagne's avatar
Don Gagne committed
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
                            height: textField.height

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

                            FactTextField {
                                id:             textField
                                anchors.right:  parent.right
                                width:          _editFieldWidth
                                showUnits:      true
                                fact:           object
                            }
                        }
                    }
135

136 137 138 139
                    Item {
                        width:  10
                        height: missionItem.textFieldFacts.count ? _margin : 0
                    }
140

141 142
                    Repeater {
                        model: missionItem.checkboxFacts
143

144 145 146 147 148 149
                        FactCheckBox {
                            id:     textField
                            text:   object.name
                            fact:   object
                        }
                    }
150

151 152 153
                    Item {
                        width:  10
                        height: missionItem.checkboxFacts.count ? _margin : 0
154 155
                    }

156 157 158
                    Row {
                        width:      parent.width
                        spacing:    _margin
159

160 161 162 163 164 165 166 167 168
                        readonly property real buttonWidth: (width - (_margin * 2)) / 3

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

                            onClicked: _root.remove()
                        }
169

170 171 172
                        QGCButton {
                            width:  parent.buttonWidth
                            text:   "Up"
173

174 175 176 177 178 179 180 181 182
                            onClicked: _root.moveUp()
                        }

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

                            onClicked: _root.moveDown()
                        }
183
                    }
184 185

                } // Column
Don Gagne's avatar
Don Gagne committed
186 187 188
            } // Item
        } // Rectangle
    } // Item
Don Gagne's avatar
Don Gagne committed
189
} // Rectangle