File indexing completed on 2024-04-28 04:42:43

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 
0009 #include "pendingweatherforecast.h"
0010 #include <kweathercore/kweathercore_export.h>
0011 
0012 #include <QObject>
0013 
0014 #include <memory>
0015 
0016 class QNetworkAccessManager;
0017 
0018 namespace KWeatherCore
0019 {
0020 
0021 class LocationQueryResult;
0022 class WeatherForecastSourcePrivate;
0023 
0024 /**
0025  * @short The WeatherForecastSource class is intended for query weather
0026  * information about a location
0027  *
0028  * @see WeatherForecast, PendingWeatherForecast
0029  *
0030  * @author Han Young <hanyoung@protonmail.com>
0031  */
0032 class KWEATHERCORE_EXPORT WeatherForecastSource : public QObject
0033 {
0034     Q_OBJECT
0035 public:
0036     explicit WeatherForecastSource(QObject *parent = nullptr);
0037     ~WeatherForecastSource() override;
0038 
0039     /**
0040      * requestData
0041      * @param latitude
0042      * @param longitude
0043      * @return it is the client's responsibility to delete the
0044      * PendingWeatherForecast afterhand to avoid memory leak.
0045      */
0046     PendingWeatherForecast *requestData(double latitude, double longitude);
0047 
0048     /**
0049      * requestData
0050      * @param result
0051      * @return it is the client's responsibility to delete the
0052      * PendingWeatherForecast afterhand to avoid memory leak.
0053      */
0054     PendingWeatherForecast *requestData(const KWeatherCore::LocationQueryResult &result);
0055 
0056     /** Set the network access manager to use for network operations.
0057      *  If not set, an instance is created internally.
0058      *  Ownership is not transferred.
0059      */
0060     void setNetworkAccessManager(QNetworkAccessManager *nam);
0061 
0062 private:
0063     std::unique_ptr<WeatherForecastSourcePrivate> d;
0064 };
0065 }