KWeatherCore

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

KDE's Doxygen guidelines are available online.