Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Itinerary
Commits
081c6a66
Commit
081c6a66
authored
Jan 30, 2022
by
Volker Krause
Browse files
Warn about severe weather conditions
parent
0825fb38
Pipeline
#130826
passed with stage
in 1 minute and 26 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
autotests/weathertest.cpp
View file @
081c6a66
...
...
@@ -60,6 +60,7 @@ private Q_SLOTS:
QCOMPARE
((
*
it
).
precipitation
(),
0.0
f
);
QCOMPARE
((
*
it
).
symbolType
(),
WeatherForecast
::
Clear
);
QCOMPARE
((
*
it
).
windSpeed
(),
1.6
f
);
QCOMPARE
((
*
it
).
isSevere
(),
false
);
}
void
testWeatherSymbol
()
...
...
src/app/WeatherForecastDelegate.qml
View file @
081c6a66
...
...
@@ -22,7 +22,7 @@ Kirigami.AbstractCard {
id
:
headerBackground
Kirigami.Theme.colorSet
:
Kirigami
.
Theme
.
Complementary
Kirigami.Theme.inherit
:
false
color
:
Kirigami
.
Theme
.
backgroundColor
color
:
weatherForecast
.
isSevere
?
Kirigami
.
Theme
.
negativeBackgroundColor
:
Kirigami
.
Theme
.
backgroundColor
radius
:
Kirigami
.
Units
.
smallSpacing
implicitWidth
:
icon
.
implicitWidth
+
Kirigami
.
Units
.
largeSpacing
*
2
Layout.minimumHeight
:
implicitWidth
...
...
src/app/WeatherForecastPage.qml
View file @
081c6a66
...
...
@@ -27,6 +27,7 @@ Kirigami.Page {
Kirigami.AbstractListItem
{
readonly
property
var
fc
:
model
.
weatherForecast
highlighted
:
false
backgroundColor
:
fc
.
isSevere
?
Kirigami
.
Theme
.
negativeBackgroundColor
:
"
transparent
"
Row
{
spacing
:
Kirigami
.
Units
.
largeSpacing
Kirigami.Icon
{
...
...
src/weather/weatherforecast.cpp
View file @
081c6a66
...
...
@@ -213,3 +213,30 @@ void WeatherForecast::setTile(WeatherTile tile)
d
.
detach
();
d
->
m_tile
=
tile
;
}
bool
WeatherForecast
::
isSevere
()
const
{
// heat: https://en.wikipedia.org/wiki/Heat_index
// TODO to do this properly we need the humidity value as well
if
(
d
->
m_maxTemp
>
35.0
)
{
return
true
;
}
// cold
if
(
d
->
m_minTemp
<
-
20.0
)
{
return
true
;
}
// precipitation: https://de.wikipedia.org/wiki/Unwetter
if
((
d
->
m_precipitation
/
d
->
m_range
)
>
25.0
||
(
d
->
m_precipitation
>
35.0
&&
d
->
m_range
>=
6
))
{
return
true
;
}
// wind: https://en.wikipedia.org/wiki/Beaufort_scale
if
(
d
->
m_windSpeed
>
17.5
)
{
return
true
;
}
return
false
;
}
src/weather/weatherforecast.h
View file @
081c6a66
...
...
@@ -28,6 +28,7 @@ class WeatherForecast
Q_PROPERTY
(
float
windSpeed
READ
windSpeed
CONSTANT
)
Q_PROPERTY
(
QString
symbolIconName
READ
symbolIconName
CONSTANT
)
Q_PROPERTY
(
int
range
READ
range
CONSTANT
)
Q_PROPERTY
(
bool
isSevere
READ
isSevere
STORED
false
)
public:
enum
SymbolFlag
:
uint16_t
{
...
...
@@ -86,6 +87,10 @@ public:
// internal for weighting different forecast elements
int
range
()
const
;
void
setRange
(
int
hours
);
/** Severe weather conditions. */
bool
isSevere
()
const
;
// internal for computing the day/night icons
WeatherTile
tile
()
const
;
void
setTile
(
WeatherTile
tile
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment