Warning, /pim/itinerary/src/app/WeatherForecastDelegate.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.kirigamiaddons.formcard as FormCard
0012 import org.kde.itinerary
0013 
0014 FormCard.FormCard {
0015     id: root
0016     width: ListView.view.width
0017     required property var weatherInformation
0018     readonly property var weatherForecast: weatherInformation.forecast
0019 
0020     visible: weatherForecast.valid
0021     FormCard.AbstractFormDelegate {
0022         id: content
0023         onClicked: if (weatherForecast.range > 1) { applicationWindow().pageStack.push(weatherForecastPage, {weatherInformation: root.weatherInformation}); }
0024         contentItem: RowLayout {
0025             spacing: 0
0026 
0027             Kirigami.Icon {
0028                 source: weatherForecast.symbolIconName
0029                 Layout.preferredHeight: Kirigami.Units.iconSizes.medium
0030                 Layout.preferredWidth: Kirigami.Units.iconSizes.medium
0031                 Layout.rightMargin: Kirigami.Units.largeSpacing
0032             }
0033 
0034             Kirigami.Icon {
0035                 Layout.preferredHeight: Kirigami.Units.iconSizes.small
0036                 Layout.preferredWidth: Kirigami.Units.iconSizes.small
0037                 source: {
0038                     if (weatherForecast.maximumTemperature > 35.0)
0039                         return "temperature-warm";
0040                     if (weatherForecast.minimumTemperature < -20.0)
0041                         return "temperature-cold";
0042                     return "temperature-normal"
0043                 }
0044             }
0045             QQC2.Label {
0046                 text: weatherForecast.minimumTemperature == weatherForecast.maximumTemperature ?
0047                     Localizer.formatTemperature(weatherForecast.maximumTemperature) :
0048                     i18nc("temperature range", "%1 / %2",  Localizer.formatTemperature(weatherForecast.minimumTemperature),
0049                                                            Localizer.formatTemperature(weatherForecast.maximumTemperature))
0050                 Layout.rightMargin: Kirigami.Units.largeSpacing
0051             }
0052 
0053             Kirigami.Icon {
0054                 Layout.preferredHeight: Kirigami.Units.iconSizes.small
0055                 Layout.preferredWidth: Kirigami.Units.iconSizes.small
0056                 source: "raindrop"
0057                 color: weatherForecast.precipitation > 25.0 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.textColor
0058                 visible: weatherForecast.precipitation > 0
0059             }
0060             QQC2.Label {
0061                 text: i18nc("precipitation", "%1 mm", weatherForecast.precipitation)
0062                 visible: weatherForecast.precipitation > 0
0063                 Layout.rightMargin: Kirigami.Units.largeSpacing
0064             }
0065 
0066             Kirigami.Icon {
0067                 Layout.preferredHeight: Kirigami.Units.iconSizes.small
0068                 Layout.preferredWidth: Kirigami.Units.iconSizes.small
0069                 source: "flag"
0070                 color: weatherForecast.windSpeed > 17.5 ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.textColor
0071                 visible: weatherForecast.windSpeed > 3.5
0072             }
0073             QQC2.Label {
0074                 text: i18nc("windSpeed", "%1 m/s", weatherForecast.windSpeed)
0075                 visible: weatherForecast.windSpeed > 3.5
0076             }
0077 
0078             Item { Layout.fillWidth: true }
0079         }
0080     }
0081 
0082 
0083     Accessible.name: i18n("Weather Forecast")
0084     Accessible.onPressAction: content.clicked()
0085 }