| 1 |
/* |
| 2 |
* Copyright (C) 2015 Canonical Ltd. |
| 3 |
* |
| 4 |
* This file is part of Lomiri Weather App |
| 5 |
* |
| 6 |
* Lomiri Weather App is free software: you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License version 3 as |
| 8 |
* published by the Free Software Foundation. |
| 9 |
* |
| 10 |
* Lomiri Weather App is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
import QtQuick 2.12 |
| 20 |
import Lomiri.Components 1.3 |
| 21 |
|
| 22 |
|
| 23 |
Column { |
| 24 |
id: extraInfoColumn |
| 25 |
anchors { |
| 26 |
top: parent.top |
| 27 |
// do not add bottom anchor here |
| 28 |
} |
| 29 |
width: parent.width |
| 30 |
objectName: "dayDelegateExtraInfo" |
| 31 |
spacing: units.gu(1.5) |
| 32 |
|
| 33 |
property bool isToday: checkToday(modelData.date) |
| 34 |
|
| 35 |
// Overview text |
| 36 |
Label { |
| 37 |
id: conditionForecast |
| 38 |
color: theme.palette.normal.baseText |
| 39 |
fontSize: "large" |
| 40 |
horizontalAlignment: Text.AlignHCenter |
| 41 |
text: modelData.condition |
| 42 |
width: parent.width |
| 43 |
} |
| 44 |
|
| 45 |
ForecastDetailsDelegate { |
| 46 |
id: chanceOfPrecipForecast |
| 47 |
forecast: i18n.tr("Chance of precipitation") |
| 48 |
imageSource: "qrc:/extended-information_chance-of-sleet.svg" |
| 49 |
// sometimes even with zero downfall, chance of precipitation returns a (small) value |
| 50 |
// 10% chance for zero downfall does not make much sense |
| 51 |
// -> disable entry for empty rain/snow values by setting value to "" |
| 52 |
value: modelData.rain > 0 || modelData.snow > 0 ? "" : modelData.chanceOfPrecip |
| 53 |
} |
| 54 |
|
| 55 |
ForecastDetailsDelegate { |
| 56 |
id: rainForecast |
| 57 |
forecast: i18n.tr("Rain volume") |
| 58 |
imageSource: "qrc:/extended-information_chance-of-rain.svg" |
| 59 |
value: modelData.rain |
| 60 |
} |
| 61 |
|
| 62 |
ForecastDetailsDelegate { |
| 63 |
id: snowForecast |
| 64 |
forecast: i18n.tr("Snow volume") |
| 65 |
imageSource: "qrc:/extended-information_chance-of-snow.svg" |
| 66 |
value: modelData.snow |
| 67 |
} |
| 68 |
|
| 69 |
ForecastDetailsDelegate { |
| 70 |
id: windForecast |
| 71 |
forecast: i18n.tr("Winds") |
| 72 |
imageSource: "qrc:/extended-information_wind.svg" |
| 73 |
objectName: "windForecast" |
| 74 |
value: isToday ? "" : modelData.wind //disable entry for today's entry |
| 75 |
} |
| 76 |
|
| 77 |
ForecastDetailsDelegate { |
| 78 |
id: uvIndexForecast |
| 79 |
imageSource: "qrc:/extended-information_uv-level.svg" |
| 80 |
forecast: i18n.tr("UV Index") |
| 81 |
value: modelData.uvIndexDay |
| 82 |
} |
| 83 |
|
| 84 |
ForecastDetailsDelegate { |
| 85 |
id: sunshineDurationForecast |
| 86 |
imageName: "weather-clear-symbolic" |
| 87 |
forecast: i18n.tr("Sunshine duration") |
| 88 |
value: modelData.sunshinetime |
| 89 |
} |
| 90 |
|
| 91 |
ForecastDetailsDelegate { |
| 92 |
id: humidityForecast |
| 93 |
forecast: i18n.tr("Humidity") |
| 94 |
imageSource: "qrc:/extended-information_humidity.svg" |
| 95 |
value: isToday ? "" : modelData.humidity //disable entry for today's entry |
| 96 |
} |
| 97 |
|
| 98 |
ForecastDetailsDelegate { |
| 99 |
id: sunriseForecast |
| 100 |
forecast: i18n.tr("Sunrise") |
| 101 |
imageSource: "qrc:/extended-information_sunrise.svg" |
| 102 |
value: modelData.sunrise |
| 103 |
} |
| 104 |
|
| 105 |
ForecastDetailsDelegate { |
| 106 |
id: sunsetForecast |
| 107 |
forecast: i18n.tr("Sunset") |
| 108 |
imageSource: "qrc:/extended-information_sunset.svg" |
| 109 |
value: modelData.sunset |
| 110 |
} |
| 111 |
|
| 112 |
ForecastDetailsDelegate { |
| 113 |
id: pressureForecast |
| 114 |
forecast: i18n.tr("Pressure") |
| 115 |
value: modelData.pressure |
| 116 |
imageSource: "qrc:/extended-information_pressure.svg" |
| 117 |
} |
| 118 |
|
| 119 |
ForecastDetailsDelegate { |
| 120 |
id: moonphaseForecast |
| 121 |
forecast: i18n.tr("Moonphase") |
| 122 |
imageSource: modelData.moonImage |
| 123 |
value: modelData.moonPhase |
| 124 |
} |
| 125 |
|
| 126 |
// checks if data day is equal to today for skipping some values |
| 127 |
function checkToday(datadate) { |
| 128 |
var day = Qt.formatDate(new Date(datadate.year, datadate.month, datadate.date, datadate.hours, datadate.minutes)) |
| 129 |
var today = Qt.formatDate(new Date()) |
| 130 |
return today === day ? true : false |
| 131 |
} |
| 132 |
} |