19 #ifndef QGSNETWORKCONTENTFETCHERREGISTRY_H
20 #define QGSNETWORKCONTENTFETCHERREGISTRY_H
25 #include <QNetworkReply>
27 #include <QTemporaryFile>
29 #include "qgis_core.h"
70 QFile *
file()
const {
return mFile;}
74 const QString
filePath()
const {
return mFilePath;}
80 QNetworkReply::NetworkError
error()
const {
return mError;}
88 void download(
bool redownload =
false );
100 void taskCompleted();
104 QTemporaryFile *mFile =
nullptr;
108 QNetworkReply::NetworkError mError = QNetworkReply::NoError;
133 Q_ENUM( FetchingMode )
154 QFile *localFile(
const QString &filePathOrUrl );
161 QString localPath(
const QString &filePathOrUrl );
164 QMap<QString, QgsFetchedContent *> mFileRegistry;
FetchedContent holds useful information about a network content being fetched.
QNetworkReply::NetworkError error() const
Returns the potential error of the download.
~QgsFetchedContent() override
ContentStatus status() const
Returns the status of the download.
QFile * file() const
Returns a pointer to the local file, or nullptr if the file is not accessible yet.
const QString filePath() const
Returns the path to the local file, an empty string if the file is not accessible yet.
ContentStatus
Status of fetched content.
@ Finished
Download finished and successful.
@ NotStarted
No download started for such URL.
@ Downloading
Currently downloading.
void fetched()
Emitted when the file is fetched and accessible.
QgsFetchedContent(const QString &url, QTemporaryFile *file=nullptr, ContentStatus status=NotStarted)
Constructs a FetchedContent with pointer to the downloaded file and status of the download.
Registry for temporary fetched files.
FetchingMode
Enum to determine when the download should start.
@ DownloadLater
Do not start immediately the download to properly connect the fetched signal.
@ DownloadImmediately
The download will start immediately, not need to run QgsFecthedContent::download()
Handles HTTP network content fetching in a background task.