Commit 1568daa7 authored by Laurent Montel's avatar Laurent Montel 😁

Use some QStringLiteral

parent 976b92da
...@@ -99,7 +99,7 @@ void FilterActionAddHeaderTest::shouldNotExecuteActionWhenParameterIsEmpty() ...@@ -99,7 +99,7 @@ void FilterActionAddHeaderTest::shouldNotExecuteActionWhenParameterIsEmpty()
item.setPayload<KMime::Message::Ptr>(msgPtr); item.setPayload<KMime::Message::Ptr>(msgPtr);
MailCommon::ItemContext context(item, true); MailCommon::ItemContext context(item, true);
filter.argsFromString(""); filter.argsFromString(QStringLiteral(""));
QCOMPARE(filter.process(context, false), MailCommon::FilterAction::ErrorButGoOn); QCOMPARE(filter.process(context, false), MailCommon::FilterAction::ErrorButGoOn);
QCOMPARE(context.needsPayloadStore(), false); QCOMPARE(context.needsPayloadStore(), false);
QCOMPARE(context.deleteItem(), false); QCOMPARE(context.deleteItem(), false);
...@@ -114,7 +114,7 @@ void FilterActionAddHeaderTest::shouldNotExecuteActionWhenValueIsEmpty() ...@@ -114,7 +114,7 @@ void FilterActionAddHeaderTest::shouldNotExecuteActionWhenValueIsEmpty()
item.setPayload<KMime::Message::Ptr>(msgPtr); item.setPayload<KMime::Message::Ptr>(msgPtr);
MailCommon::ItemContext context(item, true); MailCommon::ItemContext context(item, true);
filter.argsFromString("foo"); filter.argsFromString(QStringLiteral("foo"));
QCOMPARE(filter.process(context, false), MailCommon::FilterAction::ErrorButGoOn); QCOMPARE(filter.process(context, false), MailCommon::FilterAction::ErrorButGoOn);
QCOMPARE(context.needsPayloadStore(), false); QCOMPARE(context.needsPayloadStore(), false);
QCOMPARE(context.deleteItem(), false); QCOMPARE(context.deleteItem(), false);
...@@ -147,7 +147,7 @@ void FilterActionAddHeaderTest::shouldAddNewHeaderWhenNotExistingHeader() ...@@ -147,7 +147,7 @@ void FilterActionAddHeaderTest::shouldAddNewHeaderWhenNotExistingHeader()
item.setPayload<KMime::Message::Ptr>(msgPtr); item.setPayload<KMime::Message::Ptr>(msgPtr);
MailCommon::ItemContext context(item, true); MailCommon::ItemContext context(item, true);
filter.argsFromString("testheader\tfoo"); filter.argsFromString(QStringLiteral("testheader\tfoo"));
QCOMPARE(filter.process(context, false), MailCommon::FilterAction::GoOn); QCOMPARE(filter.process(context, false), MailCommon::FilterAction::GoOn);
QCOMPARE(context.needsPayloadStore(), true); QCOMPARE(context.needsPayloadStore(), true);
QCOMPARE(msgPtr->encodedContent(), output); QCOMPARE(msgPtr->encodedContent(), output);
...@@ -182,7 +182,7 @@ void FilterActionAddHeaderTest::shouldReplaceHeaderWhenExistingHeader() ...@@ -182,7 +182,7 @@ void FilterActionAddHeaderTest::shouldReplaceHeaderWhenExistingHeader()
item.setPayload<KMime::Message::Ptr>(msgPtr); item.setPayload<KMime::Message::Ptr>(msgPtr);
MailCommon::ItemContext context(item, true); MailCommon::ItemContext context(item, true);
filter.argsFromString("testheader\tfoo"); filter.argsFromString(QStringLiteral("testheader\tfoo"));
QCOMPARE(filter.process(context, false), MailCommon::FilterAction::GoOn); QCOMPARE(filter.process(context, false), MailCommon::FilterAction::GoOn);
QCOMPARE(context.needsPayloadStore(), true); QCOMPARE(context.needsPayloadStore(), true);
QCOMPARE(msgPtr->encodedContent(), output); QCOMPARE(msgPtr->encodedContent(), output);
......
...@@ -45,7 +45,7 @@ void FilterActionPipeThroughTest::testWithNoCommand() ...@@ -45,7 +45,7 @@ void FilterActionPipeThroughTest::testWithNoCommand()
item.setPayload<KMime::Message::Ptr>(msgPtr); item.setPayload<KMime::Message::Ptr>(msgPtr);
ItemContext context(item, true); ItemContext context(item, true);
filter.argsFromString(""); filter.argsFromString(QStringLiteral(""));
QCOMPARE(filter.process(context, false), FilterAction::ErrorButGoOn); QCOMPARE(filter.process(context, false), FilterAction::ErrorButGoOn);
QCOMPARE(context.needsPayloadStore(), false); QCOMPARE(context.needsPayloadStore(), false);
} }
......
...@@ -153,7 +153,7 @@ void FilterActionRemoveHeaderTest::shouldRemoveMultiHeader() ...@@ -153,7 +153,7 @@ void FilterActionRemoveHeaderTest::shouldRemoveMultiHeader()
item.setPayload<KMime::Message::Ptr>(msgPtr); item.setPayload<KMime::Message::Ptr>(msgPtr);
MailCommon::ItemContext context(item, true); MailCommon::ItemContext context(item, true);
filter.argsFromString("testheader"); filter.argsFromString(QStringLiteral("testheader"));
QCOMPARE(filter.process(context, false), MailCommon::FilterAction::GoOn); QCOMPARE(filter.process(context, false), MailCommon::FilterAction::GoOn);
QCOMPARE(context.needsPayloadStore(), true); QCOMPARE(context.needsPayloadStore(), true);
QCOMPARE(msgPtr->encodedContent(), output); QCOMPARE(msgPtr->encodedContent(), output);
......
...@@ -74,7 +74,7 @@ void FilterActionRewriteHeaderTest::shouldNotExecuteActionWhenParameterIsEmpty() ...@@ -74,7 +74,7 @@ void FilterActionRewriteHeaderTest::shouldNotExecuteActionWhenParameterIsEmpty()
item.setPayload<KMime::Message::Ptr>(msgPtr); item.setPayload<KMime::Message::Ptr>(msgPtr);
MailCommon::ItemContext context(item, true); MailCommon::ItemContext context(item, true);
filter.argsFromString(""); filter.argsFromString(QStringLiteral(""));
QCOMPARE(filter.process(context, false), MailCommon::FilterAction::ErrorButGoOn); QCOMPARE(filter.process(context, false), MailCommon::FilterAction::ErrorButGoOn);
QCOMPARE(context.needsPayloadStore(), false); QCOMPARE(context.needsPayloadStore(), false);
} }
...@@ -87,11 +87,11 @@ void FilterActionRewriteHeaderTest::shouldNotExecuteActionWhenValueIsEmpty() ...@@ -87,11 +87,11 @@ void FilterActionRewriteHeaderTest::shouldNotExecuteActionWhenValueIsEmpty()
item.setPayload<KMime::Message::Ptr>(msgPtr); item.setPayload<KMime::Message::Ptr>(msgPtr);
MailCommon::ItemContext context(item, true); MailCommon::ItemContext context(item, true);
filter.argsFromString("foo"); filter.argsFromString(QStringLiteral("foo"));
QCOMPARE(filter.process(context, false), MailCommon::FilterAction::ErrorButGoOn); QCOMPARE(filter.process(context, false), MailCommon::FilterAction::ErrorButGoOn);
QCOMPARE(context.needsPayloadStore(), false); QCOMPARE(context.needsPayloadStore(), false);
filter.argsFromString("foo\tbla"); filter.argsFromString(QStringLiteral("foo\tbla"));
QCOMPARE(filter.process(context, false), MailCommon::FilterAction::ErrorButGoOn); QCOMPARE(filter.process(context, false), MailCommon::FilterAction::ErrorButGoOn);
QCOMPARE(context.needsPayloadStore(), false); QCOMPARE(context.needsPayloadStore(), false);
} }
...@@ -172,7 +172,7 @@ void FilterActionRewriteHeaderTest::shouldNotRewriteHeaderWhenRegexpNotFound() ...@@ -172,7 +172,7 @@ void FilterActionRewriteHeaderTest::shouldNotRewriteHeaderWhenRegexpNotFound()
item.setPayload<KMime::Message::Ptr>(msgPtr); item.setPayload<KMime::Message::Ptr>(msgPtr);
MailCommon::ItemContext context(item, true); MailCommon::ItemContext context(item, true);
filter.argsFromString("testheader\tfoo\tbla"); filter.argsFromString(QStringLiteral("testheader\tfoo\tbla"));
QCOMPARE(filter.process(context, false), MailCommon::FilterAction::GoOn); QCOMPARE(filter.process(context, false), MailCommon::FilterAction::GoOn);
QCOMPARE(context.needsPayloadStore(), false); QCOMPARE(context.needsPayloadStore(), false);
QCOMPARE(msgPtr->encodedContent(), data); QCOMPARE(msgPtr->encodedContent(), data);
......
...@@ -66,7 +66,7 @@ void FilterActionWithUrlTest::shouldClearWidget() ...@@ -66,7 +66,7 @@ void FilterActionWithUrlTest::shouldClearWidget()
TestFilterActionWithUrl filter; TestFilterActionWithUrl filter;
QWidget *w = filter.createParamWidget(nullptr); QWidget *w = filter.createParamWidget(nullptr);
KUrlRequester *requester = w->findChild<KUrlRequester *>(QStringLiteral("requester")); KUrlRequester *requester = w->findChild<KUrlRequester *>(QStringLiteral("requester"));
requester->setUrl(QUrl::fromLocalFile("/foo/bla")); requester->setUrl(QUrl::fromLocalFile(QStringLiteral("/foo/bla")));
QVERIFY(!requester->url().isEmpty()); QVERIFY(!requester->url().isEmpty());
filter.clearParamWidget(w); filter.clearParamWidget(w);
QVERIFY(requester->url().isEmpty()); QVERIFY(requester->url().isEmpty());
......
...@@ -165,7 +165,7 @@ QString SearchRule::functionToString(Function function) ...@@ -165,7 +165,7 @@ QString SearchRule::functionToString(Function function)
if (function != FuncNone) { if (function != FuncNone) {
return funcConfigNames[int(function)]; return funcConfigNames[int(function)];
} else { } else {
return "invalid"; return QStringLiteral("invalid");
} }
} }
...@@ -176,7 +176,7 @@ void SearchRule::writeConfig(KConfigGroup &config, int aIdx) const ...@@ -176,7 +176,7 @@ void SearchRule::writeConfig(KConfigGroup &config, int aIdx) const
static const QString func = QStringLiteral("func"); static const QString func = QStringLiteral("func");
static const QString contents = QStringLiteral("contents"); static const QString contents = QStringLiteral("contents");
config.writeEntry(field + cIdx, QString(mField)); config.writeEntry(field + cIdx, /*QString*/(mField));
config.writeEntry(func + cIdx, functionToString(mFunction)); config.writeEntry(func + cIdx, functionToString(mFunction));
config.writeEntry(contents + cIdx, mContents); config.writeEntry(contents + cIdx, mContents);
} }
...@@ -522,7 +522,7 @@ const QString SearchRule::asString() const ...@@ -522,7 +522,7 @@ const QString SearchRule::asString() const
{ {
QString result = QLatin1String("\"") + mField + QLatin1String("\" <"); QString result = QLatin1String("\"") + mField + QLatin1String("\" <");
result += functionToString(mFunction); result += functionToString(mFunction);
result += "> \"" + mContents + "\""; result += QStringLiteral("> \"") + mContents + QStringLiteral("\"");
return result; return result;
} }
......
...@@ -54,10 +54,10 @@ bool SearchRuleDate::matches(const Akonadi::Item &item) const ...@@ -54,10 +54,10 @@ bool SearchRuleDate::matches(const Akonadi::Item &item) const
const QDate dateValue = QDate::fromString(contents(), Qt::ISODate); const QDate dateValue = QDate::fromString(contents(), Qt::ISODate);
bool rc = matchesInternal(dateValue, msgDate); bool rc = matchesInternal(dateValue, msgDate);
if (FilterLog::instance()->isLogging()) { if (FilterLog::instance()->isLogging()) {
QString msg = (rc ? "<font color=#00FF00>1 = </font>" QString msg = (rc ? QStringLiteral("<font color=#00FF00>1 = </font>")
: "<font color=#FF0000>0 = </font>"); : QStringLiteral("<font color=#FF0000>0 = </font>"));
msg += FilterLog::recode(asString()); msg += FilterLog::recode(asString());
msg += " ( <i>" + contents() + "</i> )"; //TODO change with locale? msg += QStringLiteral(" ( <i>") + contents() + QStringLiteral("</i> )"); //TODO change with locale?
FilterLog::instance()->add(msg, FilterLog::RuleResult); FilterLog::instance()->add(msg, FilterLog::RuleResult);
} }
return rc; return rc;
......
...@@ -75,7 +75,7 @@ bool SearchRuleNumerical::matches(const Akonadi::Item &item) const ...@@ -75,7 +75,7 @@ bool SearchRuleNumerical::matches(const Akonadi::Item &item) const
QString msg = (rc ? QStringLiteral("<font color=#00FF00>1 = </font>") QString msg = (rc ? QStringLiteral("<font color=#00FF00>1 = </font>")
: QStringLiteral("<font color=#FF0000>0 = </font>")); : QStringLiteral("<font color=#FF0000>0 = </font>"));
msg += FilterLog::recode(asString()); msg += FilterLog::recode(asString());
msg += " ( <i>" + QString::number(numericalMsgContents) + "</i> )"; msg += QStringLiteral(" ( <i>") + QString::number(numericalMsgContents) + QStringLiteral("</i> )");
FilterLog::instance()->add(msg, FilterLog::RuleResult); FilterLog::instance()->add(msg, FilterLog::RuleResult);
} }
return rc; return rc;
......
...@@ -52,7 +52,7 @@ QString englishNameForStatus(const Akonadi::MessageStatus &status) ...@@ -52,7 +52,7 @@ QString englishNameForStatus(const Akonadi::MessageStatus &status)
{ {
for (int i = 0; i < numStatusNames; ++i) { for (int i = 0; i < numStatusNames; ++i) {
if (statusNames[i].status == status) { if (statusNames[i].status == status) {
return statusNames[i].name; return QString::fromLatin1(statusNames[i].name);
} }
} }
return QString(); return QString();
...@@ -76,7 +76,7 @@ SearchRuleStatus::SearchRuleStatus(Akonadi::MessageStatus status, Function func) ...@@ -76,7 +76,7 @@ SearchRuleStatus::SearchRuleStatus(Akonadi::MessageStatus status, Function func)
Akonadi::MessageStatus SearchRuleStatus::statusFromEnglishName(const QString &aStatusString) Akonadi::MessageStatus SearchRuleStatus::statusFromEnglishName(const QString &aStatusString)
{ {
for (int i = 0; i < numStatusNames; ++i) { for (int i = 0; i < numStatusNames; ++i) {
if (!aStatusString.compare(statusNames[i].name)) { if (!aStatusString.compare(QString::fromLatin1(statusNames[i].name))) {
return statusNames[i].status; return statusNames[i].status;
} }
} }
...@@ -119,7 +119,7 @@ bool SearchRuleStatus::matches(const Akonadi::Item &item) const ...@@ -119,7 +119,7 @@ bool SearchRuleStatus::matches(const Akonadi::Item &item) const
break; break;
} }
if (FilterLog::instance()->isLogging()) { if (FilterLog::instance()->isLogging()) {
QString msg = (rc ? "<font color=#00FF00>1 = </font>" : "<font color=#FF0000>0 = </font>"); QString msg = (rc ? QStringLiteral("<font color=#00FF00>1 = </font>") : QStringLiteral("<font color=#FF0000>0 = </font>"));
msg += FilterLog::recode(asString()); msg += FilterLog::recode(asString());
FilterLog::instance()->add(msg, FilterLog::RuleResult); FilterLog::instance()->add(msg, FilterLog::RuleResult);
} }
......
...@@ -151,7 +151,7 @@ bool SearchRuleString::matches(const Akonadi::Item &item) const ...@@ -151,7 +151,7 @@ bool SearchRuleString::matches(const Akonadi::Item &item) const
} else { } else {
// make sure to treat messages with multiple header lines for // make sure to treat messages with multiple header lines for
// the same header correctly // the same header correctly
msgContents = ""; msgContents = QStringLiteral("");
if (auto hrd = msg->headerByType(field().constData())) { if (auto hrd = msg->headerByType(field().constData())) {
msgContents = hrd->asUnicodeString(); msgContents = hrd->asUnicodeString();
} }
...@@ -160,7 +160,7 @@ bool SearchRuleString::matches(const Akonadi::Item &item) const ...@@ -160,7 +160,7 @@ bool SearchRuleString::matches(const Akonadi::Item &item) const
if (function() == FuncIsInAddressbook || if (function() == FuncIsInAddressbook ||
function() == FuncIsNotInAddressbook) { function() == FuncIsNotInAddressbook) {
// I think only the "from"-field makes sense. // I think only the "from"-field makes sense.
msgContents = ""; msgContents = QStringLiteral("");
if (auto hrd = msg->headerByType(field().constData())) { if (auto hrd = msg->headerByType(field().constData())) {
msgContents = hrd->asUnicodeString(); msgContents = hrd->asUnicodeString();
} }
...@@ -179,11 +179,11 @@ bool SearchRuleString::matches(const Akonadi::Item &item) const ...@@ -179,11 +179,11 @@ bool SearchRuleString::matches(const Akonadi::Item &item) const
bool rc = matchesInternal(msgContents); bool rc = matchesInternal(msgContents);
if (FilterLog::instance()->isLogging()) { if (FilterLog::instance()->isLogging()) {
QString msg = (rc ? "<font color=#00FF00>1 = </font>" : "<font color=#FF0000>0 = </font>"); QString msg = (rc ? QStringLiteral("<font color=#00FF00>1 = </font>") : QStringLiteral("<font color=#FF0000>0 = </font>"));
msg += FilterLog::recode(asString()); msg += FilterLog::recode(asString());
// only log headers bcause messages and bodies can be pretty large // only log headers bcause messages and bodies can be pretty large
if (logContents) { if (logContents) {
msg += " (<i>" + FilterLog::recode(msgContents) + "</i>)"; msg += QStringLiteral(" (<i>") + FilterLog::recode(msgContents) + QStringLiteral("</i>)");
} }
FilterLog::instance()->add(msg, FilterLog::RuleResult); FilterLog::instance()->add(msg, FilterLog::RuleResult);
} }
......
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