diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2009-07-14 11:05:11 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2009-07-14 11:33:49 (GMT) |
commit | ec11bd70c78cbdb07b399b058fabdb16d66072b0 (patch) | |
tree | a29b7061a0624df7539750dc2e9183c5068912f1 /src | |
parent | a2bad25383e565233a0c2527e04cef9f6b577f14 (diff) | |
download | Qt-ec11bd70c78cbdb07b399b058fabdb16d66072b0.zip Qt-ec11bd70c78cbdb07b399b058fabdb16d66072b0.tar.gz Qt-ec11bd70c78cbdb07b399b058fabdb16d66072b0.tar.bz2 |
QNetworkReply: Add isFinished() method
The isFinished() method will return true if the reply has successfully
finished or has been aborted.
Task-number: 257349
Reviewed-by: Thiago Macieira
Diffstat (limited to 'src')
-rw-r--r-- | src/network/access/qnetworkreply.cpp | 21 | ||||
-rw-r--r-- | src/network/access/qnetworkreply.h | 2 | ||||
-rw-r--r-- | src/network/access/qnetworkreply_p.h | 2 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyimpl.cpp | 5 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyimpl_p.h | 2 |
5 files changed, 32 insertions, 0 deletions
diff --git a/src/network/access/qnetworkreply.cpp b/src/network/access/qnetworkreply.cpp index 1b0d9f5..e55c202 100644 --- a/src/network/access/qnetworkreply.cpp +++ b/src/network/access/qnetworkreply.cpp @@ -442,6 +442,27 @@ QNetworkReply::NetworkError QNetworkReply::error() const } /*! + Returns true when the reply has finished or was aborted. + + \sa isRunning() +*/ +bool QNetworkReply::isFinished() const +{ + return d_func()->isFinished(); +} + +/*! + Returns true when the request is still processing and the + reply has not finished or was aborted yet. + + \sa isFinished() +*/ +bool QNetworkReply::isRunning() const +{ + return !isFinished(); +} + +/*! Returns the URL of the content downloaded or uploaded. Note that the URL may be different from that of the original request. diff --git a/src/network/access/qnetworkreply.h b/src/network/access/qnetworkreply.h index 7cb082f..30e89f1 100644 --- a/src/network/access/qnetworkreply.h +++ b/src/network/access/qnetworkreply.h @@ -116,6 +116,8 @@ public: QNetworkAccessManager::Operation operation() const; QNetworkRequest request() const; NetworkError error() const; + bool isFinished() const; + bool isRunning() const; QUrl url() const; // "cooked" headers diff --git a/src/network/access/qnetworkreply_p.h b/src/network/access/qnetworkreply_p.h index c8543f0..b51e3fb 100644 --- a/src/network/access/qnetworkreply_p.h +++ b/src/network/access/qnetworkreply_p.h @@ -75,6 +75,8 @@ public: static inline void setManager(QNetworkReply *reply, QNetworkAccessManager *manager) { reply->d_func()->manager = manager; } + virtual bool isFinished() const { return false; } + Q_DECLARE_PUBLIC(QNetworkReply) }; diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index b11d986..55b8b7f 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -532,6 +532,11 @@ void QNetworkReplyImplPrivate::sslErrors(const QList<QSslError> &errors) #endif } +bool QNetworkReplyImplPrivate::isFinished() const +{ + return (state == Finished || state == Aborted); +} + QNetworkReplyImpl::QNetworkReplyImpl(QObject *parent) : QNetworkReply(*new QNetworkReplyImplPrivate, parent) { diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index 3e89a00..454185a 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -152,6 +152,8 @@ public: void redirectionRequested(const QUrl &target); void sslErrors(const QList<QSslError> &errors); + bool isFinished() const; + QNetworkAccessBackend *backend; QIODevice *outgoingData; QRingBuffer *outgoingDataBuffer; |