Skip to content

Commit

Permalink
Expose contentAsString to QgsNetworkContentFetcherTask
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 1, 2019
1 parent bb9fb49 commit b0d7c29
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
17 changes: 17 additions & 0 deletions python/core/auto_generated/qgsnetworkcontentfetchertask.sip.in
Expand Up @@ -62,6 +62,23 @@ Optionally, authentication configuration can be set via the ``authcfg`` argument
Returns the network reply. Ownership is not transferred.

May return ``None`` if the request has not yet completed.

.. warning::

This should only be accessed from a slot connected directly to
the QgsNetworkContentFetcherTask.fetched() signal.
%End

QString contentAsString() const;
%Docstring
Returns the fetched content as a string

.. warning::

This should only be accessed from a slot connected directly to
the QgsNetworkContentFetcherTask.fetched() signal.

.. versionadded:: 3.10
%End

signals:
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsnetworkcontentfetchertask.cpp
Expand Up @@ -73,3 +73,8 @@ QNetworkReply *QgsNetworkContentFetcherTask::reply()
{
return mFetcher ? mFetcher->reply() : nullptr;
}

QString QgsNetworkContentFetcherTask::contentAsString() const
{
return mFetcher ? mFetcher->contentAsString() : QString();
}
13 changes: 13 additions & 0 deletions src/core/qgsnetworkcontentfetchertask.h
Expand Up @@ -75,9 +75,22 @@ class CORE_EXPORT QgsNetworkContentFetcherTask : public QgsTask
* Returns the network reply. Ownership is not transferred.
*
* May return NULLPTR if the request has not yet completed.
*
* \warning This should only be accessed from a slot connected directly to
* the QgsNetworkContentFetcherTask::fetched() signal.
*/
QNetworkReply *reply();

/**
* Returns the fetched content as a string
*
* \warning This should only be accessed from a slot connected directly to
* the QgsNetworkContentFetcherTask::fetched() signal.
*
* \since QGIS 3.10
*/
QString contentAsString() const;

signals:

/**
Expand Down

0 comments on commit b0d7c29

Please sign in to comment.