From 9f479b8f76238a03bce5d13aee14efd34e659c6e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Sun, 30 Oct 2022 20:34:23 +0100 Subject: Clean up and modernize code - static "new-style" signal->slot connections - Fix a lot of things Clang-Tidy complained about - Move includes to .cpp files and use forward decls in .h - Don't use and , but specific includes instead --- src/client/informationdialog/informationdialog.cpp | 36 ++++++++++++---------- src/client/informationdialog/informationdialog.h | 11 +++---- 2 files changed, 25 insertions(+), 22 deletions(-) (limited to 'src/client/informationdialog') diff --git a/src/client/informationdialog/informationdialog.cpp b/src/client/informationdialog/informationdialog.cpp index fb3e87c..ff96641 100644 --- a/src/client/informationdialog/informationdialog.cpp +++ b/src/client/informationdialog/informationdialog.cpp @@ -1,19 +1,23 @@ #include "informationdialog.h" + #include #include #include #include +#include +#include +#include InformationDialog::InformationDialog() : QDialog() { /* widgets */ - _lblTitle = new QLabel(tr("

system information

")); - _tableWidget = new QWidget(); + _lblTitle = new QLabel(tr("

system information

"), this); + _tableWidget = new QWidget(this); /* layouts */ - _layout = new QVBoxLayout(); - _tableLayout = new QFormLayout(); + _layout = new QVBoxLayout(this); + _tableLayout = new QFormLayout(this); /* */ _tableWidget->setLayout(_tableLayout); @@ -30,11 +34,12 @@ void InformationDialog::initTable() { /* NETWORK*/ /* hostnames */ - _tableLayout->addRow(new QLabel("" + tr("hostname") + ""), new QLabel(QHostInfo::localHostName())); + _tableLayout->addRow(new QLabel("" + tr("hostname") + "", this), + new QLabel(QHostInfo::localHostName(), this)); /* ips */ QStringList interfaceFilter; QString bridgeDevicePath("/sys/devices/virtual/net/"); - QDirIterator it(bridgeDevicePath, QStringList() << "brif", QDir::Dirs, QDirIterator::Subdirectories); + QDirIterator it(bridgeDevicePath, QStringList("brif"), QDir::Dirs, QDirIterator::Subdirectories); while (it.hasNext()) { it.next(); QDir dir = it.filePath(); @@ -42,16 +47,16 @@ void InformationDialog::initTable() interfaceFilter += dir.entryList(); } - for (QNetworkInterface interface : QNetworkInterface::allInterfaces()) { + for (const auto& interface : QNetworkInterface::allInterfaces()) { if (interfaceFilter.contains(interface.name()) || interface.flags().testFlag(QNetworkInterface::IsLoopBack)) { qDebug() << "interface filtered: " << interface.name(); continue; } - _tableLayout->addRow("" + interface.name() + "", new QLabel("")); + _tableLayout->addRow("" + interface.name() + "", new QLabel(this)); - for (QNetworkAddressEntry entry : interface.addressEntries()) { + for (const auto &entry : interface.addressEntries()) { QLabel* label; QLabel* value; QHostAddress hostAddr = entry.ip(); @@ -61,18 +66,17 @@ void InformationDialog::initTable() continue; if (hostAddr.protocol() == QAbstractSocket::IPv6Protocol) { - label = new QLabel("IPv6"); - value = new QLabel(hostAddr.toString().split("%").first()); + label = new QLabel("IPv6", this); + value = new QLabel(hostAddr.toString().split("%").first(), this); } else { - label = new QLabel("IPv4"); - value = new QLabel(hostAddr.toString()); + label = new QLabel("IPv4", this); + value = new QLabel(hostAddr.toString(), this); } _tableLayout->addRow(label, value); } - _tableLayout->addRow("MAC", new QLabel(interface.hardwareAddress())); + _tableLayout->addRow("MAC", new QLabel(interface.hardwareAddress(), this)); } /* TODO: Add other information */ -} - +} \ No newline at end of file diff --git a/src/client/informationdialog/informationdialog.h b/src/client/informationdialog/informationdialog.h index 42aaa7b..f210dd8 100644 --- a/src/client/informationdialog/informationdialog.h +++ b/src/client/informationdialog/informationdialog.h @@ -1,12 +1,11 @@ #ifndef INFORMATION_DIALOG_H #define INFORMATION_DIALOG_H + #include -#include -#include -#include -#include -#include +class QLayout; +class QFormLayout; +class QLabel; class InformationDialog : public QDialog { @@ -21,7 +20,7 @@ private: void initTable(); public: - InformationDialog(); + explicit InformationDialog(); }; -- cgit v1.2.3-55-g7522