1/*
2 * SPDX-FileCopyrightText: 2018 Friedrich W. H. Kossebau <kossebau@kde.org>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7import QtQuick 2.9
8
9import QtQuick.Layouts 1.3
10
11import org.kde.plasma.components 3.0 as PlasmaComponents
12import org.kde.plasma.core 2.0 as PlasmaCore
13import org.kde.plasma.extras 2.0 as PlasmaExtras
14
15ColumnLayout {
16    id: root
17
18    property alias model: categoryRepeater.model
19    readonly property bool hasContent: model && model.length > 0 && (model[0].length > 0 || model[1].length > 0)
20
21    spacing: PlasmaCore.Units.largeSpacing
22
23    Repeater {
24        id: categoryRepeater
25
26        delegate: ColumnLayout {
27            property var categoryData: modelData
28
29            readonly property bool categoryHasNotices: categoryData.length > 0
30            visible: categoryHasNotices
31
32            Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
33
34            PlasmaExtras.Heading {
35                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            Repeater {
42                id: repeater
43
44                model: categoryData
45
46                delegate: PlasmaComponents.Label {
47                    font.underline: true
48                    color: PlasmaCore.Theme.linkColor
49
50                    text: modelData.description
51
52                    MouseArea {
53                        anchors.fill: parent
54
55                        onClicked: {
56                            Qt.openUrlExternally(modelData.info);
57                        }
58                    }
59                }
60            }
61        }
62    }
63
64    Item {
65        Layout.fillHeight: true
66    }
67}
68