rsslisting example: shuffle parts of constructor for clarity

Group related things together, improve the logical flow of the code.

Task-number: QTBUG-111228
Change-Id: If3eb577b74128b305ca5fb3074168280ec2d4db8
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit fb2d4074c18b0a47ee5b65e3145124f92d9fe1df)
This commit is contained in:
Edward Welbourne 2023-05-05 18:20:55 +02:00
parent 655e6d10da
commit 1d5c003e0e

View File

@ -35,11 +35,14 @@ its operation, and also allows very large data sources to be read.
RSSListing::RSSListing(const QString &url, QWidget *parent) RSSListing::RSSListing(const QString &url, QWidget *parent)
: QWidget(parent), currentReply(0) : QWidget(parent), currentReply(0)
{ {
connect(&manager, &QNetworkAccessManager::finished, this, &RSSListing::finished);
lineEdit = new QLineEdit(this); lineEdit = new QLineEdit(this);
lineEdit->setText(url); lineEdit->setText(url);
connect(lineEdit, &QLineEdit::returnPressed, this, &RSSListing::fetch);
fetchButton = new QPushButton(tr("Fetch"), this); fetchButton = new QPushButton(tr("Fetch"), this);
connect(fetchButton, &QPushButton::clicked, this, &RSSListing::fetch);
treeWidget = new QTreeWidget(this); treeWidget = new QTreeWidget(this);
connect(treeWidget, &QTreeWidget::itemActivated, connect(treeWidget, &QTreeWidget::itemActivated,
@ -49,18 +52,11 @@ RSSListing::RSSListing(const QString &url, QWidget *parent)
treeWidget->setHeaderLabels(headerLabels); treeWidget->setHeaderLabels(headerLabels);
treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents); treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
connect(&manager, &QNetworkAccessManager::finished,
this, &RSSListing::finished);
connect(lineEdit, &QLineEdit::returnPressed, this, &RSSListing::fetch);
connect(fetchButton, &QPushButton::clicked, this, &RSSListing::fetch);
QVBoxLayout *layout = new QVBoxLayout(this);
QHBoxLayout *hboxLayout = new QHBoxLayout; QHBoxLayout *hboxLayout = new QHBoxLayout;
hboxLayout->addWidget(lineEdit); hboxLayout->addWidget(lineEdit);
hboxLayout->addWidget(fetchButton); hboxLayout->addWidget(fetchButton);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addLayout(hboxLayout); layout->addLayout(hboxLayout);
layout->addWidget(treeWidget); layout->addWidget(treeWidget);