QGIS API Documentation 3.39.0-Master (3aed037ce22)
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
38class CORE_EXPORT QgsNetworkContentFetcher : public QObject
39{
40 Q_OBJECT
41
42 public:
43
45
47
54 void fetchContent( const QUrl &url, const QString &authcfg = QString() );
55
64 void fetchContent( const QNetworkRequest &request, const QString &authcfg = QString() );
65
70 QNetworkReply *reply();
71
77 QString contentDispositionFilename() const;
78
83 QString contentAsString() const;
84
89 void cancel();
90
96 bool wasCanceled() const;
97
98 signals:
99
103 void finished();
104
109 void downloadProgress( qint64 bytesReceived, qint64 bytesTotal );
110
116 void errorOccurred( QNetworkReply::NetworkError code, const QString &errorMsg );
117
118 private:
119
120 QString mAuthCfg;
121 QNetworkReply *mReply = nullptr;
122
123 bool mContentLoaded = false;
124
125 bool mIsCanceled = false;
126
132 QTextCodec *codecForHtml( QByteArray &array ) const;
133
134 private slots:
135
140 void contentLoaded( bool ok = true );
141
142};
143
144#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.