2018-04-27 08:33:28 -04:00
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/core/qgsnetworkcontentfetcherregistry.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QgsFetchedContent : QObject
|
|
|
|
{
|
|
|
|
%Docstring
|
|
|
|
FetchedContent holds useful information about a network content being fetched
|
|
|
|
|
|
|
|
.. seealso:: :py:class:`QgsNetworkContentFetcherRegistry`
|
|
|
|
|
|
|
|
.. versionadded:: 3.2
|
|
|
|
%End
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsnetworkcontentfetcherregistry.h"
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
enum ContentStatus
|
|
|
|
{
|
|
|
|
NotStarted,
|
|
|
|
Downloading,
|
|
|
|
Finished,
|
|
|
|
Failed
|
|
|
|
};
|
|
|
|
|
|
|
|
explicit QgsFetchedContent( QTemporaryFile *file = 0, ContentStatus status = NotStarted );
|
|
|
|
%Docstring
|
|
|
|
Constructs a FetchedContent with pointer to the downloaded file and status of the download
|
|
|
|
%End
|
|
|
|
|
|
|
|
|
|
|
|
const QString filePath() const;
|
|
|
|
%Docstring
|
|
|
|
Return the path to the local file, an empty string if the file is not accessible yet.
|
|
|
|
%End
|
|
|
|
|
|
|
|
ContentStatus status() const;
|
|
|
|
%Docstring
|
|
|
|
Return the status of the download
|
|
|
|
%End
|
|
|
|
|
|
|
|
QNetworkReply::NetworkError error() const;
|
|
|
|
%Docstring
|
|
|
|
Return the potential error of the download
|
|
|
|
%End
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void download( bool redownload = false );
|
|
|
|
%Docstring
|
|
|
|
Start the download
|
|
|
|
|
|
|
|
:param redownload: if set to true, it will restart any achieved or pending download.
|
|
|
|
%End
|
|
|
|
|
2018-04-29 21:02:43 -04:00
|
|
|
void cancel();
|
|
|
|
%Docstring
|
|
|
|
Cancel the download operation
|
|
|
|
%End
|
|
|
|
|
2018-04-27 08:33:28 -04:00
|
|
|
signals:
|
|
|
|
void fetched();
|
|
|
|
%Docstring
|
2018-04-29 21:02:43 -04:00
|
|
|
Emitted when the file is fetched and accessible
|
2018-04-27 08:33:28 -04:00
|
|
|
%End
|
|
|
|
|
|
|
|
void downloadStarted( const bool redownload );
|
|
|
|
%Docstring
|
2018-04-29 21:02:43 -04:00
|
|
|
Emitted when the download actually starts
|
|
|
|
%End
|
|
|
|
|
|
|
|
void cancelTriggered();
|
|
|
|
%Docstring
|
|
|
|
Emitted when download is canceled.
|
2018-04-27 08:33:28 -04:00
|
|
|
%End
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class QgsNetworkContentFetcherRegistry : QObject
|
|
|
|
{
|
|
|
|
%Docstring
|
|
|
|
Registry for temporary fetched files
|
|
|
|
|
|
|
|
This provides a simple way of downloading and accessing
|
|
|
|
remote files during QGIS application running.
|
|
|
|
|
|
|
|
.. seealso:: :py:class:`QgsFetchedContent`
|
|
|
|
|
|
|
|
.. versionadded:: 3.2
|
|
|
|
%End
|
|
|
|
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsnetworkcontentfetcherregistry.h"
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
enum FetchingMode
|
|
|
|
{
|
|
|
|
DownloadLater,
|
|
|
|
DownloadImmediately,
|
|
|
|
};
|
|
|
|
|
|
|
|
explicit QgsNetworkContentFetcherRegistry();
|
|
|
|
%Docstring
|
|
|
|
Create the registry for temporary downloaded files
|
|
|
|
%End
|
|
|
|
|
|
|
|
~QgsNetworkContentFetcherRegistry();
|
|
|
|
|
|
|
|
const QgsFetchedContent *fetch( const QUrl &url, const FetchingMode &fetchingMode = DownloadLater );
|
|
|
|
%Docstring
|
|
|
|
Initialize a download for the given URL
|
|
|
|
|
|
|
|
:param url: the URL to be fetched
|
|
|
|
:param fetchingMode: defines if the download will start immediately or shall be manually triggered
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
If the download starts immediately, it will not redownload any already fetched or currently fetching file.
|
|
|
|
%End
|
|
|
|
|
2018-04-27 14:45:24 -04:00
|
|
|
QString localPath( const QString &filePathOrUrl );
|
|
|
|
|
2018-04-27 08:33:28 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/core/qgsnetworkcontentfetcherregistry.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|