NoticesView.qml 2.07 KB
Newer Older
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
1
/*
2
 * Copyright 2018  Friedrich W. H. Kossebau <kossebau@kde.org>
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

18
import QtQuick 2.9
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
19

20 21 22 23 24 25
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
26 27
    id: root

28
    property alias model: categoryRepeater.model
29
    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
30

31
    spacing: units.largeSpacing
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
32

33 34 35 36 37 38 39 40 41 42 43
    Repeater {
        id: categoryRepeater

        delegate: ColumnLayout {
            property var categoryData: modelData

            Layout.alignment: Qt.AlignTop | Qt.AlignHCenter

            PlasmaExtras.Heading {
                level: 4

44
                text: index == 0 ? i18nc("@title:column weather warnings", "Warnings Issued") : i18nc("@title:column weather watches" ,"Watches Issued")
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
            }

            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
68 69
    }

70 71
    Item {
        Layout.fillHeight: true
Luís Gabriel Lima's avatar
Luís Gabriel Lima committed
72 73
    }
}