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
Pick-to: 6.5
Change-Id: If2fa40cac0e51a243054526d7d2997fdd54aea3e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
This commit is contained in:
Edward Welbourne 2023-05-05 18:10:38 +02:00
parent fe2af0f8a3
commit 3c78f1e96e
2 changed files with 3 additions and 3 deletions

View File

@ -76,7 +76,7 @@ void RSSListing::get(const QUrl &url)
} }
currentReply = url.isValid() ? manager.get(QNetworkRequest(url)) : nullptr; currentReply = url.isValid() ? manager.get(QNetworkRequest(url)) : nullptr;
if (currentReply) { if (currentReply) {
connect(currentReply, &QNetworkReply::readyRead, this, &RSSListing::readyRead); connect(currentReply, &QNetworkReply::readyRead, this, &RSSListing::consumeData);
connect(currentReply, &QNetworkReply::errorOccurred, this, &RSSListing::error); connect(currentReply, &QNetworkReply::errorOccurred, this, &RSSListing::error);
} }
xml.setDevice(currentReply); // Equivalent to clear() if currentReply is null. xml.setDevice(currentReply); // Equivalent to clear() if currentReply is null.
@ -112,7 +112,7 @@ void RSSListing::fetch()
stream reader. Then we call the XML parsing function. stream reader. Then we call the XML parsing function.
*/ */
void RSSListing::readyRead() void RSSListing::consumeData()
{ {
int statusCode = currentReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); int statusCode = currentReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (statusCode >= 200 && statusCode < 300) if (statusCode >= 200 && statusCode < 300)

View File

@ -26,7 +26,7 @@ public:
public slots: public slots:
void fetch(); void fetch();
void finished(QNetworkReply *reply); void finished(QNetworkReply *reply);
void readyRead(); void consumeData();
void error(QNetworkReply::NetworkError); void error(QNetworkReply::NetworkError);
private: private: