NoticesView.qml 1.66 KB
Newer Older
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
1
/*
2
 * SPDX-FileCopyrightText: 2018 Friedrich W. H. Kossebau <kossebau@kde.org>
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
3
 *
4
 * SPDX-License-Identifier: GPL-2.0-or-later
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
5 6
 */

7
import QtQuick 2.9
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
8

9 10 11 12 13 14
import QtQuick.Layouts 1.3

import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras

ColumnLayout {
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
15 16
    id: root

17
    property alias model: categoryRepeater.model
18
    readonly property bool hasContent: model && model.length > 0 && (model[0].length > 0 || model[1].length > 0)
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
19

20
    spacing: units.largeSpacing
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
21

22 23 24 25 26 27
    Repeater {
        id: categoryRepeater

        delegate: ColumnLayout {
            property var categoryData: modelData

28 29 30
            readonly property bool categoryHasNotices: categoryData.length > 0
            visible: categoryHasNotices

31 32 33 34
            Layout.alignment: Qt.AlignTop | Qt.AlignHCenter

            PlasmaExtras.Heading {
                level: 4
35
                Layout.alignment: Qt.AlignHCenter
36

37
                text: index == 0 ? i18nc("@title:column weather warnings", "Warnings Issued") : i18nc("@title:column weather watches" ,"Watches Issued")
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
            }

            Repeater {
                id: repeater

                model: categoryData

                delegate: PlasmaComponents.Label {
                    font.underline: true
                    color: theme.linkColor

                    text: modelData.description

                    MouseArea {
                        anchors.fill: parent

                        onClicked: {
                            Qt.openUrlExternally(modelData.info);
                        }
                    }
                }
            }
        }
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
61 62
    }

63 64
    Item {
        Layout.fillHeight: true
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
65 66
    }
}