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

KDE's Doxygen guidelines are available online.