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

Use some QStringLiteral

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