MissionCommandDialog.qml 3.45 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/
Don Gagne's avatar
Don Gagne committed
9 10


11 12
import QtQuick                  2.3
import QtQuick.Controls         1.2
Don Gagne's avatar
Don Gagne committed
13 14 15 16 17 18 19

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

QGCViewDialog {
20 21
    id: root

Don Gagne's avatar
Don Gagne committed
22 23
    property var missionItem

24 25
    property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle

Don Gagne's avatar
Don Gagne committed
26 27 28 29 30
    QGCPalette { id: qgcPal }

    QGCLabel {
        id:                 categoryLabel
        anchors.baseline:   categoryCombo.baseline
31
        text:               qsTr("Category:")
Don Gagne's avatar
Don Gagne committed
32 33 34 35 36 37 38
    }

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

        function categorySelected(category) {
42
            commandList.model = QGroundControl.missionCommandTree.getCommandsForCategory(_vehicle, category)
Don Gagne's avatar
Don Gagne committed
43 44 45 46 47 48 49 50 51 52 53
        }

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

        onActivated: categorySelected(textAt(index))
    }

Don Gagne's avatar
Don Gagne committed
54
    QGCListView {
Don Gagne's avatar
Don Gagne committed
55 56 57 58 59 60 61 62
        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
63
        clip:               true
Don Gagne's avatar
Don Gagne committed
64 65 66

        delegate: Rectangle {
            width:  parent.width
67
            height: commandColumn.height + ScreenTools.defaultFontPixelHeight
Don Gagne's avatar
Don Gagne committed
68
            color:  qgcPal.button
Don Gagne's avatar
Don Gagne committed
69

70
            property var    mavCmdInfo: modelData
Don Gagne's avatar
Don Gagne committed
71
            property var    textColor:  qgcPal.buttonText
Don Gagne's avatar
Don Gagne committed
72 73 74 75 76 77 78 79 80

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

                QGCLabel {
81 82
                    text:           mavCmdInfo.friendlyName
                    color:          textColor
83
                    font.family:    ScreenTools.demiboldFontFamily
Don Gagne's avatar
Don Gagne committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
                }

                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
100
                    root.reject()
Don Gagne's avatar
Don Gagne committed
101 102 103
                }
            }
        }
Don Gagne's avatar
Don Gagne committed
104
    } // QGCListView
Don Gagne's avatar
Don Gagne committed
105
} // QGCViewDialog