Commit 4f16b16e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent 54b26bb2
Pipeline #92790 canceled with stage
......@@ -112,31 +112,28 @@ void SieveActionWidget::initWidget()
mComboBox->setEditable(false);
mComboBox->setMinimumWidth(50);
const QVector<KSieveUi::SieveAction *> list = KSieveUi::SieveActionList::actionList(mSieveGraphicalModeWidget);
QVector<KSieveUi::SieveAction *>::const_iterator it;
QVector<KSieveUi::SieveAction *>::const_iterator end(list.constEnd());
int index = 0;
QStringList listCapabilities = mSieveGraphicalModeWidget->sieveCapabilities();
// imapflags was old name of imap4flags but still used.
if (listCapabilities.contains(QLatin1String("imap4flags"))) {
listCapabilities.append(QStringLiteral("imapflags"));
}
for (index = 0, it = list.constBegin(); it != end; ++it, ++index) {
if ((*it)->needCheckIfServerHasCapability()) {
if (listCapabilities.contains((*it)->serverNeedsCapability())) {
for (const auto &action : list) {
if (action->needCheckIfServerHasCapability()) {
if (listCapabilities.contains(action->serverNeedsCapability())) {
// append to the list of actions:
mActionList.append(*it);
connect(*it, &SieveAction::valueChanged, this, &SieveActionWidget::valueChanged);
mActionList.append(action);
connect(action, &SieveAction::valueChanged, this, &SieveActionWidget::valueChanged);
// add (i18n-ized) name to combo box
mComboBox->addItem((*it)->label(), (*it)->name());
mComboBox->addItem(action->label(), action->name());
} else {
delete (*it);
delete (action);
}
} else {
// append to the list of actions:
mActionList.append(*it);
connect(*it, &SieveAction::valueChanged, this, &SieveActionWidget::valueChanged);
mActionList.append(action);
connect(action, &SieveAction::valueChanged, this, &SieveActionWidget::valueChanged);
// add (i18n-ized) name to combo box
mComboBox->addItem((*it)->label(), (*it)->name());
mComboBox->addItem(action->label(), action->name());
}
}
......
......@@ -220,9 +220,8 @@ void SieveDebugDialog::slotGetScriptList(KManageSieve::SieveJob *job, bool succe
if (caps.isEmpty()) {
mEdit->editor()->appendPlainText(i18n("(No special capabilities available)"));
} else {
QStringList::const_iterator end = caps.constEnd();
for (QStringList::const_iterator it = caps.constBegin(); it != end; ++it) {
mEdit->editor()->appendPlainText(QLatin1String("* ") + *it + QLatin1Char('\n'));
for (const auto &str : caps) {
mEdit->editor()->appendPlainText(QLatin1String("* ") + str + QLatin1Char('\n'));
}
mEdit->editor()->appendPlainText(QStringLiteral("\n"));
}
......@@ -233,9 +232,8 @@ void SieveDebugDialog::slotGetScriptList(KManageSieve::SieveJob *job, bool succe
mEdit->editor()->appendPlainText(i18n("(No Sieve scripts available on this server)\n\n"));
} else {
mScriptList = scriptList;
QStringList::const_iterator end = scriptList.constEnd();
for (QStringList::const_iterator it = scriptList.constBegin(); it != end; ++it) {
mEdit->editor()->appendPlainText(QLatin1String("* ") + *it + QLatin1Char('\n'));
for (const auto &str : scriptList) {
mEdit->editor()->appendPlainText(QLatin1String("* ") + str + QLatin1Char('\n'));
}
mEdit->editor()->appendPlainText(QStringLiteral("\n"));
mEdit->editor()->appendPlainText(i18n("Active script: '%1'\n\n", activeScript));
......
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