Skip to content
MissionCommandDialog.qml 3.45 KiB
Newer Older
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
import QtQuick                  2.3
import QtQuick.Controls         1.2
Don Gagne's avatar
Don Gagne committed

import QGroundControl               1.0
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Palette       1.0

QGCViewDialog {
Don Gagne's avatar
Don Gagne committed
    property var missionItem

    property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle

Don Gagne's avatar
Don Gagne committed
    QGCPalette { id: qgcPal }

    QGCLabel {
        id:                 categoryLabel
        anchors.baseline:   categoryCombo.baseline
        text:               qsTr("Category:")
Don Gagne's avatar
Don Gagne committed
    }

    QGCComboBox {
        id:                 categoryCombo
        anchors.margins:    ScreenTools.defaultFontPixelWidth
        anchors.left:       categoryLabel.right
        anchors.right:      parent.right
        model:              QGroundControl.missionCommandTree.categoriesForVehicle(_vehicle)
Don Gagne's avatar
Don Gagne committed

        function categorySelected(category) {
            commandList.model = QGroundControl.missionCommandTree.getCommandsForCategory(_vehicle, category)
Don Gagne's avatar
Don Gagne committed
        }

        Component.onCompleted: {
            var category  = missionItem.category
            currentIndex = find(category)
            categorySelected(category)
        }

        onActivated: categorySelected(textAt(index))
    }

Don Gagne's avatar
Don Gagne committed
    QGCListView {
Don Gagne's avatar
Don Gagne committed
        id:                 commandList
        anchors.margins:    ScreenTools.defaultFontPixelHeight
        anchors.left:       parent.left
        anchors.right:      parent.right
        anchors.top:        categoryCombo.bottom
        anchors.bottom:     parent.bottom
        spacing:            ScreenTools.defaultFontPixelHeight / 2
        orientation:        ListView.Vertical
Don Gagne's avatar
Don Gagne committed
        clip:               true
Don Gagne's avatar
Don Gagne committed

        delegate: Rectangle {
            width:  parent.width
dogmaphobic's avatar
dogmaphobic committed
            height: commandColumn.height + ScreenTools.defaultFontPixelHeight
Don Gagne's avatar
Don Gagne committed
            color:  qgcPal.button
            property var    mavCmdInfo: modelData
Don Gagne's avatar
Don Gagne committed
            property var    textColor:  qgcPal.buttonText
Don Gagne's avatar
Don Gagne committed

            Column {
                id:                 commandColumn
                anchors.margins:    ScreenTools.defaultFontPixelWidth
                anchors.left:       parent.left
                anchors.right:      parent.right
                anchors.top:        parent.top

                QGCLabel {
Don Gagne's avatar
Don Gagne committed
                    text:           mavCmdInfo.friendlyName
                    color:          textColor
                    font.family:    ScreenTools.demiboldFontFamily
Don Gagne's avatar
Don Gagne committed
                }

                QGCLabel {
                    anchors.margins:    ScreenTools.defaultFontPixelWidth
                    anchors.left:       parent.left
                    anchors.right:      parent.right
                    text:               mavCmdInfo.description
                    wrapMode:           Text.WordWrap
                    color:              textColor
                }
            }

            MouseArea {
                anchors.fill:   parent
                onClicked: {
                    missionItem.command = mavCmdInfo.command
                    root.reject()
Don Gagne's avatar
Don Gagne committed
    } // QGCListView
Don Gagne's avatar
Don Gagne committed
} // QGCViewDialog