ComplianceRules.qml 4.92 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
import QtQuick                  2.3
import QtQuick.Controls         1.2
import QtQuick.Controls.Styles  1.4
import QtQuick.Dialogs          1.2
import QtQml                    2.2

import QGroundControl                   1.0
import QGroundControl.ScreenTools       1.0
import QGroundControl.Controls          1.0
import QGroundControl.Palette           1.0
import QGroundControl.Airmap            1.0
import QGroundControl.SettingsManager   1.0

Item {
    id:             _root
16 17 18 19 20 21 22 23 24 25 26
    height:         checked ? (header.height + content.height) : header.height
    property var    rules:      null
    property color  color:      "white"
    property alias  text:       title.text
    property bool   checked:    false
    property ExclusiveGroup exclusiveGroup: null
    onExclusiveGroupChanged: {
        if (exclusiveGroup) {
            exclusiveGroup.bindCheckable(_root)
        }
    }
27 28 29 30 31
    QGCPalette {
        id: qgcPal
        colorGroupEnabled: enabled
    }
    Rectangle {
32 33
        id:                 header
        height:             ScreenTools.defaultFontPixelHeight * 2
34
        color:              qgcPal.windowShade
35 36 37
        anchors.top:        parent.top
        anchors.right:      parent.right
        anchors.left:       parent.left
38 39 40
    }
    Row {
        spacing:            ScreenTools.defaultFontPixelWidth * 2
41
        anchors.fill:       header
42
        Rectangle {
43
            height:         parent.height
44
            width:          ScreenTools.defaultFontPixelWidth * 0.75
45
            color:          _root.color
46 47 48 49 50 51 52
        }
        QGCLabel {
            id:                 title
            anchors.verticalCenter: parent.verticalCenter
        }
    }
    QGCColoredImage {
53
        source:                 checked ? "qrc:/airmap/colapse.svg" : "qrc:/airmap/expand.svg"
54 55 56 57 58
        height:                 ScreenTools.defaultFontPixelHeight
        width:                  height
        color:                  qgcPal.text
        fillMode:               Image.PreserveAspectFit
        sourceSize.height:      height
59
        anchors.right:          header.right
60
        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
        anchors.verticalCenter: header.verticalCenter
    }
    MouseArea {
        anchors.fill:       header
        onClicked: {
            _root.checked = !_root.checked
        }
    }
    Rectangle {
        id:             content
        color:          qgcPal.window
        visible:        checked
        height:         ScreenTools.defaultFontPixelHeight * 10
        anchors.top:    header.bottom
        anchors.right:  parent.right
        anchors.left:   parent.left
        anchors.margins: ScreenTools.defaultFontPixelWidth
        Flickable {
            clip:           true
            anchors.fill:   parent
            contentHeight:  rulesetCol.height
            flickableDirection: Flickable.VerticalFlick
            Column {
                id:         rulesetCol
                spacing:    ScreenTools.defaultFontPixelHeight * 0.25
                anchors.right: parent.right
                anchors.left:  parent.left
                Repeater {
                    model:    _root.rules ? _root.rules : []
                    delegate: Item {
                        height:         ruleCol.height
                        anchors.right:  parent.right
                        anchors.left:   parent.left
                        anchors.margins: ScreenTools.defaultFontPixelWidth
                        Column {
                            id:         ruleCol
                            spacing:    ScreenTools.defaultFontPixelHeight * 0.5
                            anchors.right:  parent.right
                            anchors.left:   parent.left
                            Item { width: 1; height: ScreenTools.defaultFontPixelHeight * 0.25; }
                            QGCLabel {
                                text:           object.shortText !== "" ? object.shortText : qsTr("Rule")
                                anchors.right:  parent.right
                                anchors.left:   parent.left
                                wrapMode:       Text.WordWrap
                            }
                            QGCLabel {
                                text:           object.description
                                visible:        object.description !== ""
                                font.pointSize: ScreenTools.smallFontPointSize
                                anchors.right:  parent.right
                                anchors.left:   parent.left
                                wrapMode:       Text.WordWrap
                                anchors.rightMargin: ScreenTools.defaultFontPixelWidth * 0.5
                                anchors.leftMargin:  ScreenTools.defaultFontPixelWidth * 0.5
                            }
                        }
                    }
                }
                Item { width: 1; height: ScreenTools.defaultFontPixelHeight * 0.25; }
            }
        }
123 124
    }
}