QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
network
qgsfiledownloader.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsfiledownloader.h
3
--------------------------------------
4
Date : November 2016
5
Copyright : (C) 2016 by Alessandro Pasotti
6
Email : apasotti at boundlessgeo dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#ifndef QGSFILEDOWNLOADER_H
17
#define QGSFILEDOWNLOADER_H
18
19
#include "
qgis.h
"
20
#include "qgis_core.h"
21
22
#include <QFile>
23
#include <QNetworkReply>
24
#include <QObject>
25
#include <QUrl>
26
27
#ifndef QT_NO_SSL
28
#include <QSslError>
29
#endif
30
45
class
CORE_EXPORT
QgsFileDownloader
:
public
QObject
46
{
47
Q_OBJECT
48
public
:
61
QgsFileDownloader
(
62
const
QUrl &url,
const
QString &outputFileName,
const
QString &authcfg = QString(),
bool
delayStart =
false
,
Qgis::HttpMethod
httpMethod =
Qgis::HttpMethod::Get
,
const
QByteArray &data = QByteArray()
63
);
64
65
signals:
67
void
downloadCompleted
(
const
QUrl &url );
69
void
downloadExited
();
70
75
void
downloadCanceled
();
76
78
void
downloadError
( QStringList errorMessages );
80
void
downloadProgress
( qint64 bytesReceived, qint64 bytesTotal );
81
82
public
slots:
83
89
void
cancelDownload
();
90
92
void
startDownload
();
93
94
private
slots:
96
void
onReadyRead();
98
void
onFinished();
100
void
onDownloadProgress( qint64 bytesReceived, qint64 bytesTotal );
102
void
onRequestTimedOut( QNetworkReply *reply );
103
104
#ifndef QT_NO_SSL
105
111
void
onSslErrors( QNetworkReply *reply,
const
QList<QSslError> &errors );
112
#endif
113
114
protected
:
115
~QgsFileDownloader
()
override
;
116
117
private
:
122
void
error(
const
QStringList &errorMessages );
123
void
error(
const
QString &errorMessage );
124
QUrl mUrl;
125
QNetworkReply *mReply =
nullptr
;
126
QFile mFile;
127
bool
mDownloadCanceled =
false
;
128
Qgis::HttpMethod
mHttpMethod =
Qgis::HttpMethod::Get
;
129
QByteArray mData;
130
QStringList mErrors;
131
QString mAuthCfg;
132
};
133
134
#endif
// QGSFILEDOWNLOADER_H
Qgis::HttpMethod
HttpMethod
Different methods of HTTP requests.
Definition
qgis.h:1138
Qgis::HttpMethod::Get
@ Get
GET method.
Definition
qgis.h:1139
QgsFileDownloader::cancelDownload
void cancelDownload()
Call to abort the download and delete this object after the cancellation has been processed.
Definition
qgsfiledownloader.cpp:116
QgsFileDownloader::downloadExited
void downloadExited()
Emitted always when the downloader exits.
QgsFileDownloader::downloadCanceled
void downloadCanceled()
Emitted when the download was canceled by the user.
QgsFileDownloader::downloadError
void downloadError(QStringList errorMessages)
Emitted when an error makes the download fail.
QgsFileDownloader::startDownload
void startDownload()
Called to start the download.
Definition
qgsfiledownloader.cpp:60
QgsFileDownloader::QgsFileDownloader
QgsFileDownloader(const QUrl &url, const QString &outputFileName, const QString &authcfg=QString(), bool delayStart=false, Qgis::HttpMethod httpMethod=Qgis::HttpMethod::Get, const QByteArray &data=QByteArray())
QgsFileDownloader.
Definition
qgsfiledownloader.cpp:38
QgsFileDownloader::downloadCompleted
void downloadCompleted(const QUrl &url)
Emitted when the download has completed successfully.
QgsFileDownloader::downloadProgress
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
Emitted when data are ready to be processed.
qgis.h
Generated on
for QGIS API Documentation by
1.17.0