KWeatherCore

weatherforecast.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 #pragma once
8 #include "dailyweatherforecast.h"
9 #include "sunrise.h"
10 #include <QSharedData>
11 #include <kweathercore/kweathercore_export.h>
12 namespace KWeatherCore
13 {
14 /**
15  * @short The WeatherForecast class contains the weather information of one
16  * location for days
17  *
18  * @see WeatherForecastSource
19  *
20  * @author Han Young <[email protected]>
21  */
22 
23 class KWEATHERCORE_EXPORT WeatherForecast
24 {
25 public:
26  /**
27  * construct an empty object
28  */
30  WeatherForecast(const WeatherForecast &other);
31  WeatherForecast &operator=(const WeatherForecast &other);
32  ~WeatherForecast();
33  /**
34  * convert to QJsonObject
35  */
36  QJsonObject toJson() const;
37  /**
38  * construct from json
39  */
40  static WeatherForecast fromJson(QJsonObject obj);
41  /**
42  * @return daily weather forecast
43  */
44  const std::vector<DailyWeatherForecast> &dailyWeatherForecast() const;
45  double latitude() const;
46  double longitude() const;
47  /**
48  * @return the time this forecast object was created, this value won't
49  * change once constructed
50  */
51  const QDateTime &createdTime() const;
52  /**
53  * IANA Time Zone ID
54  * @return
55  */
56  const QString &timezone() const;
57  /**
58  * setCoordinate
59  */
60  void setCoordinate(double latitude, double longitude);
61  /**
62  * @param timezone valid IANA Time Zone ID
63  */
64  void setTimezone(QString timezone);
65  void setDailyWeatherForecast(const std::vector<DailyWeatherForecast> &forecast);
66  void setDailyWeatherForecast(std::vector<DailyWeatherForecast> &&forecast);
67  /**
68  * the vector should be sorted
69  */
70  void setSunriseForecast(const std::vector<Sunrise> &sunrise);
71  /**
72  * overloaded version
73  */
74  void setSunriseForecast(std::vector<Sunrise> &&sunrise);
75 
76  /**
77  * merge DailyWeatherForecast
78  */
79  WeatherForecast &operator+=(const DailyWeatherForecast &forecast);
80  /**
81  * overloaded version
82  */
83  WeatherForecast &operator+=(DailyWeatherForecast &&forecast);
84  /**
85  * merge HourlyWeatherForecast, new day is created when required
86  */
87  WeatherForecast &operator+=(const HourlyWeatherForecast &forecast);
88  /**
89  * overloaded version
90  */
91  WeatherForecast &operator+=(HourlyWeatherForecast &&forecast);
92 
93 private:
94  void setCreatedTime(const QDateTime &date);
95  class WeatherForecastPrivate;
97 };
98 }
Class represents weatherforecast in a day.
The WeatherForecast class contains the weather information of one location for days.
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.