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

16 17
    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
18

19 20
    signal clicked
    signal remove
Don Gagne's avatar
Don Gagne committed
21

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

26
    readonly property real _editFieldWidth:     ScreenTools.defaultFontPixelWidth * 16
27 28
    readonly property real _margin:             ScreenTools.defaultFontPixelWidth / 2
    readonly property real _radius:             ScreenTools.defaultFontPixelWidth / 2
Don Gagne's avatar
Don Gagne committed
29

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

Don Gagne's avatar
Don Gagne committed
35
    Item {
36
        id:                 innerItem
Don Gagne's avatar
Don Gagne committed
37
        anchors.margins:    _margin
38 39 40 41
        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
42

Don Gagne's avatar
Don Gagne committed
43
        MissionItemIndexLabel {
44 45 46
            id:                     label
            anchors.verticalCenter: commandPicker.verticalCenter
            isCurrentItem:          missionItem.isCurrentItem
Don Gagne's avatar
Don Gagne committed
47
            label:                  missionItem.sequenceNumber == 0 ? "H" : missionItem.sequenceNumber
48 49 50 51 52 53 54
        }

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

            onClicked: _root.clicked()
Don Gagne's avatar
Don Gagne committed
55
        }
Don Gagne's avatar
Don Gagne committed
56

Don Gagne's avatar
Don Gagne committed
57 58
        QGCComboBox {
            id:                 commandPicker
59
            anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 10
Don Gagne's avatar
Don Gagne committed
60 61 62 63
            anchors.left:       label.right
            anchors.right:      parent.right
            currentIndex:       missionItem.commandByIndex
            model:              missionItem.commandNames
64
            visible:            missionItem.sequenceNumber != 0 && missionItem.isCurrentItem
Don Gagne's avatar
Don Gagne committed
65

Don Gagne's avatar
Don Gagne committed
66 67
            onActivated: missionItem.commandByIndex = index
        }
Don Gagne's avatar
Don Gagne committed
68

Don Gagne's avatar
Don Gagne committed
69 70 71
        Rectangle {
            anchors.fill:   commandPicker
            color:          qgcPal.button
72
            visible:        !commandPicker.visible
Don Gagne's avatar
Don Gagne committed
73 74 75 76 77 78

            QGCLabel {
                id:                 homeLabel
                anchors.leftMargin: ScreenTools.defaultFontPixelWidth
                anchors.fill:       parent
                verticalAlignment:  Text.AlignVCenter
79
                text:               missionItem.sequenceNumber == 0 ? "Home" : missionItem.commandName
Don Gagne's avatar
Don Gagne committed
80 81 82 83
                color:              qgcPal.buttonText
            }
        }

Don Gagne's avatar
Don Gagne committed
84
        Rectangle {
85
            id:                 valuesRect
86
            anchors.topMargin:  _margin
Don Gagne's avatar
Don Gagne committed
87 88 89
            anchors.top:        commandPicker.bottom
            anchors.left:       parent.left
            anchors.right:      parent.right
90
            height:             valuesItem.height
Don Gagne's avatar
Don Gagne committed
91
            color:              qgcPal.windowShadeDark
92
            visible:            missionItem.isCurrentItem
93
            radius:             _radius
Don Gagne's avatar
Don Gagne committed
94

Don Gagne's avatar
Don Gagne committed
95
            Item {
96
                id:                 valuesItem
Don Gagne's avatar
Don Gagne committed
97
                anchors.margins:    _margin
98 99 100 101
                anchors.left:       parent.left
                anchors.right:      parent.right
                anchors.top:        parent.top
                height:             valuesColumn.height + _margin
Don Gagne's avatar
Don Gagne committed
102

Don Gagne's avatar
Don Gagne committed
103
                Column {
104 105 106 107 108
                    id:             valuesColumn
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    anchors.top:    parent.top
                    spacing:        _margin
Don Gagne's avatar
Don Gagne committed
109

110 111 112 113 114 115
                    QGCLabel {
                        width:      parent.width
                        wrapMode:   Text.WordWrap
                        text:       missionItem.commandDescription
                    }

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

                        Item {
120
                            width:  valuesColumn.width
Don Gagne's avatar
Don Gagne committed
121 122 123
                            height: textField.height

                            QGCLabel {
124
                                id:                 textFieldLabel
Don Gagne's avatar
Don Gagne committed
125 126 127 128 129 130 131 132 133 134
                                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 140 141 142
                                visible:        !_root.readOnly
                            }

                            FactLabel {
                                anchors.baseline:   textFieldLabel.baseline
                                anchors.right:      parent.right
                                fact:               object
                                visible:            _root.readOnly
Don Gagne's avatar
Don Gagne committed
143 144 145
                            }
                        }
                    }
146

147 148
                    Repeater {
                        model: missionItem.checkboxFacts
149

150 151 152 153 154 155 156
                        FactCheckBox {
                            id:     textField
                            text:   object.name
                            fact:   object
                        }
                    }
                } // Column
Don Gagne's avatar
Don Gagne committed
157 158 159
            } // Item
        } // Rectangle
    } // Item
Don Gagne's avatar
Don Gagne committed
160
} // Rectangle