29 :
QgsTask( tr(
"Fetching %1" ).arg( request.url().toString() ), flags )
38 mFetcher->deleteLater();
55 const int progress = ( bytesReceived * 100 ) / bytesTotal;
64 bool hasErrorOccurred =
false;
67 hasErrorOccurred =
true;
90 return mFetcher ? mFetcher->
reply() :
nullptr;
Handles HTTP network content fetching in a background task.
bool run() override
Performs the task's operation.
QString contentAsString() const
Returns the fetched content as a string.
void fetched()
Emitted when the network content has been fetched, regardless of whether the fetch was successful or ...
~QgsNetworkContentFetcherTask() override
QNetworkReply * reply()
Returns the network reply.
QgsNetworkContentFetcherTask(const QUrl &url, const QString &authcfg=QString(), QgsTask::Flags flags=QgsTask::CanCancel)
Constructor for a QgsNetworkContentFetcherTask which fetches the specified url.
void cancel() override
Notifies the task that it should terminate.
void errorOccurred(QNetworkReply::NetworkError code, const QString &errorMsg)
Emitted when an error with code error occurred while processing the request errorMsg is a textual des...
HTTP network content fetcher.
void finished()
Emitted when content has loaded.
void errorOccurred(QNetworkReply::NetworkError code, const QString &errorMsg)
Emitted when an error with code error occurred while processing the request errorMsg is a textual des...
void cancel()
Cancels any ongoing request.
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
Emitted when data is received.
QNetworkReply * reply()
Returns a reference to the network reply.
QString contentAsString() const
Returns the fetched content as a string.
void fetchContent(const QUrl &url, const QString &authcfg=QString())
Fetches content from a remote URL and handles redirects.
Abstract base class for long running background tasks.
double progress() const
Returns the task's progress (between 0.0 and 100.0)
virtual void cancel()
Notifies the task that it should terminate.
bool isCanceled() const
Will return true if task should terminate ASAP.
void setProgress(double progress)
Sets the task's current progress.