MissionItemStatus.qml 4.22 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.
 *
 ****************************************************************************/
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
    height:     ScreenTools.defaultFontPixelHeight * 7
24
    radius:     ScreenTools.defaultFontPixelWidth * 0.5
25 26 27 28
    color:      qgcPal.window
    opacity:    0.80
    clip:       true

29
    property var missionItems                ///< List of all available mission items
30

31
    property real maxWidth:          parent.width
32
    readonly property real _margins: ScreenTools.defaultFontPixelWidth
33

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

39
    QGCPalette { id: qgcPal }
40

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

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

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

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

            property real availableHeight:  height - indicator.height
77 78 79
            property bool showTerrain:      !isNaN(object.terrainPercent)
            property real _terrainPercent:  showTerrain ? object.terrainPercent : 0

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

83 84 85 86 87 88 89 90 91
            Rectangle {
                anchors.bottom:             parent.bottom
                anchors.horizontalCenter:   parent.horizontalCenter
                width:                      indicator.width
                height:                     Math.max(availableHeight * _terrainPercent, 1)
                color:                      _terrainPercent > object.altPercent ? "red": qgcPal.text
                visible:                    !isNaN(object.terrainPercent)
            }

92 93 94 95 96 97
            MissionItemIndexLabel {
                id:                         indicator
                anchors.horizontalCenter:   parent.horizontalCenter
                y:                          availableHeight - (availableHeight * object.altPercent)
                small:                      true
                checked:                    object.isCurrentItem
98
                label:                      object.abbreviation.charAt(0)
99 100
                index:                      object.abbreviation.charAt(0) > 'A' && object.abbreviation.charAt(0) < 'z' ? -1 : object.sequenceNumber
                visible:                    true
101 102 103 104
            }
        }
    }
}
105

106