Handles the logic for requesting geographical and weather data from network services.
More...
#include <WeatherRequestEngine.h>
|
void | weatherDataReady (const WeatherData data) |
| Signal emitted when new weather data is successfully retrieved and ready.
|
|
void | errorOccurred (const QString &errorMessage) |
| Signal emitted when an error occurs during the data request process.
|
|
Handles the logic for requesting geographical and weather data from network services.
This class is responsible for making network requests to obtain location data (latitude and longitude) for a given city, and then using those coordinates to fetch current weather conditions. It utilizes a caching mechanism (QueryCached
) to reduce redundant API calls and optimize performance. Signals are emitted upon successful data retrieval or if an error occurs.
◆ WeatherRequestEngine()
WeatherRequestEngine::WeatherRequestEngine |
( |
const QString & |
city, |
|
|
QObject * |
parent = nullptr |
|
) |
| |
|
explicit |
Constructs a WeatherRequestEngine object.
- Parameters
-
city | The name of the city for which weather data will be requested. |
parent | A pointer to the parent QObject, allowing for proper object hierarchy and memory management. Defaults to nullptr. |
◆ ~WeatherRequestEngine()
WeatherRequestEngine::~WeatherRequestEngine |
( |
| ) |
|
|
default |
Destroys the WeatherRequestEngine object.
- The default destructor is sufficient as
QObject
handles child deletion, and QueryCached
is a child of this object.
◆ errorOccurred
void WeatherRequestEngine::errorOccurred |
( |
const QString & |
errorMessage | ) |
|
|
signal |
Signal emitted when an error occurs during the data request process.
- Parameters
-
errorMessage | A QString describing the nature of the error. |
◆ queryWeatherData()
void WeatherRequestEngine::queryWeatherData |
( |
| ) |
|
Initiates a request for weather data.
- This method first checks the cache. If the cached data is valid, it emits
weatherDataReady
immediately. Otherwise, it triggers network requests: first for geographical coordinates if not already known, then for weather data.
◆ weatherDataReady
void WeatherRequestEngine::weatherDataReady |
( |
const WeatherData |
data | ) |
|
|
signal |
Signal emitted when new weather data is successfully retrieved and ready.
- Parameters
-
data | A constant reference to the WeatherData object containing the fetched weather details. |
The documentation for this class was generated from the following files:
- plugin_loader/plugin_cards/WeatherCard/WeatherRequestEngine.h
- plugin_loader/plugin_cards/WeatherCard/WeatherRequestEngine.cpp