rsslisting example: rename a slot to reflect what it does
Many slots can be connected to one signal so, unlike a virtual method that must be named for the situation in which it is called, a slot can (so should) be named for what it does, rather than naming it to match the signal it's connected to. Task-number: QTBUG-111228 Change-Id: If2fa40cac0e51a243054526d7d2997fdd54aea3e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> (cherry picked from commit 3c78f1e96e17f5becb6830ea473c1ed16ac261ea)
This commit is contained in:
parent
dd48f643b6
commit
80c2b227f0
@ -74,7 +74,7 @@ void RSSListing::get(const QUrl &url)
|
||||
}
|
||||
currentReply = url.isValid() ? manager.get(QNetworkRequest(url)) : nullptr;
|
||||
if (currentReply) {
|
||||
connect(currentReply, &QNetworkReply::readyRead, this, &RSSListing::readyRead);
|
||||
connect(currentReply, &QNetworkReply::readyRead, this, &RSSListing::consumeData);
|
||||
connect(currentReply, &QNetworkReply::errorOccurred, this, &RSSListing::error);
|
||||
}
|
||||
xml.setDevice(currentReply); // Equivalent to clear() if currentReply is null.
|
||||
@ -110,7 +110,7 @@ void RSSListing::fetch()
|
||||
stream reader. Then we call the XML parsing function.
|
||||
*/
|
||||
|
||||
void RSSListing::readyRead()
|
||||
void RSSListing::consumeData()
|
||||
{
|
||||
int statusCode = currentReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
if (statusCode >= 200 && statusCode < 300)
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
public slots:
|
||||
void fetch();
|
||||
void finished(QNetworkReply *reply);
|
||||
void readyRead();
|
||||
void consumeData();
|
||||
void error(QNetworkReply::NetworkError);
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user