MissionCommandDialog.qml 3.55 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
    property var missionItem
23
    property var map
Don Gagne's avatar
Don Gagne committed
24

25 26
    property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle

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

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

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

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

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

        onActivated: categorySelected(textAt(index))
    }

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

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

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

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

                QGCLabel {
82 83
                    text:           mavCmdInfo.friendlyName
                    color:          textColor
84
                    font.family:    ScreenTools.demiboldFontFamily
Don Gagne's avatar
Don Gagne committed
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: {
100
                        missionItem.setMapCenterHintForCommandChange(map.center)
Don Gagne's avatar
Don Gagne committed
101
                    missionItem.command = mavCmdInfo.command
102
                    root.reject()
Don Gagne's avatar
Don Gagne committed
103 104 105
                }
            }
        }
Don Gagne's avatar
Don Gagne committed
106
    } // QGCListView
Don Gagne's avatar
Don Gagne committed
107
} // QGCViewDialog