Skip to content
MissionItemEditor.qml 5.4 KiB
Newer Older
Don Gagne's avatar
Don Gagne committed
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
import QGroundControl.Controls      1.0
import QGroundControl.FactControls  1.0
Don Gagne's avatar
Don Gagne committed
import QGroundControl.Palette       1.0

Don Gagne's avatar
Don Gagne committed

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

Don Gagne's avatar
Don Gagne committed
    property var    missionItem

    signal clicked
    signal remove
    signal moveUp
    signal moveDown
    height: missionItem.isCurrentItem ?
Don Gagne's avatar
Don Gagne committed
                (missionItem.textFieldFacts.count * (measureTextField.height + _margin)) +
                    (missionItem.checkboxFacts.count * (measureCheckbox.height + _margin)) +
                    commandPicker.height + deleteButton.height + (_margin * 9) :
                commandPicker.height + (_margin * 2)
    color:  missionItem.isCurrentItem ? qgcPal.buttonHighlight : qgcPal.windowShade
Don Gagne's avatar
Don Gagne committed
    readonly property real _editFieldWidth:     ScreenTools.defaultFontPixelWidth * 16
Don Gagne's avatar
Don Gagne committed
    readonly property real _margin:             ScreenTools.defaultFontPixelWidth / 3
Don Gagne's avatar
Don Gagne committed
    QGCPalette {
        id: qgcPal
        colorGroupEnabled: enabled
Don Gagne's avatar
Don Gagne committed
    QGCTextField {
        id:         measureTextField
        visible:    false
    }

    QGCCheckBox {
        id:         measureCheckbox
        visible:    false
    }

Don Gagne's avatar
Don Gagne committed
    Item {
        anchors.margins:    _margin
        anchors.fill:       parent
Don Gagne's avatar
Don Gagne committed
        MissionItemIndexLabel {
            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
        }
Don Gagne's avatar
Don Gagne committed
        QGCComboBox {
            id:                 commandPicker
            anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 10
Don Gagne's avatar
Don Gagne committed
            anchors.left:       label.right
            anchors.right:      parent.right
            currentIndex:       missionItem.commandByIndex
            model:              missionItem.commandNames
Don Gagne's avatar
Don Gagne committed
            onActivated: missionItem.commandByIndex = index
        }
Don Gagne's avatar
Don Gagne committed
        Rectangle {
Don Gagne's avatar
Don Gagne committed
            anchors.topMargin:  _margin
Don Gagne's avatar
Don Gagne committed
            anchors.top:        commandPicker.bottom
            anchors.bottom:     parent.bottom
            anchors.left:       parent.left
            anchors.right:      parent.right
            color:              qgcPal.windowShadeDark
            visible:            missionItem.isCurrentItem
Don Gagne's avatar
Don Gagne committed
            Item {
                anchors.margins:    _margin
                anchors.fill:   parent
Don Gagne's avatar
Don Gagne committed
                Column {
Don Gagne's avatar
Don Gagne committed
                    id:             valuesColumn
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    anchors.top:    parent.top
                    spacing:        _margin
Don Gagne's avatar
Don Gagne committed

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

                        Item {
Don Gagne's avatar
Don Gagne committed
                            width:  valuesColumn.width
Don Gagne's avatar
Don Gagne committed
                            height: textField.height

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

                            FactTextField {
                                id:             textField
                                anchors.right:  parent.right
                                width:          _editFieldWidth
                                showUnits:      true
                                fact:           object
                            }
                        }
                    }
Don Gagne's avatar
Don Gagne committed
                    Item {
                        width:  10
                        height: missionItem.textFieldFacts.count ? _margin : 0
                    }
Don Gagne's avatar
Don Gagne committed
                    Repeater {
                        model: missionItem.checkboxFacts
Don Gagne's avatar
Don Gagne committed
                        FactCheckBox {
                            id:     textField
                            text:   object.name
                            fact:   object
                        }
                    }
Don Gagne's avatar
Don Gagne committed
                    Item {
                        width:  10
                        height: missionItem.checkboxFacts.count ? _margin : 0
Don Gagne's avatar
Don Gagne committed
                    Row {
                        width:      parent.width
                        spacing:    _margin
Don Gagne's avatar
Don Gagne committed
                        readonly property real buttonWidth: (width - (_margin * 2)) / 3

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

                            onClicked: _root.remove()
                        }
Don Gagne's avatar
Don Gagne committed
                        QGCButton {
                            width:  parent.buttonWidth
                            text:   "Up"
Don Gagne's avatar
Don Gagne committed
                            onClicked: _root.moveUp()
                        }

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

                            onClicked: _root.moveDown()
                        }
Don Gagne's avatar
Don Gagne committed

                } // Column
Don Gagne's avatar
Don Gagne committed
            } // Item
        } // Rectangle
    } // Item
Don Gagne's avatar
Don Gagne committed
} // Rectangle