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

import QGroundControl.ScreenTools   1.0
import QGroundControl.Vehicle       1.0
Don Gagne's avatar
Don Gagne committed
8 9
import QGroundControl.Controls      1.0
import QGroundControl.FactControls  1.0
Don Gagne's avatar
Don Gagne committed
10 11
import QGroundControl.Palette       1.0

Don Gagne's avatar
Don Gagne committed
12 13 14

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

17 18
    property var    missionItem ///< MissionItem associated with this editor
    property bool   readOnly    ///< true: read only view, false: full editing view
Don Gagne's avatar
Don Gagne committed
19
    property var    qgcView     ///< QGCView control used for showing dialogs
Don Gagne's avatar
Don Gagne committed
20

21 22
    signal clicked
    signal remove
Don Gagne's avatar
Don Gagne committed
23

24
    height: innerItem.height + (_margin * 3)
25
    color:  missionItem.isCurrentItem ? qgcPal.buttonHighlight : qgcPal.windowShade
26
    radius: _radius
Don Gagne's avatar
Don Gagne committed
27

28
    readonly property real _editFieldWidth:     ScreenTools.defaultFontPixelWidth * 16
29 30
    readonly property real _margin:             ScreenTools.defaultFontPixelWidth / 2
    readonly property real _radius:             ScreenTools.defaultFontPixelWidth / 2
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
    Item {
38
        id:                 innerItem
Don Gagne's avatar
Don Gagne committed
39
        anchors.margins:    _margin
40 41 42 43
        anchors.top:        parent.top
        anchors.left:       parent.left
        anchors.right:      parent.right
        height:             valuesRect.visible ? valuesRect.y + valuesRect.height : valuesRect.y
Don Gagne's avatar
Don Gagne committed
44

45 46 47 48 49 50 51
        MouseArea {
            anchors.fill:   parent
            visible:        !missionItem.isCurrentItem

            onClicked: _root.clicked()
        }

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
        Image {
            id:                     rawEdit
Don Gagne's avatar
Don Gagne committed
61 62
            anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
            anchors.right:          parent.right
63 64 65 66 67 68 69 70 71 72
            anchors.verticalCenter: commandPicker.verticalCenter
            width:                  commandPicker.height
            height:                 commandPicker.height
            visible:                missionItem.friendlyEditAllowed && missionItem.sequenceNumber != 0 && missionItem.isCurrentItem
            source:                 "qrc:/qmlimages/CogWheel.svg"

            MouseArea {
                anchors.fill:   parent
                onClicked:      missionItem.rawEdit = !missionItem.rawEdit
            }
Don Gagne's avatar
Don Gagne committed
73
        }
Don Gagne's avatar
Don Gagne committed
74

Don Gagne's avatar
Don Gagne committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
        QGCButton {
            id:                     commandPicker
            anchors.leftMargin:     ScreenTools.defaultFontPixelWidth * 2
            anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
            anchors.left:           label.right
            anchors.right:          rawEdit.left
            visible:                missionItem.sequenceNumber != 0 && missionItem.isCurrentItem && !missionItem.rawEdit
            text:                   missionItem.commandName

            Component {
                id: commandDialog

                MissionCommandDialog {
                    missionItem: _root.missionItem
                }
            }
Don Gagne's avatar
Don Gagne committed
91

Don Gagne's avatar
Don Gagne committed
92
            onClicked:              qgcView.showDialog(commandDialog, "Select Mission Command", 40, StandardButton.Cancel)
Don Gagne's avatar
Don Gagne committed
93
        }
Don Gagne's avatar
Don Gagne committed
94

Don Gagne's avatar
Don Gagne committed
95 96 97
        Rectangle {
            anchors.fill:   commandPicker
            color:          qgcPal.button
98
            visible:        missionItem.sequenceNumber == 0 || !missionItem.isCurrentItem
Don Gagne's avatar
Don Gagne committed
99 100 101 102 103

            QGCLabel {
                anchors.leftMargin: ScreenTools.defaultFontPixelWidth
                anchors.fill:       parent
                verticalAlignment:  Text.AlignVCenter
104
                text:               missionItem.sequenceNumber == 0 ? "Home" : missionItem.commandName
Don Gagne's avatar
Don Gagne committed
105 106 107 108
                color:              qgcPal.buttonText
            }
        }

Don Gagne's avatar
Don Gagne committed
109
        Rectangle {
110
            id:                 valuesRect
111
            anchors.topMargin:  _margin
Don Gagne's avatar
Don Gagne committed
112 113 114
            anchors.top:        commandPicker.bottom
            anchors.left:       parent.left
            anchors.right:      parent.right
115
            height:             valuesItem.height
Don Gagne's avatar
Don Gagne committed
116
            color:              qgcPal.windowShadeDark
117
            visible:            missionItem.sequenceNumber != 0 && missionItem.isCurrentItem
118
            radius:             _radius
Don Gagne's avatar
Don Gagne committed
119

Don Gagne's avatar
Don Gagne committed
120
            Item {
121
                id:                 valuesItem
Don Gagne's avatar
Don Gagne committed
122
                anchors.margins:    _margin
123 124 125 126
                anchors.left:       parent.left
                anchors.right:      parent.right
                anchors.top:        parent.top
                height:             valuesColumn.height + _margin
Don Gagne's avatar
Don Gagne committed
127

Don Gagne's avatar
Don Gagne committed
128
                Column {
129 130 131 132 133
                    id:             valuesColumn
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    anchors.top:    parent.top
                    spacing:        _margin
Don Gagne's avatar
Don Gagne committed
134

135 136 137
                    QGCLabel {
                        width:      parent.width
                        wrapMode:   Text.WordWrap
138 139 140 141 142 143 144 145
                        text:       missionItem.rawEdit ?
                                        "Provides advanced access to all commands/parameters. Be very careful!" :
                                        missionItem.commandDescription
                    }

                    Repeater {
                        model: missionItem.comboboxFacts

146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
                        Item {
                            width:  valuesColumn.width
                            height: comboBoxFact.height

                            QGCLabel {
                                id:                 comboBoxLabel
                                anchors.baseline:   comboBoxFact.baseline
                                text:               object.name
                                visible:            object.name != ""
                            }

                            FactComboBox {
                                id:             comboBoxFact
                                anchors.right:  parent.right
                                width:          comboBoxLabel.visible ? _editFieldWidth : parent.width
                                indexModel:     false
                                model:          object.enumStrings
                                fact:           object
                            }
165
                        }
166 167
                    }

Don Gagne's avatar
Don Gagne committed
168
                    Repeater {
169
                        model: missionItem.textFieldFacts
Don Gagne's avatar
Don Gagne committed
170 171

                        Item {
172
                            width:  valuesColumn.width
Don Gagne's avatar
Don Gagne committed
173 174 175
                            height: textField.height

                            QGCLabel {
176
                                id:                 textFieldLabel
Don Gagne's avatar
Don Gagne committed
177 178 179 180 181 182 183 184 185 186
                                anchors.baseline:   textField.baseline
                                text:               object.name
                            }

                            FactTextField {
                                id:             textField
                                anchors.right:  parent.right
                                width:          _editFieldWidth
                                showUnits:      true
                                fact:           object
187 188 189 190 191 192 193 194
                                visible:        !_root.readOnly
                            }

                            FactLabel {
                                anchors.baseline:   textFieldLabel.baseline
                                anchors.right:      parent.right
                                fact:               object
                                visible:            _root.readOnly
Don Gagne's avatar
Don Gagne committed
195 196 197
                            }
                        }
                    }
198

199 200
                    Repeater {
                        model: missionItem.checkboxFacts
201

202 203 204 205 206 207
                        FactCheckBox {
                            text:   object.name
                            fact:   object
                        }
                    }
                } // Column
Don Gagne's avatar
Don Gagne committed
208 209 210
            } // Item
        } // Rectangle
    } // Item
Don Gagne's avatar
Don Gagne committed
211
} // Rectangle