File indexing completed on 2024-05-05 16:49:22

0001 /*
0002  * SPDX-FileCopyrightText: 2020-2021 Han Young <hanyoung@protonmail.com>
0003  * SPDX-FileCopyrightText: 2020 Devin Lin <espidev@gmail.com>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 #pragma once
0008 #include "weatherforecast.h"
0009 #include <QExplicitlySharedDataPointer>
0010 #include <QObject>
0011 #include <kweathercore/kweathercore_export.h>
0012 class QNetworkReply;
0013 namespace KWeatherCore
0014 {
0015 class PendingWeatherForecastPrivate;
0016 /**
0017  * @short The PendingWeatherForecast class contains the reply to an asynchronous
0018  * weather forecast request.
0019  *
0020  * @see WeatherForecastSource
0021  *
0022  * @author Han Young <hanyoung@protonmail.com>
0023  */
0024 class KWEATHERCORE_EXPORT PendingWeatherForecast : public QObject
0025 {
0026     Q_OBJECT
0027 public:
0028     /**
0029      * value pointer to the shared weather data
0030      * the pointer is nullptr until finished() raised
0031      * @return
0032      */
0033     QExplicitlySharedDataPointer<WeatherForecast> value() const;
0034     /**
0035      * isFinished if the call has finished
0036      * @return
0037      */
0038     bool isFinished() const;
0039 
0040 Q_SIGNALS:
0041     /**
0042      * signals the call has finished
0043      */
0044     void finished();
0045     /**
0046      * indicate there is a network error
0047      */
0048     void networkError();
0049 
0050 protected:
0051     friend class WeatherForecastSourcePrivate;
0052     explicit PendingWeatherForecast(
0053         double latitude,
0054         double longitude,
0055         QNetworkReply *reply = nullptr,
0056         const QString &timezone = QString(),
0057         const std::vector<Sunrise> &sunrise = std::vector<Sunrise>());
0058 
0059 private:
0060     PendingWeatherForecastPrivate *d = nullptr;
0061 };
0062 }