Warning, /pim/itinerary/src/app/WeatherForecastPage.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 import QtQuick
0008 import QtQuick.Layouts
0009 import QtQuick.Controls as QQC2
0010 import org.kde.kirigami as Kirigami
0011 import org.kde.kitinerary
0012 import org.kde.itinerary
0013 
0014 Kirigami.ScrollablePage {
0015     id: root
0016 
0017     property var weatherInformation
0018 
0019     title: i18n("Weather Forecast")
0020 
0021     header: QQC2.ToolBar {
0022         width: root.width
0023 
0024         QQC2.Label {
0025             text: root.weatherInformation.locationName
0026             padding: Kirigami.Units.largeSpacing
0027             visible: text.length > 0
0028         }
0029     }
0030 
0031     footer: QQC2.ToolBar {
0032         width: root.width
0033 
0034         contentItem: Kirigami.Heading {
0035             level: 2
0036             text: i18n("Using data from <a href=\"https://www.met.no/\">The Norwegian Meteorological Institute</a> under <a href=\"https://creativecommons.org/licenses/by/4.0\">Creative Commons 4.0 BY International</a> license.")
0037             font: Kirigami.Theme.smallFont
0038             wrapMode: Text.WordWrap
0039             onLinkActivated: Qt.openUrlExternally(link)
0040         }
0041     }
0042 
0043     ListView {
0044         id: forecastList
0045 
0046         model: WeatherForecastModel {
0047             weatherForecast: root.weatherInformation.forecast
0048             weatherForecastManager: WeatherForecastManager
0049         }
0050 
0051         delegate: QQC2.ItemDelegate {
0052             id: weatherForecastDelegate
0053 
0054             required property var weatherForecast
0055             required property string localizedTime
0056 
0057             highlighted: false
0058             width: ListView.view.width
0059 
0060             background: Rectangle {
0061                 color: weatherForecast.isSevere ? Kirigami.Theme.negativeBackgroundColor : Kirigami.Theme.backgroundColor
0062             }
0063 
0064             contentItem: RowLayout {
0065                 spacing: 0
0066 
0067                 Kirigami.Icon {
0068                     source: weatherForecast.symbolIconName
0069                     Layout.preferredHeight: Kirigami.Units.iconSizes.smallMedium
0070                     Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium
0071                     Layout.rightMargin: Kirigami.Units.largeSpacing
0072                 }
0073 
0074                 QQC2.Label {
0075                     text: weatherForecastDelegate.localizedTime
0076                     Layout.rightMargin: Kirigami.Units.largeSpacing
0077                 }
0078 
0079                 Kirigami.Icon {
0080                     Layout.preferredHeight: Kirigami.Units.iconSizes.small
0081                     Layout.preferredWidth: Kirigami.Units.iconSizes.small
0082                     source: {
0083                         if (weatherForecastDelegate.weatherForecast.maximumTemperature > 35.0)
0084                             return "temperature-warm";
0085                         if (weatherForecastDelegate.weatherForecast.minimumTemperature < -20.0)
0086                             return "temperature-cold";
0087                         return "temperature-normal"
0088                     }
0089                 }
0090                 QQC2.Label {
0091                     text: weatherForecastDelegate.weatherForecast.minimumTemperature === weatherForecastDelegate.weatherForecast.maximumTemperature ?
0092                         Localizer.formatTemperature(weatherForecastDelegate.weatherForecast.maximumTemperature) :
0093                         i18nc("temperature range", "%1 / %2",  Localizer.formatTemperature(weatherForecastDelegate.weatherForecast.minimumTemperature),
0094                                                             Localizer.formatTemperature(weatherForecastDelegate.weatherForecast.maximumTemperature))
0095                     Layout.rightMargin: Kirigami.Units.largeSpacing
0096                 }
0097 
0098                 Kirigami.Icon {
0099                     Layout.preferredHeight: Kirigami.Units.iconSizes.small
0100                     Layout.preferredWidth: Kirigami.Units.iconSizes.small
0101                     source: "raindrop"
0102                     color: weatherForecastDelegate.weatherForecast.precipitation > 25.0 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.textColor
0103                     visible: weatherForecastDelegate.weatherForecast.precipitation > 0
0104                 }
0105                 QQC2.Label {
0106                     text: i18nc("precipitation", "%1 mm", weatherForecastDelegate.weatherForecast.precipitation)
0107                     visible: weatherForecastDelegate.weatherForecast.precipitation > 0
0108                     Layout.rightMargin: Kirigami.Units.largeSpacing
0109                 }
0110 
0111                 Kirigami.Icon {
0112                     Layout.preferredHeight: Kirigami.Units.iconSizes.small
0113                     Layout.preferredWidth: Kirigami.Units.iconSizes.small
0114                     source: "flag"
0115                     color: weatherForecastDelegate.weatherForecast.windSpeed > 17.5 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.textColor
0116                     visible: weatherForecastDelegate.weatherForecast.windSpeed > 3.5
0117                 }
0118                 QQC2.Label {
0119                     text: i18nc("windSpeed", "%1 m/s", weatherForecastDelegate.weatherForecast.windSpeed)
0120                     visible: weatherForecastDelegate.weatherForecast.windSpeed > 3.5
0121                 }
0122 
0123                 Item { Layout.fillWidth: true }
0124             }
0125         }
0126     }
0127 }