diff options
author | Simon Rettberg | 2022-10-30 20:34:23 +0100 |
---|---|---|
committer | Simon Rettberg | 2022-10-30 20:34:23 +0100 |
commit | 9f479b8f76238a03bce5d13aee14efd34e659c6e (patch) | |
tree | e320d32838202ac4604032da7a4bc3702cc304da /src/client/informationdialog | |
parent | Update translation files (diff) | |
download | pvs2-9f479b8f76238a03bce5d13aee14efd34e659c6e.tar.gz pvs2-9f479b8f76238a03bce5d13aee14efd34e659c6e.tar.xz pvs2-9f479b8f76238a03bce5d13aee14efd34e659c6e.zip |
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 <QtWidgets> and <QtCore>, but specific includes instead
Diffstat (limited to 'src/client/informationdialog')
-rw-r--r-- | src/client/informationdialog/informationdialog.cpp | 36 | ||||
-rw-r--r-- | src/client/informationdialog/informationdialog.h | 11 |
2 files changed, 25 insertions, 22 deletions
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 <QNetworkInterface> #include <QHostInfo> #include <QDir> #include <QDirIterator> +#include <QLayout> +#include <QFormLayout> +#include <QLabel> InformationDialog::InformationDialog() : QDialog() { /* widgets */ - _lblTitle = new QLabel(tr("<h1>system information</h1>")); - _tableWidget = new QWidget(); + _lblTitle = new QLabel(tr("<h1>system information</h1>"), 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("<b>" + tr("hostname") + "</b>"), new QLabel(QHostInfo::localHostName())); + _tableLayout->addRow(new QLabel("<b>" + tr("hostname") + "</b>", 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("<u><b>" + interface.name() + "</b></u>", new QLabel("")); + _tableLayout->addRow("<u><b>" + interface.name() + "</b></u>", 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 <QDialog> -#include <QLayout> -#include <QFormLayout> -#include <QLabel> -#include <QDebug> -#include <QStringList> +class QLayout; +class QFormLayout; +class QLabel; class InformationDialog : public QDialog { @@ -21,7 +20,7 @@ private: void initTable(); public: - InformationDialog(); + explicit InformationDialog(); }; |