MissionItemEditor.qml 5.4 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 56 57 58 59 60 61 62 63
            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
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

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

Don Gagne's avatar
Don Gagne committed
78
        Rectangle {
79
            anchors.topMargin:  _margin
Don Gagne's avatar
Don Gagne committed
80 81 82 83 84
            anchors.top:        commandPicker.bottom
            anchors.bottom:     parent.bottom
            anchors.left:       parent.left
            anchors.right:      parent.right
            color:              qgcPal.windowShadeDark
85
            visible:            missionItem.isCurrentItem
Don Gagne's avatar
Don Gagne committed
86

Don Gagne's avatar
Don Gagne committed
87 88 89
            Item {
                anchors.margins:    _margin
                anchors.fill:   parent
Don Gagne's avatar
Don Gagne committed
90

Don Gagne's avatar
Don Gagne committed
91
                Column {
92 93 94 95 96
                    id:             valuesColumn
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    anchors.top:    parent.top
                    spacing:        _margin
Don Gagne's avatar
Don Gagne committed
97 98

                    Repeater {
99
                        model: missionItem.textFieldFacts
Don Gagne's avatar
Don Gagne committed
100 101

                        Item {
102
                            width:  valuesColumn.width
Don Gagne's avatar
Don Gagne committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
                            height: textField.height

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

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

120 121 122 123
                    Item {
                        width:  10
                        height: missionItem.textFieldFacts.count ? _margin : 0
                    }
124

125 126
                    Repeater {
                        model: missionItem.checkboxFacts
127

128 129 130 131 132 133
                        FactCheckBox {
                            id:     textField
                            text:   object.name
                            fact:   object
                        }
                    }
134

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

140 141 142
                    Row {
                        width:      parent.width
                        spacing:    _margin
143

144 145 146 147 148 149 150 151 152
                        readonly property real buttonWidth: (width - (_margin * 2)) / 3

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

                            onClicked: _root.remove()
                        }
153

154 155 156
                        QGCButton {
                            width:  parent.buttonWidth
                            text:   "Up"
157

158 159 160 161 162 163 164 165 166
                            onClicked: _root.moveUp()
                        }

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

                            onClicked: _root.moveDown()
                        }
167
                    }
168 169

                } // Column
Don Gagne's avatar
Don Gagne committed
170 171 172
            } // Item
        } // Rectangle
    } // Item
Don Gagne's avatar
Don Gagne committed
173
} // Rectangle