Commit 916b1064 authored by Laurent Montel's avatar Laurent Montel 😁

Remove some qAsConst

parent dfe1408c
......@@ -18,6 +18,7 @@
*/
#include "autocreatescriptutil_p.h"
#include "util/util.h"
#include <KLocalizedString>
......@@ -85,7 +86,7 @@ QStringList AutoCreateScriptUtil::createListFromString(QString str)
}
lst = str.split(QStringLiteral(", "));
QStringList resultLst;
Q_FOREACH (QString s, lst) {
for (QString s : qAsConst(lst)) {
s.remove(QLatin1Char('"'));
resultLst << s.trimmed();
}
......
......@@ -319,7 +319,8 @@ void SieveGlobalVariableLister::loadSetVariable(const QDomElement &element, QStr
node = node.nextSibling();
}
Q_FOREACH (QWidget *widget, widgets()) {
const QList<QWidget *> lstWidget = widgets();
for (QWidget *widget : lstWidget) {
SieveGlobalVariableActionWidget *w = static_cast<SieveGlobalVariableActionWidget *>(widget);
if (w->variableName() == variableName) {
w->setVariableValue(variableValue);
......
......@@ -23,6 +23,7 @@
#include "sieveforeverypartwidget.h"
#include "sievescriptpage.h"
#include "sieveincludewidget.h"
#include "util/util.h"
#include <QHBoxLayout>
#include <KMessageBox>
......@@ -354,7 +355,7 @@ QString SieveScriptListBox::generatedScript(QString &requires) const
}
QStringList endRequires;
Q_FOREACH (const QString &r, lstRequires) {
for (const QString &r : qAsConst(lstRequires)) {
if (!endRequires.contains(r)) {
endRequires.append(r);
requires += QStringLiteral("require \"%1\";\n").arg(r);
......
......@@ -16,6 +16,7 @@
*/
#include "sieveinfowidget.h"
#include "util/util.h"
#include <KLocalizedString>
......@@ -43,7 +44,7 @@ void SieveInfoWidget::setServerInfo(QStringList serverInfos)
{
serverInfos.sort();
QString result = QLatin1String("<qt><b>") + i18n("Sieve server supports:") + QLatin1String("</b><ul>");
Q_FOREACH (const QString &info, serverInfos) {
for (const QString &info : qAsConst(serverInfos)) {
result += QLatin1String("<li>") + info;
}
result += QLatin1String("</ul></qt>");
......
......@@ -18,6 +18,7 @@
#include "generateglobalscriptjob.h"
#include "kmanagesieve/sievejob.h"
#include "util/util.h"
#include <KLocalizedString>
......@@ -118,7 +119,7 @@ void GenerateGlobalScriptJob::writeUserScript()
"\n"
"require [\"include\"];\n");
Q_FOREACH (const QString &activeScript, mListUserActiveScripts) {
for (const QString &activeScript : qAsConst(mListUserActiveScripts)) {
userScript += QStringLiteral("\ninclude :personal \"%1\"").arg(activeScript);
}
......
......@@ -55,10 +55,10 @@ void XMLPrintingSyntaxHighLighter::init()
QTextCharFormat misc;
misc.setForeground(Qt::red);
misc.setFontWeight(QFont::Bold);
QStringList miscType;
miscType << QStringLiteral("control") << QStringLiteral("block") << QStringLiteral("script") << QStringLiteral("action") << QStringLiteral("comment");
miscType << QStringLiteral("num") << QStringLiteral("tag") << QStringLiteral("list") << QStringLiteral("str") << QStringLiteral("test") << QStringLiteral("crlf/");
Q_FOREACH (const QString &s, miscType) {
const QStringList miscType = QStringList()
<< QStringLiteral("control") << QStringLiteral("block") << QStringLiteral("script") << QStringLiteral("action") << QStringLiteral("comment")
<< QStringLiteral("num") << QStringLiteral("tag") << QStringLiteral("list") << QStringLiteral("str") << QStringLiteral("test") << QStringLiteral("crlf/");
for (const QString &s : miscType) {
const QRegularExpression regex(s, QRegularExpression::CaseInsensitiveOption);
m_rules.append(KPIMTextEdit::Rule(regex, misc));
}
......
......@@ -48,6 +48,22 @@ class QUrl;
class QString;
class QStringList;
#if QT_VERSION < QT_VERSION_CHECK(5,7,0)
namespace QtPrivate
{
template <typename T> struct QAddConst {
typedef const T Type;
};
}
// this adds const to non-const objects (like std::as_const)
template <typename T>
Q_DECL_CONSTEXPR typename QtPrivate::QAddConst<T>::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; }
// prevent rvalue arguments:
template <typename T>
void qAsConst(const T &&) Q_DECL_EQ_DELETE;
#endif
namespace KSieveUi
{
/**
......
......@@ -88,7 +88,8 @@ bool Legacy::VacationUtils::parseScript(const QString &script, QString &messageT
}
notificationInterval = vdx.notificationInterval();
aliases.clear();
foreach (const QString &alias, vdx.aliases()) {
const QStringList lstAliases = vdx.aliases();
for (const QString &alias : lstAliases) {
KMime::Types::Mailbox a;
a.fromUnicodeString(alias);
aliases.append(a.addrSpec());
......
......@@ -160,7 +160,7 @@ void VacationCheckJob::searchVacationScript()
QStringList scriptList = mActiveScripts;
// Reorder script list
foreach (const QString &script, mAvailableScripts) {
for (const QString &script : qAsConst(mAvailableScripts)) {
if (!scriptList.contains(script)) {
scriptList.append(script);
}
......
......@@ -104,7 +104,8 @@ KMime::Types::AddrSpecList VacationUtils::defaultMailAliases()
a.fromUnicodeString((*it).primaryEmailAddress());
sl.push_back(a.addrSpec());
}
foreach (const QString &email, (*it).emailAliases()) {
const QStringList lstEmails = (*it).emailAliases();
for (const QString &email : lstEmails) {
KMime::Types::Mailbox a;
a.fromUnicodeString(email);
sl.push_back(a.addrSpec());
......@@ -195,7 +196,8 @@ VacationUtils::Vacation VacationUtils::parseScript(const QString &script)
}
vacation.notificationInterval = vdx.notificationInterval();
vacation.aliases = KMime::Types::AddrSpecList();
foreach (const QString &alias, vdx.aliases()) {
const QStringList lstAliases = vdx.aliases();
for (const QString &alias : lstAliases) {
KMime::Types::Mailbox a;
a.fromUnicodeString(alias);
vacation.aliases.append(a.addrSpec());
......
......@@ -577,7 +577,7 @@ void ManageSieveWidget::setActiveScripts(ParseUserScriptJob *job)
}
}
foreach (const QString &scriptName, scriptOrder) {
for (const QString &scriptName : qAsConst(scriptOrder)) {
parent->addChild(scriptMap[scriptName]);
}
......
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