KWeatherCore

hourlyweatherforecast.h
1/*
2 * SPDX-FileCopyrightText: 2020-2021 Han Young <hanyoung@protonmail.com>
3 * SPDX-FileCopyrightText: 2020 Devin Lin <espidev@gmail.com>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
8#pragma once
9#include <QDateTime>
10#include <QJsonObject>
11#include <QObject>
12#include <kweathercore/kweathercore_export.h>
13#include <memory>
14namespace KWeatherCore
15{
16Q_NAMESPACE_EXPORT(KWEATHERCORE_EXPORT)
17enum class WindDirection { N, NW, W, SW, S, SE, E, NE };
18Q_ENUM_NS(WindDirection)
19
20/**
21 * @short Class represents weatherforecast in a hour
22 *
23 * This is a class to hold hourly forecast
24 *
25 * @see DailyWeatherForecast
26 *
27 * @author Han Young <hanyoung@protonmail.com>
28 */
29class KWEATHERCORE_EXPORT HourlyWeatherForecast
30{
31 Q_GADGET
32 Q_PROPERTY(QDateTime date READ date)
33 Q_PROPERTY(QString weatherDescription READ weatherDescription)
34 Q_PROPERTY(QString weatherIcon READ weatherIcon)
35 Q_PROPERTY(QString neutralWeatherIcon READ neutralWeatherIcon)
36 Q_PROPERTY(double windDirectionDegree READ windDirectionDegree)
37 Q_PROPERTY(KWeatherCore::WindDirection windDirectionCardinal READ windDirectionCardinal STORED false)
38 Q_PROPERTY(qreal temperature READ temperature)
39 Q_PROPERTY(qreal pressure READ pressure)
40 Q_PROPERTY(qreal windSpeed READ windSpeed)
41 Q_PROPERTY(qreal humidity READ humidity)
42 Q_PROPERTY(qreal fog READ fog)
43 Q_PROPERTY(qreal uvIndex READ uvIndex)
44 Q_PROPERTY(qreal precipitationAmount READ precipitationAmount)
45public:
46 /**
47 * HourlyWeatherForecast construct a null forecast
48 */
50 explicit HourlyWeatherForecast(const QDateTime &date);
54
55 /**
56 * convert this to QJsonObject
57 */
58 QJsonObject toJson() const;
59 /**
60 * construct from QJsonObject
61 */
62 static HourlyWeatherForecast fromJson(const QJsonObject &obj);
63 /**
64 * date of the forecast
65 * @return
66 */
67 const QDateTime &date() const;
68 /**
69 * set date
70 */
71 void setDate(const QDateTime &date);
72 /**
73 * weather description
74 */
75 const QString &weatherDescription() const;
76 /**
77 * set weather description
78 */
79 void setWeatherDescription(const QString &weatherDescription);
80 /**
81 * weather icon, breeze icon if construct by WeatherForecastSource
82 */
83 const QString &weatherIcon() const;
84 /**
85 * set weather icon
86 */
87 void setWeatherIcon(const QString &weatherIcon);
88 /**
89 * icon without "day" or "night" attached
90 */
91 const QString &neutralWeatherIcon() const;
92 /**
93 * set neutral weatherIcon
94 */
95 void setNeutralWeatherIcon(const QString &neutralWeatherIcon);
96 /**
97 * internal symbolcode from api, normally you can ignore this
98 */
99 const QString &symbolCode() const;
100 /**
101 * set internal symbolcode from api, normally you can ignore this
102 */
103 void setSymbolCode(const QString &symbolCode);
104 /**
105 * temperature in celsius
106 */
107 double temperature() const;
108 /**
109 * set temperature in celsius
110 */
111 void setTemperature(double temperature);
112 /**
113 * pressure in hpa
114 */
115 double pressure() const;
116 /**
117 * set pressure in hpa
118 */
119 void setPressure(double pressure);
120 /**
121 * Wind direction in degree.
122 * That is, the direction the wind is coming from.
123 * @see https://en.wikipedia.org/wiki/Wind_direction
124 * @see windDirectionCardinal
125 */
126 double windDirectionDegree() const;
127 /**
128 * Sets the wind direction in degree.
129 * @see windDirectionDegree
130 */
131 void setWindDirectionDegree(double windDirection);
132 /**
133 * Cardinal wind direction.
134 * That is, the cardinal direction the wind is coming from.
135 * @see windDirectionDegree
136 */
137 WindDirection windDirectionCardinal() const;
138 /**
139 * wind speed in km/h
140 */
141 double windSpeed() const;
142 /**
143 * set wind speed in km/h
144 */
145 void setWindSpeed(double windSpeed);
146 /**
147 * humidity in percentage
148 */
149 double humidity() const;
150 /**
151 * set humidity in percentage
152 */
153 void setHumidity(double humidity);
154 /**
155 * fog in percentage
156 */
157 double fog() const;
158 /**
159 * set fog in percentage
160 */
161 void setFog(double fog);
162 /**
163 * uv index, 0-1
164 */
165 double uvIndex() const;
166 /**
167 * set uv index, 0-1
168 */
169 void setUvIndex(double uvIndex);
170 /**
171 * precipitation in mm
172 */
173 double precipitationAmount() const;
174 /**
175 * set precipitation in mm
176 */
177 void setPrecipitationAmount(double precipitationAmount);
178 /**
179 * @return true if date, weather icon and description is same
180 */
181 bool operator==(const KWeatherCore::HourlyWeatherForecast &) const;
182 HourlyWeatherForecast &operator=(const HourlyWeatherForecast &other);
184
185private:
186 class HourlyWeatherForecastPrivate;
187 std::unique_ptr<HourlyWeatherForecastPrivate> d;
188};
189}
Class represents weatherforecast in a hour.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:42 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.