QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgsnetworkcontentfetcher.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsnetworkcontentfetcher.h
3 -------------------
4 begin : July, 2014
5 copyright : (C) 2014 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 QGSNETWORKCONTENTFETCHER_H
21#define QGSNETWORKCONTENTFETCHER_H
22
23#include <QNetworkReply>
24#include <QUrl>
25
26#include "qgis_core.h"
27
28class QTextCodec;
29
39class CORE_EXPORT QgsNetworkContentFetcher : public QObject
40{
41 Q_OBJECT
42
43 public:
44
46
48
55 void fetchContent( const QUrl &url, const QString &authcfg = QString() );
56
65 void fetchContent( const QNetworkRequest &request, const QString &authcfg = QString() );
66
71 QNetworkReply *reply();
72
78 QString contentDispositionFilename() const;
79
84 QString contentAsString() const;
85
90 void cancel();
91
97 bool wasCanceled() const;
98
99 signals:
100
104 void finished();
105
110 void downloadProgress( qint64 bytesReceived, qint64 bytesTotal );
111
117 void errorOccurred( QNetworkReply::NetworkError code, const QString &errorMsg );
118
119 private:
120
121 QString mAuthCfg;
122 QNetworkReply *mReply = nullptr;
123
124 bool mContentLoaded = false;
125
126 bool mIsCanceled = false;
127
133 QTextCodec *codecForHtml( QByteArray &array ) const;
134
135 private slots:
136
141 void contentLoaded( bool ok = true );
142
143};
144
145#endif
HTTP network content fetcher.
QgsNetworkContentFetcher()=default
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 downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
Emitted when data is received.