QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsnetworkcontentfetchertask.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsnetworkcontentfetchertask.h
3 -------------------
4 begin : March, 2018
5 copyright : (C) 2018 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7
8 ***************************************************************************/
9
10/***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 ***************************************************************************/
18
19
20#ifndef QGSNETWORKCONTENTFETCHERTASK_H
21#define QGSNETWORKCONTENTFETCHERTASK_H
22
23#include "qgis_core.h"
24#include "qgstaskmanager.h"
25
26#include <QNetworkReply>
27#include <QNetworkRequest>
28
30
48class CORE_EXPORT QgsNetworkContentFetcherTask : public QgsTask
49{
50 Q_OBJECT
51
52 public:
53
62 QgsNetworkContentFetcherTask( const QUrl &url, const QString &authcfg = QString(), QgsTask::Flags flags = QgsTask::CanCancel,
63 const QString &description = QString() );
64
73 QgsNetworkContentFetcherTask( const QNetworkRequest &request, const QString &authcfg = QString(), QgsTask::Flags flags = QgsTask::CanCancel,
74 const QString &description = QString() );
75
77
78 bool run() override;
79 void cancel() override;
80
89 QNetworkReply *reply();
90
96 QString contentDispositionFilename() const;
97
106 QString contentAsString() const;
107
108 signals:
109
118 void fetched();
119
125 void errorOccurred( QNetworkReply::NetworkError code, const QString &errorMsg );
126
127 private:
128
129 QNetworkRequest mRequest;
130 QString mAuthcfg;
131 QgsNetworkContentFetcher *mFetcher = nullptr;
132 QString mMode;
133};
134
135#endif //QGSNETWORKCONTENTFETCHERTASK_H
QString contentAsString() const
Returns the fetched content as a string.
QString contentDispositionFilename() const
Returns the associated filename from the reply's content disposition header, if present.
void fetched()
Emitted when the network content has been fetched, regardless of whether the fetch was successful or ...
QNetworkReply * reply()
Returns the network reply.
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...
QgsNetworkContentFetcherTask(const QUrl &url, const QString &authcfg=QString(), QgsTask::Flags flags=QgsTask::CanCancel, const QString &description=QString())
Constructor for a QgsNetworkContentFetcherTask which fetches the specified url.
HTTP network content fetcher.
Flags flags() const
Returns the flags associated with the task.
virtual bool run()=0
Performs the task's operation.
QFlags< Flag > Flags
virtual void cancel()
Notifies the task that it should terminate.
QgsTask(const QString &description=QString(), QgsTask::Flags flags=AllFlags)
Constructor for QgsTask.
@ CanCancel
Task can be canceled.
QString description() const
Returns the task's description.