Commit 7e069403 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent a2c5187f
Pipeline #40021 canceled with stage
......@@ -36,10 +36,10 @@ ConfigureCustomSettingDialogTest::~ConfigureCustomSettingDialogTest()
void ConfigureCustomSettingDialogTest::shouldHaveDefaultValue()
{
ConfigureCustomSettingDialog dlg;
QDialogButtonBox *buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
auto *buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
QVERIFY(buttonBox);
QVERIFY(!buttonBox->button(QDialogButtonBox::Ok)->isEnabled());
ConfigureCustomSettingWidget *widget = dlg.findChild<ConfigureCustomSettingWidget *>(QStringLiteral("customsettingwidget"));
auto *widget = dlg.findChild<ConfigureCustomSettingWidget *>(QStringLiteral("customsettingwidget"));
QVERIFY(widget);
}
......
......@@ -39,20 +39,20 @@ ConfigureCustomSettingWidgetTest::~ConfigureCustomSettingWidgetTest()
void ConfigureCustomSettingWidgetTest::shouldHaveDefaultValue()
{
ConfigureCustomSettingWidget w;
QLabel *lab = w.findChild<QLabel *>(QStringLiteral("category_label"));
auto *lab = w.findChild<QLabel *>(QStringLiteral("category_label"));
QVERIFY(lab);
KLineEdit *categoryLineEdit = w.findChild<KLineEdit *>(QStringLiteral("category_lineedit"));
auto *categoryLineEdit = w.findChild<KLineEdit *>(QStringLiteral("category_lineedit"));
QVERIFY(categoryLineEdit);
QVERIFY(categoryLineEdit->trapReturnKey());
QVERIFY(categoryLineEdit->isClearButtonEnabled());
QCheckBox *enableCategory = w.findChild<QCheckBox *>(QStringLiteral("enable_category"));
auto *enableCategory = w.findChild<QCheckBox *>(QStringLiteral("enable_category"));
QVERIFY(enableCategory);
lab = w.findChild<QLabel *>(QStringLiteral("categorytype_label"));
QVERIFY(lab);
QComboBox *categoryType = w.findChild<QComboBox *>(QStringLiteral("categorytype_combobox"));
auto *categoryType = w.findChild<QComboBox *>(QStringLiteral("categorytype_combobox"));
QVERIFY(categoryType);
QCOMPARE(categoryType->count(), 4);
}
......@@ -79,7 +79,7 @@ void ConfigureCustomSettingWidgetTest::shouldRestoreRules()
void ConfigureCustomSettingWidgetTest::shouldEmitSignalWhenWeChangeLogName()
{
ConfigureCustomSettingWidget w;
KLineEdit *categoryLineEdit = w.findChild<KLineEdit *>(QStringLiteral("category_lineedit"));
auto *categoryLineEdit = w.findChild<KLineEdit *>(QStringLiteral("category_lineedit"));
QVERIFY(categoryLineEdit);
QSignalSpy spy(&w, &ConfigureCustomSettingWidget::enableButton);
categoryLineEdit->setText(QStringLiteral("bla"));
......
......@@ -39,28 +39,28 @@ void CustomDebugSettingsPageTest::shouldHaveDefaultValue()
{
CustomDebugSettingsPage page;
QLabel *lab = page.findChild<QLabel *>(QStringLiteral("custom_label"));
auto *lab = page.findChild<QLabel *>(QStringLiteral("custom_label"));
QVERIFY(lab);
QListWidget *listWidget = page.findChild<QListWidget *>(QStringLiteral("custom_listwidget"));
auto *listWidget = page.findChild<QListWidget *>(QStringLiteral("custom_listwidget"));
QVERIFY(listWidget);
QCOMPARE(listWidget->selectionMode(), QAbstractItemView::MultiSelection);
QCOMPARE(listWidget->count(), 0);
KListWidgetSearchLine *searchLine = page.findChild<KListWidgetSearchLine *>(QStringLiteral("searchline"));
auto *searchLine = page.findChild<KListWidgetSearchLine *>(QStringLiteral("searchline"));
QVERIFY(searchLine);
QVERIFY(!searchLine->placeholderText().isEmpty());
QCOMPARE(searchLine->listWidget(), listWidget);
QPushButton *addButton = page.findChild<QPushButton *>(QStringLiteral("add_rule"));
auto *addButton = page.findChild<QPushButton *>(QStringLiteral("add_rule"));
QVERIFY(addButton);
QVERIFY(addButton->isEnabled());
QPushButton *editButton = page.findChild<QPushButton *>(QStringLiteral("edit_rule"));
auto *editButton = page.findChild<QPushButton *>(QStringLiteral("edit_rule"));
QVERIFY(editButton);
QVERIFY(!editButton->isEnabled());
QPushButton *removeButton = page.findChild<QPushButton *>(QStringLiteral("remove_rule"));
auto *removeButton = page.findChild<QPushButton *>(QStringLiteral("remove_rule"));
QVERIFY(removeButton);
QVERIFY(!removeButton->isEnabled());
}
......
......@@ -36,9 +36,9 @@ void EnvironmentSettingsRulesPageTest::shouldHaveDefaultValue()
{
EnvironmentSettingsRulesPage w;
QLabel *lab = w.findChild<QLabel *>(QStringLiteral("label"));
auto *lab = w.findChild<QLabel *>(QStringLiteral("label"));
QVERIFY(lab);
EnvironmentPlainTextEdit *plainText = w.findChild<EnvironmentPlainTextEdit *>(QStringLiteral("richtext"));
auto *plainText = w.findChild<EnvironmentPlainTextEdit *>(QStringLiteral("richtext"));
QVERIFY(plainText);
QVERIFY(plainText->toPlainText().isEmpty());
QVERIFY(plainText->isReadOnly());
......@@ -47,7 +47,7 @@ void EnvironmentSettingsRulesPageTest::shouldHaveDefaultValue()
void EnvironmentSettingsRulesPageTest::shouldSetRules()
{
EnvironmentSettingsRulesPage w;
EnvironmentPlainTextEdit *plainText = w.findChild<EnvironmentPlainTextEdit *>(QStringLiteral("richtext"));
auto *plainText = w.findChild<EnvironmentPlainTextEdit *>(QStringLiteral("richtext"));
QString rules = QStringLiteral("Rules for qt\ntest");
w.setRules(rules);
QVERIFY(plainText->toPlainText().endsWith(rules));
......
......@@ -38,26 +38,26 @@ KDEApplicationDebugSettingPageTest::~KDEApplicationDebugSettingPageTest()
void KDEApplicationDebugSettingPageTest::shouldHaveDefaultValue()
{
KDEApplicationDebugSettingPage page;
KDEApplicationTreeListWidget *listWidget = page.findChild<KDEApplicationTreeListWidget *>(QStringLiteral("listwidget"));
auto *listWidget = page.findChild<KDEApplicationTreeListWidget *>(QStringLiteral("listwidget"));
QVERIFY(listWidget);
QVERIFY(!listWidget->rootIsDecorated());
QVERIFY(listWidget->header()->isHidden());
QVERIFY(listWidget->isColumnHidden(2));
QCOMPARE(listWidget->columnCount(), 4);
QPushButton *selectAll = page.findChild<QPushButton *>(QStringLiteral("selectall"));
auto *selectAll = page.findChild<QPushButton *>(QStringLiteral("selectall"));
QVERIFY(selectAll);
QVERIFY(selectAll->isEnabled());
QPushButton *deselectAll = page.findChild<QPushButton *>(QStringLiteral("deselectall"));
auto *deselectAll = page.findChild<QPushButton *>(QStringLiteral("deselectall"));
QVERIFY(deselectAll);
QVERIFY(deselectAll->isEnabled());
QPushButton *mTurnOffAllMessages = page.findChild<QPushButton *>(QStringLiteral("deselectallmessage"));
auto *mTurnOffAllMessages = page.findChild<QPushButton *>(QStringLiteral("deselectallmessage"));
QVERIFY(mTurnOffAllMessages);
QVERIFY(mTurnOffAllMessages->isEnabled());
KTreeWidgetSearchLine *searchLine = page.findChild<KTreeWidgetSearchLine *>(QStringLiteral("searchline"));
auto *searchLine = page.findChild<KTreeWidgetSearchLine *>(QStringLiteral("searchline"));
QVERIFY(searchLine);
QVERIFY(searchLine->text().isEmpty());
}
......
......@@ -40,10 +40,10 @@ KDebugSettingsDialogTest::~KDebugSettingsDialogTest()
void KDebugSettingsDialogTest::shouldHaveDefaultValue()
{
KDebugSettingsDialog dlg;
QDialogButtonBox *buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
auto *buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
QVERIFY(buttonBox);
QCOMPARE(buttonBox->standardButtons(), QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Apply);
QTabWidget *tab = dlg.findChild<QTabWidget *>(QStringLiteral("tabwidget"));
auto *tab = dlg.findChild<QTabWidget *>(QStringLiteral("tabwidget"));
QVERIFY(tab);
for (int i = 0; i < tab->count(); ++i) {
const QString objName = tab->widget(i)->objectName();
......@@ -52,13 +52,13 @@ void KDebugSettingsDialogTest::shouldHaveDefaultValue()
|| (objName == QLatin1String("environmentsettingsrulespage"));
QVERIFY(hasCorrectName);
}
QPushButton *saveAs = buttonBox->findChild<QPushButton *>(QStringLiteral("saveas_button"));
auto *saveAs = buttonBox->findChild<QPushButton *>(QStringLiteral("saveas_button"));
QVERIFY(saveAs);
QPushButton *load = buttonBox->findChild<QPushButton *>(QStringLiteral("load_button"));
auto *load = buttonBox->findChild<QPushButton *>(QStringLiteral("load_button"));
QVERIFY(load);
QPushButton *insertCategories = buttonBox->findChild<QPushButton *>(QStringLiteral("insert_button"));
auto *insertCategories = buttonBox->findChild<QPushButton *>(QStringLiteral("insert_button"));
QVERIFY(insertCategories);
CategoryWarning *categoryWarning = dlg.findChild<CategoryWarning *>(QStringLiteral("categorywarning"));
auto *categoryWarning = dlg.findChild<CategoryWarning *>(QStringLiteral("categorywarning"));
QVERIFY(categoryWarning);
QVERIFY(!categoryWarning->isVisible());
}
......
......@@ -29,7 +29,7 @@
ConfigureCustomSettingDialog::ConfigureCustomSettingDialog(QWidget *parent)
: QDialog(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
setWindowTitle(i18nc("@title:window", "Add custom rule"));
mCustomSettingWidget = new ConfigureCustomSettingWidget(this);
......
......@@ -32,7 +32,7 @@
ConfigureCustomSettingWidget::ConfigureCustomSettingWidget(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *vbox = new QVBoxLayout(this);
auto *vbox = new QVBoxLayout(this);
QLabel *lab = new QLabel(i18n("Category:"), this);
lab->setObjectName(QStringLiteral("category_label"));
......@@ -41,7 +41,7 @@ ConfigureCustomSettingWidget::ConfigureCustomSettingWidget(QWidget *parent)
mCategoryLineEdit->setClearButtonEnabled(true);
mCategoryLineEdit->setObjectName(QStringLiteral("category_lineedit"));
connect(mCategoryLineEdit, &KLineEdit::textChanged, this, &ConfigureCustomSettingWidget::slotTextChanged);
QHBoxLayout *categoryLayout = new QHBoxLayout;
auto *categoryLayout = new QHBoxLayout;
vbox->addLayout(categoryLayout);
categoryLayout->addWidget(lab);
categoryLayout->addWidget(mCategoryLineEdit);
......
......@@ -34,17 +34,17 @@
CustomDebugSettingsPage::CustomDebugSettingsPage(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
QLabel *lab = new QLabel(i18n("Rules:"), this);
lab->setObjectName(QStringLiteral("custom_label"));
mainLayout->addWidget(lab);
QHBoxLayout *horizontalLayout = new QHBoxLayout;
auto *horizontalLayout = new QHBoxLayout;
horizontalLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addLayout(horizontalLayout);
QVBoxLayout *vbox = new QVBoxLayout;
auto *vbox = new QVBoxLayout;
horizontalLayout->addLayout(vbox);
mListWidget = new QListWidget(this);
......@@ -52,13 +52,13 @@ CustomDebugSettingsPage::CustomDebugSettingsPage(QWidget *parent)
mListWidget->setSelectionMode(QAbstractItemView::MultiSelection);
connect(mListWidget, &QListWidget::itemSelectionChanged, this, &CustomDebugSettingsPage::updateButtons);
connect(mListWidget, &QListWidget::itemDoubleClicked, this, &CustomDebugSettingsPage::slotEditRule);
KListWidgetSearchLine *searchLine = new KListWidgetSearchLine(this, mListWidget);
auto *searchLine = new KListWidgetSearchLine(this, mListWidget);
searchLine->setObjectName(QStringLiteral("searchline"));
searchLine->setPlaceholderText(i18n("Search..."));
vbox->addWidget(searchLine);
vbox->addWidget(mListWidget);
QVBoxLayout *buttonLayout = new QVBoxLayout;
auto *buttonLayout = new QVBoxLayout;
horizontalLayout->addLayout(buttonLayout);
mAddRule = new QPushButton(i18n("Add..."), this);
......
......@@ -27,7 +27,7 @@
EnvironmentSettingsRulesPage::EnvironmentSettingsRulesPage(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
QLabel *lab = new QLabel(i18n("Rules:"), this);
lab->setObjectName(QStringLiteral("label"));
mRichTextEdit = new EnvironmentPlainTextEdit(this);
......
......@@ -30,7 +30,7 @@
KDEApplicationDebugSettingPage::KDEApplicationDebugSettingPage(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
mTreeListWidget = new KDEApplicationTreeListWidget(this);
mTreeListWidget->setObjectName(QStringLiteral("listwidget"));
......@@ -43,7 +43,7 @@ KDEApplicationDebugSettingPage::KDEApplicationDebugSettingPage(QWidget *parent)
mainLayout->addWidget(mTreeListWidget);
QHBoxLayout *buttonLayout = new QHBoxLayout;
auto *buttonLayout = new QHBoxLayout;
mainLayout->addLayout(buttonLayout);
mEnableDebug = new QPushButton(i18n("Enable All Debug"), this);
......@@ -76,7 +76,7 @@ void KDEApplicationDebugSettingPage::forceFocus()
bool KDEApplicationDebugSettingPage::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::KeyPress && obj == mTreeListWidgetSearchLine) {
QKeyEvent *key = static_cast<QKeyEvent *>(event);
auto *key = static_cast<QKeyEvent *>(event);
if ((key->key() == Qt::Key_Enter) || (key->key() == Qt::Key_Return)) {
event->accept();
return true;
......
......@@ -94,7 +94,7 @@ QList<int> KDEApplicationTreeListWidget::searchColumns() const
void KDEApplicationTreeListWidget::selectAllDebugCategories()
{
for (int i = 0; i < topLevelItemCount(); ++i) {
KDEApplicationTreeListWidgetItem *itemWidget = static_cast<KDEApplicationTreeListWidgetItem *>(topLevelItem(i));
auto *itemWidget = static_cast<KDEApplicationTreeListWidgetItem *>(topLevelItem(i));
if (!itemWidget->isHidden()) {
itemWidget->setType(LoggingCategory::Debug);
}
......@@ -104,7 +104,7 @@ void KDEApplicationTreeListWidget::selectAllDebugCategories()
void KDEApplicationTreeListWidget::deSelectAllDebugCategories()
{
for (int i = 0; i < topLevelItemCount(); ++i) {
KDEApplicationTreeListWidgetItem *itemWidget = static_cast<KDEApplicationTreeListWidgetItem *>(topLevelItem(i));
auto *itemWidget = static_cast<KDEApplicationTreeListWidgetItem *>(topLevelItem(i));
if (!itemWidget->isHidden()) {
itemWidget->setType(LoggingCategory::Info);
}
......@@ -114,7 +114,7 @@ void KDEApplicationTreeListWidget::deSelectAllDebugCategories()
void KDEApplicationTreeListWidget::deSelectAllMessagesCategories()
{
for (int i = 0; i < topLevelItemCount(); ++i) {
KDEApplicationTreeListWidgetItem *itemWidget = static_cast<KDEApplicationTreeListWidgetItem *>(topLevelItem(i));
auto *itemWidget = static_cast<KDEApplicationTreeListWidgetItem *>(topLevelItem(i));
if (!itemWidget->isHidden()) {
itemWidget->setType(LoggingCategory::Off);
}
......@@ -142,7 +142,7 @@ void KDEApplicationTreeListWidget::addListItems(const LoggingCategory::List &lis
clear();
}
for (const LoggingCategory &cat : list) {
KDEApplicationTreeListWidgetItem *item = new KDEApplicationTreeListWidgetItem(cat.categoryName, this);
auto *item = new KDEApplicationTreeListWidgetItem(cat.categoryName, this);
item->setToolTip(0, generateToolTip(cat));
item->setText(KDEApplicationTreeListWidgetItem::Description, cat.description);
item->setType(cat.loggingType);
......@@ -162,7 +162,7 @@ LoggingCategory::List KDEApplicationTreeListWidget::rules(bool forceSavingAllRul
{
LoggingCategory::List lst;
for (int i = 0; i < topLevelItemCount(); ++i) {
KDEApplicationTreeListWidgetItem *listWidgetItem = static_cast<KDEApplicationTreeListWidgetItem *>(topLevelItem(i));
auto *listWidgetItem = static_cast<KDEApplicationTreeListWidgetItem *>(topLevelItem(i));
const LoggingCategory cat = listWidgetItem->rule(forceSavingAllRules);
if (cat.isValid()) {
lst.append(cat);
......@@ -174,7 +174,7 @@ LoggingCategory::List KDEApplicationTreeListWidget::rules(bool forceSavingAllRul
void KDEApplicationTreeListWidget::restoreToDefault()
{
for (int i = 0; i < topLevelItemCount(); ++i) {
KDEApplicationTreeListWidgetItem *itemWidget = static_cast<KDEApplicationTreeListWidgetItem *>(topLevelItem(i));
auto *itemWidget = static_cast<KDEApplicationTreeListWidgetItem *>(topLevelItem(i));
itemWidget->restoreToDefault();
}
}
......@@ -48,7 +48,7 @@ constexpr char KDebugSettingsDialogGroupName[] = "KDebugSettingsDialog";
KDebugSettingsDialog::KDebugSettingsDialog(QWidget *parent)
: QDialog(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
mCategoryWarning = new CategoryWarning(this);
mCategoryWarning->setObjectName(QStringLiteral("categorywarning"));
......
......@@ -86,7 +86,7 @@ struct LIBKDEBUGSETTINGS_EXPORT_TEST_EXPORT LoadLoggingCategory {
}
}
typedef QVector<LoadLoggingCategory> List;
using List = QVector<LoadLoggingCategory>;
bool isValid() const
{
......
......@@ -28,7 +28,7 @@
struct LIBKDEBUGSETTINGS_EXPORT_TEST_EXPORT KdeLoggingCategory {
KdeLoggingCategory();
typedef QVector<KdeLoggingCategory> List;
using List = QVector<KdeLoggingCategory>;
Q_REQUIRED_RESULT bool operator ==(const KdeLoggingCategory &other) const;
Q_REQUIRED_RESULT bool operator !=(const KdeLoggingCategory &other) const;
Q_REQUIRED_RESULT bool isValid() const;
......
......@@ -46,7 +46,7 @@ struct LIBKDEBUGSETTINGS_EXPORT LoggingCategory {
{
}
typedef QVector<LoggingCategory> List;
using List = QVector<LoggingCategory>;
Q_REQUIRED_RESULT bool operator ==(const LoggingCategory &other) const;
Q_REQUIRED_RESULT bool isValid() const;
......
......@@ -99,7 +99,7 @@ int main(int argc, char **argv)
return 1;
} else {
KDBusService service(KDBusService::Unique);
KDebugSettingsDialog *dialog = new KDebugSettingsDialog;
auto *dialog = new KDebugSettingsDialog;
const int ret = dialog->exec();
delete dialog;
return ret;
......
......@@ -31,7 +31,7 @@ public:
{
}
typedef QVector<RenameCategory> List;
using List = QVector<RenameCategory>;
Q_REQUIRED_RESULT bool operator ==(const RenameCategory &other) const;
Q_REQUIRED_RESULT bool isValid() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment