MissionItemStatus.qml 5.43 KB
Newer Older
1 2
/****************************************************************************
 *
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.
 *
 ****************************************************************************/
9

10 11 12
import QtQuick          2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts  1.2
13

14
import QGroundControl               1.0
15 16 17
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controls      1.0
import QGroundControl.Palette       1.0
18 19
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
20 21

Rectangle {
22
    id:         root
23
    radius:     ScreenTools.defaultFontPixelWidth * 0.5
24 25 26 27
    color:      qgcPal.window
    opacity:    0.80
    clip:       true

28 29 30 31
    property var    missionItems                    ///< List of all available mission items
    property real   maxWidth:          parent.width

    signal setCurrentSeqNum(int seqNum)
32

33
    readonly property real _margins: ScreenTools.defaultFontPixelWidth
34

35
    onMaxWidthChanged: {
36
        var calcLength = (statusListView.count + 1) * (statusListView.count ? statusListView.contentItem.children[0].width : 1)
37 38 39
        root.width = root.maxWidth > calcLength ? calcLength : root.maxWidth
    }

40
    QGCPalette { id: qgcPal }
41

42 43 44 45
    QGCLabel {
        id:                     label
        anchors.top:            parent.bottom
        width:                  parent.height
46
        text:                   qsTr("Terrain Altitude")
47 48 49 50
        horizontalAlignment:    Text.AlignHCenter
        rotation:               -90
        transformOrigin:        Item.TopLeft
    }
51

52 53 54
    QGCListView {
        id:                     statusListView
        anchors.margins:        _margins
55 56 57 58 59
        anchors.top:            parent.top
        anchors.bottom:         parent.bottom
        anchors.leftMargin:     ScreenTools.defaultFontPixelHeight
        anchors.left:           parent.left
        anchors.right:          parent.right
60 61 62 63 64
        model:                  missionItems
        highlightMoveDuration:  250
        orientation:            ListView.Horizontal
        spacing:                0
        clip:                   true
65
        currentIndex:           _missionController.currentPlanViewSeqNum
66

67
        onCountChanged: {
68
            var calcLength = (statusListView.count + 1) * (statusListView.count ? statusListView.contentItem.children[0].width : 1)
69 70 71
            root.width = root.maxWidth > calcLength ? calcLength : root.maxWidth
        }

72 73 74 75 76
        delegate: Item {
            height:     statusListView.height
            width:      display ? (indicator.width + spacing)  : 0
            visible:    display

77
            property real availableHeight:      height - indicator.height
78
            property bool _coordValid:          object.coordinate.isValid
79 80
            property bool _terrainAvailable:    !isNaN(object.terrainPercent)
            property real _terrainPercent:      _terrainAvailable ? object.terrainPercent : 1
81

82 83 84
            readonly property bool display: object.specifiesCoordinate && !object.isStandaloneCoordinate
            readonly property real spacing: ScreenTools.defaultFontPixelWidth * ScreenTools.smallFontPointRatio

85 86 87 88
            Rectangle {
                anchors.bottom:             parent.bottom
                anchors.horizontalCenter:   parent.horizontalCenter
                width:                      indicator.width
89
                height:                     _terrainAvailable ? Math.max(availableHeight * _terrainPercent, 1) : parent.height
90
                color:                      _terrainAvailable ? (object.terrainCollision ? "red": qgcPal.text) : "yellow"
91
                visible:                    _coordValid
92 93
            }

94 95 96 97 98 99
            MissionItemIndexLabel {
                id:                         indicator
                anchors.horizontalCenter:   parent.horizontalCenter
                y:                          availableHeight - (availableHeight * object.altPercent)
                small:                      true
                checked:                    object.isCurrentItem
100
                label:                      object.abbreviation.charAt(0)
101
                index:                      object.abbreviation.charAt(0) > 'A' && object.abbreviation.charAt(0) < 'z' ? -1 : object.sequenceNumber
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
                showSequenceNumbers:        false
            }

            Rectangle {
                id:                     indexBackground
                anchors.leftMargin:     -2
                anchors.rightMargin:    -2
                anchors.fill:           indexLabel
                color:                  qgcPal.window
                opacity:                0.3
                visible:                indexLabel.visible
                transform:              Rotation { angle: 90; origin.x: indexBackground.width / 2; origin.y: indexBackground.height / 2 }
            }

            QGCLabel {
                id:                 indexLabel
                anchors.centerIn:   parent
                text:               object.sequenceNumber
                visible:            indicator.index != -1
                transform:          Rotation { angle: 90; origin.x: indexLabel.width / 2; origin.y: indexLabel.height / 2 }
            }

            MouseArea {
                anchors.fill:   parent
                onClicked:      root.setCurrentSeqNum(object.sequenceNumber)
127 128 129 130
            }
        }
    }
}