KWeatherCore

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