NoticesView.qml 1.72 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
import QtQuick.Layouts 1.3

import org.kde.plasma.components 3.0 as PlasmaComponents
12
import org.kde.plasma.core 2.0 as PlasmaCore
13 14 15
import org.kde.plasma.extras 2.0 as PlasmaExtras

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

18
    property alias model: categoryRepeater.model
19
    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
20

21
    spacing: PlasmaCore.Units.largeSpacing
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
22

23 24 25 26 27 28
    Repeater {
        id: categoryRepeater

        delegate: ColumnLayout {
            property var categoryData: modelData

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

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

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

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

            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
62 63
    }

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