Commit 7784b04b authored by Laurent Montel's avatar Laurent Montel 😁

Modernize code (using auto)

parent 99152321
Pipeline #39253 passed with stage
in 12 minutes and 58 seconds
...@@ -35,17 +35,17 @@ SieveEditorConfigureServerPageTest::~SieveEditorConfigureServerPageTest() ...@@ -35,17 +35,17 @@ SieveEditorConfigureServerPageTest::~SieveEditorConfigureServerPageTest()
void SieveEditorConfigureServerPageTest::shouldHaveDefaultValue() void SieveEditorConfigureServerPageTest::shouldHaveDefaultValue()
{ {
SieveEditorConfigureServerPage w; SieveEditorConfigureServerPage w;
QPushButton *button = w.findChild<QPushButton *>(QStringLiteral("configure_button")); auto *button = w.findChild<QPushButton *>(QStringLiteral("configure_button"));
QVERIFY(button); QVERIFY(button);
QPushButton *importSieveSettings = w.findChild<QPushButton *>(QStringLiteral("import_sieve_settings_button")); auto *importSieveSettings = w.findChild<QPushButton *>(QStringLiteral("import_sieve_settings_button"));
QVERIFY(importSieveSettings); QVERIFY(importSieveSettings);
} }
void SieveEditorConfigureServerPageTest::shouldEmitSignalWhenClickOnConfigureButton() void SieveEditorConfigureServerPageTest::shouldEmitSignalWhenClickOnConfigureButton()
{ {
SieveEditorConfigureServerPage w; SieveEditorConfigureServerPage w;
QPushButton *button = w.findChild<QPushButton *>(QStringLiteral("configure_button")); auto *button = w.findChild<QPushButton *>(QStringLiteral("configure_button"));
QSignalSpy spy(&w, &SieveEditorConfigureServerPage::configureClicked); QSignalSpy spy(&w, &SieveEditorConfigureServerPage::configureClicked);
QTest::mouseClick(button, Qt::LeftButton); QTest::mouseClick(button, Qt::LeftButton);
QCOMPARE(spy.count(), 1); QCOMPARE(spy.count(), 1);
...@@ -54,7 +54,7 @@ void SieveEditorConfigureServerPageTest::shouldEmitSignalWhenClickOnConfigureBut ...@@ -54,7 +54,7 @@ void SieveEditorConfigureServerPageTest::shouldEmitSignalWhenClickOnConfigureBut
void SieveEditorConfigureServerPageTest::shouldEmitSignalWhenClickOnImportSieveButton() void SieveEditorConfigureServerPageTest::shouldEmitSignalWhenClickOnImportSieveButton()
{ {
SieveEditorConfigureServerPage w; SieveEditorConfigureServerPage w;
QPushButton *button = w.findChild<QPushButton *>(QStringLiteral("import_sieve_settings_button")); auto *button = w.findChild<QPushButton *>(QStringLiteral("import_sieve_settings_button"));
QSignalSpy spy(&w, &SieveEditorConfigureServerPage::importSieveSettings); QSignalSpy spy(&w, &SieveEditorConfigureServerPage::importSieveSettings);
QTest::mouseClick(button, Qt::LeftButton); QTest::mouseClick(button, Qt::LeftButton);
QCOMPARE(spy.count(), 1); QCOMPARE(spy.count(), 1);
......
...@@ -36,16 +36,16 @@ ImportImapSettingFinishPageTest::~ImportImapSettingFinishPageTest() ...@@ -36,16 +36,16 @@ ImportImapSettingFinishPageTest::~ImportImapSettingFinishPageTest()
void ImportImapSettingFinishPageTest::shouldHaveDefaultValue() void ImportImapSettingFinishPageTest::shouldHaveDefaultValue()
{ {
ImportImapSettingFinishPage w; ImportImapSettingFinishPage w;
QLabel *label = w.findChild<QLabel *>(QStringLiteral("label")); auto *label = w.findChild<QLabel *>(QStringLiteral("label"));
QVERIFY(label); QVERIFY(label);
QVERIFY(!label->text().isEmpty()); QVERIFY(!label->text().isEmpty());
QTextEdit *mTextEdit = w.findChild<QTextEdit *>(QStringLiteral("textedit")); auto *mTextEdit = w.findChild<QTextEdit *>(QStringLiteral("textedit"));
QVERIFY(mTextEdit); QVERIFY(mTextEdit);
QVERIFY(mTextEdit->isReadOnly()); QVERIFY(mTextEdit->isReadOnly());
QVERIFY(mTextEdit->document()->isEmpty()); QVERIFY(mTextEdit->document()->isEmpty());
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout")); auto *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout); QVERIFY(mainLayout);
} }
......
...@@ -35,11 +35,11 @@ ImportImapSettingNoFoundPageTest::~ImportImapSettingNoFoundPageTest() ...@@ -35,11 +35,11 @@ ImportImapSettingNoFoundPageTest::~ImportImapSettingNoFoundPageTest()
void ImportImapSettingNoFoundPageTest::shouldHaveDefaultValue() void ImportImapSettingNoFoundPageTest::shouldHaveDefaultValue()
{ {
ImportImapSettingNoFoundPage w; ImportImapSettingNoFoundPage w;
QLabel *lab = w.findChild<QLabel *>(QStringLiteral("label")); auto *lab = w.findChild<QLabel *>(QStringLiteral("label"));
QVERIFY(lab); QVERIFY(lab);
QVERIFY(!lab->text().isEmpty()); QVERIFY(!lab->text().isEmpty());
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout")); auto *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout); QVERIFY(mainLayout);
} }
......
...@@ -38,12 +38,12 @@ void ImportImapSettingProgressPageTest::shouldHaveDefaultValue() ...@@ -38,12 +38,12 @@ void ImportImapSettingProgressPageTest::shouldHaveDefaultValue()
{ {
ImportImapSettingProgressPage w; ImportImapSettingProgressPage w;
QTextEdit *mProgressTextEdit = w.findChild<QTextEdit *>(QStringLiteral("textedit")); auto *mProgressTextEdit = w.findChild<QTextEdit *>(QStringLiteral("textedit"));
QVERIFY(mProgressTextEdit); QVERIFY(mProgressTextEdit);
QVERIFY(mProgressTextEdit->isReadOnly()); QVERIFY(mProgressTextEdit->isReadOnly());
QVERIFY(mProgressTextEdit->document()->isEmpty()); QVERIFY(mProgressTextEdit->document()->isEmpty());
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout")); auto *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout); QVERIFY(mainLayout);
} }
......
...@@ -37,15 +37,15 @@ ImportImapSettingSearchPageTest::~ImportImapSettingSearchPageTest() ...@@ -37,15 +37,15 @@ ImportImapSettingSearchPageTest::~ImportImapSettingSearchPageTest()
void ImportImapSettingSearchPageTest::shouldHaveDefaultValue() void ImportImapSettingSearchPageTest::shouldHaveDefaultValue()
{ {
ImportImapSettingSearchPage w; ImportImapSettingSearchPage w;
QLabel *label = w.findChild<QLabel *>(QStringLiteral("label")); auto *label = w.findChild<QLabel *>(QStringLiteral("label"));
QVERIFY(label); QVERIFY(label);
QVERIFY(!label->text().isEmpty()); QVERIFY(!label->text().isEmpty());
QListWidget *mFoundProgramList = w.findChild<QListWidget *>(QStringLiteral("foundprogramlist")); auto *mFoundProgramList = w.findChild<QListWidget *>(QStringLiteral("foundprogramlist"));
QVERIFY(mFoundProgramList); QVERIFY(mFoundProgramList);
QCOMPARE(mFoundProgramList->count(), 0); QCOMPARE(mFoundProgramList->count(), 0);
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout")); auto *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout); QVERIFY(mainLayout);
} }
...@@ -57,7 +57,7 @@ void ImportImapSettingSearchPageTest::shouldAddCheckPrograms() ...@@ -57,7 +57,7 @@ void ImportImapSettingSearchPageTest::shouldAddCheckPrograms()
}; };
w.setProgramList(lst); w.setProgramList(lst);
QListWidget *mFoundProgramList = w.findChild<QListWidget *>(QStringLiteral("foundprogramlist")); auto *mFoundProgramList = w.findChild<QListWidget *>(QStringLiteral("foundprogramlist"));
QCOMPARE(mFoundProgramList->count(), lst.count()); QCOMPARE(mFoundProgramList->count(), lst.count());
for (int i = 0; i < mFoundProgramList->count(); ++i) { for (int i = 0; i < mFoundProgramList->count(); ++i) {
QCOMPARE(mFoundProgramList->item(i)->checkState(), Qt::Unchecked); QCOMPARE(mFoundProgramList->item(i)->checkState(), Qt::Unchecked);
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
ImportImapSettingFinishPage::ImportImapSettingFinishPage(QWidget *parent) ImportImapSettingFinishPage::ImportImapSettingFinishPage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
QVBoxLayout *mainlayout = new QVBoxLayout(this); auto *mainlayout = new QVBoxLayout(this);
mainlayout->setObjectName(QStringLiteral("mainlayout")); mainlayout->setObjectName(QStringLiteral("mainlayout"));
QLabel *label = new QLabel(i18n("IMAP settings were imported:"), this); QLabel *label = new QLabel(i18n("IMAP settings were imported:"), this);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
ImportImapSettingNoFoundPage::ImportImapSettingNoFoundPage(QWidget *parent) ImportImapSettingNoFoundPage::ImportImapSettingNoFoundPage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
QVBoxLayout *mainLayout = new QVBoxLayout(this); auto *mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainlayout")); mainLayout->setObjectName(QStringLiteral("mainlayout"));
QLabel *lab = new QLabel(i18n("No settings found to import.")); QLabel *lab = new QLabel(i18n("No settings found to import."));
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
ImportImapSettingProgressPage::ImportImapSettingProgressPage(QWidget *parent) ImportImapSettingProgressPage::ImportImapSettingProgressPage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
QVBoxLayout *mainLayout = new QVBoxLayout(this); auto *mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainlayout")); mainLayout->setObjectName(QStringLiteral("mainlayout"));
mProgressTextEdit = new QTextEdit(this); mProgressTextEdit = new QTextEdit(this);
mProgressTextEdit->setObjectName(QStringLiteral("textedit")); mProgressTextEdit->setObjectName(QStringLiteral("textedit"));
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
ImportImapSettingSearchPage::ImportImapSettingSearchPage(QWidget *parent) ImportImapSettingSearchPage::ImportImapSettingSearchPage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
QVBoxLayout *mainLayout = new QVBoxLayout(this); auto *mainLayout = new QVBoxLayout(this);
mainLayout->setObjectName(QStringLiteral("mainlayout")); mainLayout->setObjectName(QStringLiteral("mainlayout"));
QLabel *label = new QLabel(i18n("Please select the program from which you like to import IMAP settings:"), this); QLabel *label = new QLabel(i18n("Please select the program from which you like to import IMAP settings:"), this);
label->setObjectName(QStringLiteral("label")); label->setObjectName(QStringLiteral("label"));
...@@ -46,7 +46,7 @@ ImportImapSettingSearchPage::~ImportImapSettingSearchPage() ...@@ -46,7 +46,7 @@ ImportImapSettingSearchPage::~ImportImapSettingSearchPage()
void ImportImapSettingSearchPage::setProgramList(const QStringList &lst) void ImportImapSettingSearchPage::setProgramList(const QStringList &lst)
{ {
for (const QString &prog : lst) { for (const QString &prog : lst) {
QListWidgetItem *item = new QListWidgetItem(prog, mFoundProgramList); auto *item = new QListWidgetItem(prog, mFoundProgramList);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(Qt::Unchecked); item->setCheckState(Qt::Unchecked);
} }
......
...@@ -71,14 +71,14 @@ ImportImapSettingWizard::~ImportImapSettingWizard() ...@@ -71,14 +71,14 @@ ImportImapSettingWizard::~ImportImapSettingWizard()
void ImportImapSettingWizard::initializeWizard() void ImportImapSettingWizard::initializeWizard()
{ {
bool hasSettingToImport = false; bool hasSettingToImport = false;
ImportImapSettingsThunderbirdCheckJob *thjob = new ImportImapSettingsThunderbirdCheckJob(this); auto *thjob = new ImportImapSettingsThunderbirdCheckJob(this);
if (thjob->settingsCanBeImported()) { if (thjob->settingsCanBeImported()) {
mListCheckJob.insert(thjob->name(), thjob); mListCheckJob.insert(thjob->name(), thjob);
hasSettingToImport = true; hasSettingToImport = true;
} else { } else {
delete thjob; delete thjob;
} }
ImportImapSettingsAkonadiCheckJob *akonadiJob = new ImportImapSettingsAkonadiCheckJob(this); auto *akonadiJob = new ImportImapSettingsAkonadiCheckJob(this);
akonadiJob->setImapSettingsPassword(new ImportImapSettingsAkonadiPassword); akonadiJob->setImapSettingsPassword(new ImportImapSettingsAkonadiPassword);
if (akonadiJob->settingsCanBeImported()) { if (akonadiJob->settingsCanBeImported()) {
mListCheckJob.insert(akonadiJob->name(), akonadiJob); mListCheckJob.insert(akonadiJob->name(), akonadiJob);
......
...@@ -75,7 +75,7 @@ int main(int argc, char **argv) ...@@ -75,7 +75,7 @@ int main(int argc, char **argv)
KDBusService service(KDBusService::Unique); KDBusService service(KDBusService::Unique);
SieveEditorMainWindow *mw = new SieveEditorMainWindow(); auto *mw = new SieveEditorMainWindow();
mw->show(); mw->show();
const int val = app.exec(); const int val = app.exec();
return val; return val;
......
...@@ -39,7 +39,7 @@ void ServerSieveListWidget::readConfig() ...@@ -39,7 +39,7 @@ void ServerSieveListWidget::readConfig()
{ {
const QVector<SieveEditorUtil::SieveServerConfig> lstServer = SieveEditorUtil::readServerSieveConfig(); const QVector<SieveEditorUtil::SieveServerConfig> lstServer = SieveEditorUtil::readServerSieveConfig();
for (const SieveEditorUtil::SieveServerConfig &conf : lstServer) { for (const SieveEditorUtil::SieveServerConfig &conf : lstServer) {
ServerSieveListWidgetItem *item = new ServerSieveListWidgetItem(this); auto *item = new ServerSieveListWidgetItem(this);
item->setServerConfig(conf); item->setServerConfig(conf);
} }
} }
...@@ -48,7 +48,7 @@ void ServerSieveListWidget::writeConfig() ...@@ -48,7 +48,7 @@ void ServerSieveListWidget::writeConfig()
{ {
QVector<SieveEditorUtil::SieveServerConfig> lstServerConfig; QVector<SieveEditorUtil::SieveServerConfig> lstServerConfig;
for (int i = 0; i < count(); ++i) { for (int i = 0; i < count(); ++i) {
ServerSieveListWidgetItem *serverSieveItem = static_cast<ServerSieveListWidgetItem *>(item(i)); auto *serverSieveItem = static_cast<ServerSieveListWidgetItem *>(item(i));
if (serverSieveItem) { if (serverSieveItem) {
SieveEditorUtil::SieveServerConfig config = serverSieveItem->serverConfig(); SieveEditorUtil::SieveServerConfig config = serverSieveItem->serverConfig();
config.enabled = (serverSieveItem->checkState() == Qt::Checked); config.enabled = (serverSieveItem->checkState() == Qt::Checked);
...@@ -66,7 +66,7 @@ void ServerSieveListWidget::modifyServerConfig() ...@@ -66,7 +66,7 @@ void ServerSieveListWidget::modifyServerConfig()
return; return;
} }
ServerSieveListWidgetItem *serverSieveListItem = static_cast<ServerSieveListWidgetItem *>(item); auto *serverSieveListItem = static_cast<ServerSieveListWidgetItem *>(item);
QPointer<ServerSieveSettingsDialog> dlg = new ServerSieveSettingsDialog(this); QPointer<ServerSieveSettingsDialog> dlg = new ServerSieveSettingsDialog(this);
dlg->setWindowTitle(i18nc("@title:window", "Modify Settings")); dlg->setWindowTitle(i18nc("@title:window", "Modify Settings"));
...@@ -79,7 +79,7 @@ void ServerSieveListWidget::modifyServerConfig() ...@@ -79,7 +79,7 @@ void ServerSieveListWidget::modifyServerConfig()
void ServerSieveListWidget::deleteServerConfig(QListWidgetItem *item) void ServerSieveListWidget::deleteServerConfig(QListWidgetItem *item)
{ {
ServerSieveListWidgetItem *serverSieveListItem = static_cast<ServerSieveListWidgetItem *>(item); auto *serverSieveListItem = static_cast<ServerSieveListWidgetItem *>(item);
SieveEditorUtil::SieveServerConfig conf = serverSieveListItem->serverConfig(); SieveEditorUtil::SieveServerConfig conf = serverSieveListItem->serverConfig();
mNeedToRemovePasswordInWallet.append(SieveEditorUtil::sievePasswordIdentifier(conf.sieveSettings.userName, conf.sieveSettings.serverName)); mNeedToRemovePasswordInWallet.append(SieveEditorUtil::sievePasswordIdentifier(conf.sieveSettings.userName, conf.sieveSettings.serverName));
...@@ -93,7 +93,7 @@ void ServerSieveListWidget::addServerConfig() ...@@ -93,7 +93,7 @@ void ServerSieveListWidget::addServerConfig()
{ {
QPointer<ServerSieveSettingsDialog> dlg = new ServerSieveSettingsDialog(this); QPointer<ServerSieveSettingsDialog> dlg = new ServerSieveSettingsDialog(this);
if (dlg->exec()) { if (dlg->exec()) {
ServerSieveListWidgetItem *item = new ServerSieveListWidgetItem(this); auto *item = new ServerSieveListWidgetItem(this);
item->setServerConfig(dlg->serverSieveConfig()); item->setServerConfig(dlg->serverSieveConfig());
} }
delete dlg; delete dlg;
......
...@@ -31,13 +31,13 @@ ServerSieveSettingsDialog::ServerSieveSettingsDialog(QWidget *parent) ...@@ -31,13 +31,13 @@ ServerSieveSettingsDialog::ServerSieveSettingsDialog(QWidget *parent)
setWindowTitle(i18nc("@title:window", "Add Sieve Server")); setWindowTitle(i18nc("@title:window", "Add Sieve Server"));
QWidget *w = new QWidget; QWidget *w = new QWidget;
QVBoxLayout *lay = new QVBoxLayout; auto *lay = new QVBoxLayout;
mServerSieveSettings = new ServerSieveSettings; mServerSieveSettings = new ServerSieveSettings;
connect(mServerSieveSettings, &ServerSieveSettings::enableOkButton, this, &ServerSieveSettingsDialog::slotEnableButtonOk); connect(mServerSieveSettings, &ServerSieveSettings::enableOkButton, this, &ServerSieveSettingsDialog::slotEnableButtonOk);
lay->addWidget(mServerSieveSettings); lay->addWidget(mServerSieveSettings);
lay->setContentsMargins({}); lay->setContentsMargins({});
w->setLayout(lay); w->setLayout(lay);
QVBoxLayout *mainLayout = new QVBoxLayout(this); auto *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(w); mainLayout->addWidget(w);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
......
...@@ -51,7 +51,7 @@ SieveEditorConfigureDialog::SieveEditorConfigureDialog(QWidget *parent) ...@@ -51,7 +51,7 @@ SieveEditorConfigureDialog::SieveEditorConfigureDialog(QWidget *parent)
//Server page //Server page
QWidget *serverConfigureWiget = new QWidget; QWidget *serverConfigureWiget = new QWidget;
QVBoxLayout *layout = new QVBoxLayout(serverConfigureWiget); auto *layout = new QVBoxLayout(serverConfigureWiget);
mServerWidget = new SieveEditorConfigureServerWidget; mServerWidget = new SieveEditorConfigureServerWidget;
layout->addWidget(mServerWidget); layout->addWidget(mServerWidget);
...@@ -83,7 +83,7 @@ SieveEditorConfigureDialog::SieveEditorConfigureDialog(QWidget *parent) ...@@ -83,7 +83,7 @@ SieveEditorConfigureDialog::SieveEditorConfigureDialog(QWidget *parent)
mUserFeedbackWidget = new KUserFeedback::FeedbackConfigWidget(this); mUserFeedbackWidget = new KUserFeedback::FeedbackConfigWidget(this);
QHBoxLayout *userFeedBackLayout = new QHBoxLayout(userFeedBackWidget); auto *userFeedBackLayout = new QHBoxLayout(userFeedBackWidget);
userFeedBackLayout->setContentsMargins({}); userFeedBackLayout->setContentsMargins({});
userFeedBackLayout->addWidget(mUserFeedbackWidget); userFeedBackLayout->addWidget(mUserFeedbackWidget);
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
SieveEditorConfigureServerPage::SieveEditorConfigureServerPage(QWidget *parent) SieveEditorConfigureServerPage::SieveEditorConfigureServerPage(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
QHBoxLayout *hbox = new QHBoxLayout(this); auto *hbox = new QHBoxLayout(this);
hbox->addStretch(1); hbox->addStretch(1);
QPushButton *button = new QPushButton(i18n("Configure...")); QPushButton *button = new QPushButton(i18n("Configure..."));
button->setObjectName(QStringLiteral("configure_button")); button->setObjectName(QStringLiteral("configure_button"));
......
...@@ -78,7 +78,7 @@ SieveEditorMainWidget::~SieveEditorMainWidget() ...@@ -78,7 +78,7 @@ SieveEditorMainWidget::~SieveEditorMainWidget()
QWidget *SieveEditorMainWidget::hasExistingPage(const QUrl &url) QWidget *SieveEditorMainWidget::hasExistingPage(const QUrl &url)
{ {
for (int i = 0; i < mTabWidget->count(); ++i) { for (int i = 0; i < mTabWidget->count(); ++i) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(mTabWidget->widget(i)); auto *page = qobject_cast<SieveEditorPageWidget *>(mTabWidget->widget(i));
if (page) { if (page) {
if (page->currentUrl() == url) { if (page->currentUrl() == url) {
return page; return page;
...@@ -111,7 +111,7 @@ void SieveEditorMainWidget::slotScriptRenamed(const QUrl &oldUrl, const QUrl &ne ...@@ -111,7 +111,7 @@ void SieveEditorMainWidget::slotScriptRenamed(const QUrl &oldUrl, const QUrl &ne
{ {
QWidget *page = hasExistingPage(oldUrl); QWidget *page = hasExistingPage(oldUrl);
if (page) { if (page) {
if (SieveEditorPageWidget *editor = qobject_cast<SieveEditorPageWidget *>(page)) { if (auto *editor = qobject_cast<SieveEditorPageWidget *>(page)) {
editor->setCurrentUrl(newUrl); editor->setCurrentUrl(newUrl);
const QString newScriptName = newUrl.fileName(); const QString newScriptName = newUrl.fileName();
mTabWidget->setTabText(mTabWidget->indexOf(page), newScriptName); mTabWidget->setTabText(mTabWidget->indexOf(page), newScriptName);
...@@ -127,7 +127,7 @@ void SieveEditorMainWidget::slotCreateScriptPage(const KSieveUi::ManageSieveWidg ...@@ -127,7 +127,7 @@ void SieveEditorMainWidget::slotCreateScriptPage(const KSieveUi::ManageSieveWidg
if (page) { if (page) {
mTabWidget->setCurrentWidget(page); mTabWidget->setCurrentWidget(page);
} else { } else {
SieveEditorPageWidget *editor = new SieveEditorPageWidget; auto *editor = new SieveEditorPageWidget;
connect(editor, &SieveEditorPageWidget::refreshList, this, &SieveEditorMainWidget::updateScriptList); connect(editor, &SieveEditorPageWidget::refreshList, this, &SieveEditorMainWidget::updateScriptList);
connect(editor, &SieveEditorPageWidget::scriptModified, this, &SieveEditorMainWidget::slotScriptModified); connect(editor, &SieveEditorPageWidget::scriptModified, this, &SieveEditorMainWidget::slotScriptModified);
connect(editor, &SieveEditorPageWidget::modeEditorChanged, this, &SieveEditorMainWidget::modeEditorChanged); connect(editor, &SieveEditorPageWidget::modeEditorChanged, this, &SieveEditorMainWidget::modeEditorChanged);
...@@ -181,7 +181,7 @@ void SieveEditorMainWidget::uploadScript() ...@@ -181,7 +181,7 @@ void SieveEditorMainWidget::uploadScript()
{ {
QWidget *w = mTabWidget->currentWidget(); QWidget *w = mTabWidget->currentWidget();
if (w) { if (w) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(w); auto *page = qobject_cast<SieveEditorPageWidget *>(w);
if (page) { if (page) {
page->uploadScript(); page->uploadScript();
} }
...@@ -192,7 +192,7 @@ bool SieveEditorMainWidget::needToSaveScript() ...@@ -192,7 +192,7 @@ bool SieveEditorMainWidget::needToSaveScript()
{ {
bool scriptSaved = false; bool scriptSaved = false;
for (int i = 0; i < mTabWidget->count(); ++i) { for (int i = 0; i < mTabWidget->count(); ++i) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(mTabWidget->widget(i)); auto *page = qobject_cast<SieveEditorPageWidget *>(mTabWidget->widget(i));
if (page) { if (page) {
const bool result = page->needToSaveScript(); const bool result = page->needToSaveScript();
if (result) { if (result) {
...@@ -212,7 +212,7 @@ bool SieveEditorMainWidget::isUndoAvailable() const ...@@ -212,7 +212,7 @@ bool SieveEditorMainWidget::isUndoAvailable() const
{ {
QWidget *w = mTabWidget->currentWidget(); QWidget *w = mTabWidget->currentWidget();
if (w) { if (w) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(w); auto *page = qobject_cast<SieveEditorPageWidget *>(w);
if (page) { if (page) {
return page->isUndoAvailable(); return page->isUndoAvailable();
} }
...@@ -224,7 +224,7 @@ bool SieveEditorMainWidget::isRedoAvailable() const ...@@ -224,7 +224,7 @@ bool SieveEditorMainWidget::isRedoAvailable() const
{ {
QWidget *w = mTabWidget->currentWidget(); QWidget *w = mTabWidget->currentWidget();
if (w) { if (w) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(w); auto *page = qobject_cast<SieveEditorPageWidget *>(w);
if (page) { if (page) {
return page->isRedoAvailable(); return page->isRedoAvailable();
} }
...@@ -236,7 +236,7 @@ bool SieveEditorMainWidget::isWordWrap() const ...@@ -236,7 +236,7 @@ bool SieveEditorMainWidget::isWordWrap() const
{ {
QWidget *w = mTabWidget->currentWidget(); QWidget *w = mTabWidget->currentWidget();
if (w) { if (w) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(w); auto *page = qobject_cast<SieveEditorPageWidget *>(w);
if (page) { if (page) {
return page->isWordWrap(); return page->isWordWrap();
} }
...@@ -248,7 +248,7 @@ bool SieveEditorMainWidget::hasSelection() const ...@@ -248,7 +248,7 @@ bool SieveEditorMainWidget::hasSelection() const
{ {
QWidget *w = mTabWidget->currentWidget(); QWidget *w = mTabWidget->currentWidget();
if (w) { if (w) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(w); auto *page = qobject_cast<SieveEditorPageWidget *>(w);
if (page) { if (page) {
return page->hasSelection(); return page->hasSelection();
} }
...@@ -260,7 +260,7 @@ void SieveEditorMainWidget::slotSelectAll() ...@@ -260,7 +260,7 @@ void SieveEditorMainWidget::slotSelectAll()
{ {
QWidget *w = mTabWidget->currentWidget(); QWidget *w = mTabWidget->currentWidget();
if (w) { if (w) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(w); auto *page = qobject_cast<SieveEditorPageWidget *>(w);
if (page) { if (page) {
page->selectAll(); page->selectAll();
} }
...@@ -271,7 +271,7 @@ void SieveEditorMainWidget::slotCopy() ...@@ -271,7 +271,7 @@ void SieveEditorMainWidget::slotCopy()
{ {
QWidget *w = mTabWidget->currentWidget(); QWidget *w = mTabWidget->currentWidget();
if (w) { if (w) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(w); auto *page = qobject_cast<SieveEditorPageWidget *>(w);
if (page) { if (page) {
page->copy(); page->copy();
} }
...@@ -282,7 +282,7 @@ void SieveEditorMainWidget::slotPaste() ...@@ -282,7 +282,7 @@ void SieveEditorMainWidget::slotPaste()
{ {
QWidget *w = mTabWidget->currentWidget(); QWidget *w = mTabWidget->currentWidget();
if (w) { if (w) {
SieveEditorPageWidget *page = qobject_cast<SieveEditorPageWidget *>(w); auto *page = qobject_cast<SieveEditorPageWidget *>(w);
if (page) { if (page) {
page->paste(); page->paste();
} }
...@@ -293,7 +293,7 @@ void SieveEditorMainWidget::slotCut() ...@@ -293,7 +293,7 @@ void SieveEditorMainWidget::slotCut()
{ {
QWidget *w = mTabWidget->currentWidget(); QWidget *w = mTabWidget->currentWidget();
if (w) {