MissionCommandDialog.qml 3.62 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8
 *
 * 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

22 23 24
    property var    missionItem
    property var    map
    property bool   flyThroughCommandsAllowed
Don Gagne's avatar
Don Gagne committed
25

26 27
    property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle

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

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

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

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

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

        onActivated: categorySelected(textAt(index))
    }

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

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

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

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

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

                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: {
101
                    missionItem.setMapCenterHintForCommandChange(map.center)
Don Gagne's avatar
Don Gagne committed
102
                    missionItem.command = mavCmdInfo.command
103
                    root.reject()
Don Gagne's avatar
Don Gagne committed
104 105 106
                }
            }
        }
Don Gagne's avatar
Don Gagne committed
107
    } // QGCListView
Don Gagne's avatar
Don Gagne committed
108
} // QGCViewDialog