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);
31 WeatherForecast &operator=(const WeatherForecast &other);
32 WeatherForecast &operator=(WeatherForecast &&) noexcept;
34 /**
35 * convert to QJsonObject
36 */
37 QJsonObject toJson() const;
38 /**
39 * construct from json
40 */
41 static WeatherForecast fromJson(const QJsonObject &obj);
42 /**
43 * @return daily weather forecast
44 */
45 const std::vector<DailyWeatherForecast> &dailyWeatherForecast() const;
46 double latitude() const;
47 double longitude() const;
48 /**
49 * @return the time this forecast object was created, this value won't
50 * change once constructed
51 */
52 const QDateTime &createdTime() const;
53 /**
54 * IANA Time Zone ID
55 * @return
56 */
57 const QString &timezone() const;
58 /**
59 * setCoordinate
60 */
61 void setCoordinate(double latitude, double longitude);
62 /**
63 * @param timezone valid IANA Time Zone ID
64 */
65 void setTimezone(QString timezone);
66 void setDailyWeatherForecast(std::vector<DailyWeatherForecast> &&forecast);
67
68 /**
69 * merge HourlyWeatherForecast, new day is created when required
70 */
71 WeatherForecast &operator+=(HourlyWeatherForecast &&forecast);
72
73private:
74 void setCreatedTime(const QDateTime &date);
75 class WeatherForecastPrivate;
77};
78}
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 Fri Dec 20 2024 12:00:07 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.