From 66357f09745503b99a9832beb6ea18082fdff792 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Fri, 5 May 2017 22:21:18 +0200 Subject: [PATCH] Start to make it compile with QT_NO_CAST_FROM_BYTEARRAY --- .../filteractions/filteractionaddheader.cpp | 2 +- src/search/searchpattern.cpp | 4 +- src/search/searchrule/searchrule.cpp | 4 +- src/search/searchrule/searchrulenumerical.cpp | 8 +- src/search/searchrule/searchrulestring.cpp | 76 +++++++++---------- src/snippets/snippetsmanager.cpp | 4 +- 6 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/filter/filteractions/filteractionaddheader.cpp b/src/filter/filteractions/filteractionaddheader.cpp index 35065ca..4ad9562 100644 --- a/src/filter/filteractions/filteractionaddheader.cpp +++ b/src/filter/filteractions/filteractionaddheader.cpp @@ -59,7 +59,7 @@ FilterAction::ReturnCode FilterActionAddHeader::process(ItemContext &context, bo KMime::Headers::Base *header = KMime::Headers::createHeader(mParameter.toLatin1()); if (!header) { - header = new KMime::Headers::Generic(mParameter.toLatin1()); + header = new KMime::Headers::Generic(mParameter.toLatin1().constData()); } header->fromUnicodeString(mValue, "utf-8"); diff --git a/src/search/searchpattern.cpp b/src/search/searchpattern.cpp index 1ad4f3b..6441a95 100644 --- a/src/search/searchpattern.cpp +++ b/src/search/searchpattern.cpp @@ -178,7 +178,7 @@ void SearchPattern::importLegacyConfig(const KConfigGroup &config) SearchRule::Ptr rule = SearchRule::createInstance( config.readEntry("fieldA").toLatin1(), - config.readEntry("funcA").toLatin1(), + config.readEntry("funcA").toLatin1().constData(), config.readEntry("contentsA")); if (rule->isEmpty()) { @@ -196,7 +196,7 @@ void SearchPattern::importLegacyConfig(const KConfigGroup &config) rule = SearchRule::createInstance( config.readEntry("fieldB").toLatin1(), - config.readEntry("funcB").toLatin1(), + config.readEntry("funcB").toLatin1().constData(), config.readEntry("contentsB")); if (rule->isEmpty()) { diff --git a/src/search/searchrule/searchrule.cpp b/src/search/searchrule/searchrule.cpp index ed86038..b5d84f9 100644 --- a/src/search/searchrule/searchrule.cpp +++ b/src/search/searchrule/searchrule.cpp @@ -119,7 +119,7 @@ SearchRule::Ptr SearchRule::createInstanceFromConfig(const KConfigGroup &config, static const QString contents = QStringLiteral("contents"); const QByteArray &field2 = config.readEntry(field + cIdx, QString()).toLatin1(); - Function func2 = configValueToFunc(config.readEntry(func + cIdx, QString()).toLatin1()); + Function func2 = configValueToFunc(config.readEntry(func + cIdx, QString()).toLatin1().constData()); const QString &contents2 = config.readEntry(contents + cIdx, QString()); if (field2 == "") { // backwards compat @@ -135,7 +135,7 @@ SearchRule::Ptr SearchRule::createInstance(QDataStream &s) s >> field; QString function; s >> function; - Function func = configValueToFunc(function.toUtf8()); + Function func = configValueToFunc(function.toUtf8().constData()); QString contents; s >> contents; return createInstance(field, func, contents); diff --git a/src/search/searchrule/searchrulenumerical.cpp b/src/search/searchrule/searchrulenumerical.cpp index 4929cc1..e1b82c4 100644 --- a/src/search/searchrule/searchrulenumerical.cpp +++ b/src/search/searchrule/searchrulenumerical.cpp @@ -58,11 +58,11 @@ bool SearchRuleNumerical::matches(const Akonadi::Item &item) const qint64 numericalMsgContents = 0; qint64 numericalValue = 0; - if (qstricmp(field(), "") == 0) { + if (qstricmp(field().constData(), "") == 0) { numericalMsgContents = item.size(); numericalValue = contents().toLongLong(); msgContents.setNum(numericalMsgContents); - } else if (qstricmp(field(), "") == 0) { + } else if (qstricmp(field().constData(), "") == 0) { QDateTime msgDateTime = msg->date()->dateTime(); numericalMsgContents = msgDateTime.daysTo(QDateTime::currentDateTime()); numericalValue = contents().toInt(); @@ -141,11 +141,11 @@ void SearchRuleNumerical::addQueryTerms(Akonadi::SearchTerm &groupTerm, bool &em { using namespace Akonadi; emptyIsNotAnError = false; - if (qstricmp(field(), "") == 0) { + if (qstricmp(field().constData(), "") == 0) { EmailSearchTerm term(EmailSearchTerm::ByteSize, contents().toInt(), akonadiComparator()); term.setIsNegated(isNegated()); groupTerm.addSubTerm(term); - } else if (qstricmp(field(), "") == 0) { + } else if (qstricmp(field().constData(), "") == 0) { QDate date(QDate::currentDate()); date = date.addDays(contents().toInt()); EmailSearchTerm term(EmailSearchTerm::HeaderOnlyDate, date, akonadiComparator()); diff --git a/src/search/searchrule/searchrulestring.cpp b/src/search/searchrule/searchrulestring.cpp index 6277806..bf46a62 100644 --- a/src/search/searchrule/searchrulestring.cpp +++ b/src/search/searchrule/searchrulestring.cpp @@ -73,23 +73,23 @@ SearchRule::RequiredPart SearchRuleString::requiredPart() const { const QByteArray f = field(); SearchRule::RequiredPart part = Header; - if (qstricmp(f, "") == 0 || - qstricmp(f, "") == 0 || - qstricmp(f, "") == 0 || - qstricmp(f, "subject") == 0 || - qstricmp(f, "from") == 0 || - qstricmp(f, "sender") == 0 || - qstricmp(f, "reply-to") == 0 || - qstricmp(f, "to") == 0 || - qstricmp(f, "cc") == 0 || - qstricmp(f, "bcc") == 0 || - qstricmp(f, "in-reply-to") == 0 || - qstricmp(f, "message-id") == 0 || - qstricmp(f, "references") == 0) { + if (qstricmp(f.constData(), "") == 0 || + qstricmp(f.constData(), "") == 0 || + qstricmp(f.constData(), "") == 0 || + qstricmp(f.constData(), "subject") == 0 || + qstricmp(f.constData(), "from") == 0 || + qstricmp(f.constData(), "sender") == 0 || + qstricmp(f.constData(), "reply-to") == 0 || + qstricmp(f.constData(), "to") == 0 || + qstricmp(f.constData(), "cc") == 0 || + qstricmp(f.constData(), "bcc") == 0 || + qstricmp(f.constData(), "in-reply-to") == 0 || + qstricmp(f.constData(), "message-id") == 0 || + qstricmp(f.constData(), "references") == 0) { // these fields are directly provided by KMime::Message, no need to fetch the whole Header part part = Envelope; - } else if (qstricmp(f, "") == 0 || - qstricmp(f, "") == 0) { + } else if (qstricmp(f.constData(), "") == 0 || + qstricmp(f.constData(), "") == 0) { part = CompleteMessage; } @@ -117,16 +117,16 @@ bool SearchRuleString::matches(const Akonadi::Item &item) const // Overwrite the value for complete messages and all headers! bool logContents = true; - if (qstricmp(field(), "") == 0) { + if (qstricmp(field().constData(), "") == 0) { msgContents = msg->encodedContent(); logContents = false; - } else if (qstricmp(field(), "") == 0) { + } else if (qstricmp(field().constData(), "") == 0) { msgContents = msg->body(); logContents = false; - } else if (qstricmp(field(), "") == 0) { + } else if (qstricmp(field().constData(), "") == 0) { msgContents = msg->head(); logContents = false; - } else if (qstricmp(field(), "") == 0) { + } else if (qstricmp(field().constData(), "") == 0) { // (mmutz 2001-11-05) hack to fix " !contains foo" to // meet user's expectations. See FAQ entry in KDE 2.2.2's KMail // handbook @@ -141,7 +141,7 @@ bool SearchRuleString::matches(const Akonadi::Item &item) const msgContents = msg->to()->asUnicodeString(); msgContents += ", " + msg->cc()->asUnicodeString(); msgContents += ", " + msg->bcc()->asUnicodeString(); - } else if (qstricmp(field(), "") == 0) { + } else if (qstricmp(field().constData(), "") == 0) { //port? // const Nepomuk2::Resource res( item.url() ); // foreach ( const Nepomuk2::Tag &tag, res.tags() ) { @@ -152,7 +152,7 @@ bool SearchRuleString::matches(const Akonadi::Item &item) const // make sure to treat messages with multiple header lines for // the same header correctly msgContents = ""; - if (auto hrd = msg->headerByType(field())) { + if (auto hrd = msg->headerByType(field().constData())) { msgContents = hrd->asUnicodeString(); } } @@ -161,7 +161,7 @@ bool SearchRuleString::matches(const Akonadi::Item &item) const function() == FuncIsNotInAddressbook) { // I think only the "from"-field makes sense. msgContents = ""; - if (auto hrd = msg->headerByType(field())) { + if (auto hrd = msg->headerByType(field().constData())) { msgContents = hrd->asUnicodeString(); } @@ -195,43 +195,43 @@ void SearchRuleString::addQueryTerms(Akonadi::SearchTerm &groupTerm, bool &empty using namespace Akonadi; emptyIsNotAnError = false; SearchTerm termGroup(SearchTerm::RelOr); - if (qstricmp(field(), "subject") == 0) { + if (qstricmp(field().constData(), "subject") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::Subject, contents(), akonadiComparator())); - } else if (qstricmp(field(), "reply-to") == 0) { + } else if (qstricmp(field().constData(), "reply-to") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderReplyTo, contents(), akonadiComparator())); - } else if (qstricmp(field(), "") == 0) { + } else if (qstricmp(field().constData(), "") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::Message, contents(), akonadiComparator())); } else if (field() == "") { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::Body, contents(), akonadiComparator())); termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::Attachment, contents(), akonadiComparator())); - } else if (qstricmp(field(), "") == 0) { + } else if (qstricmp(field().constData(), "") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderTo, contents(), akonadiComparator())); termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderCC, contents(), akonadiComparator())); termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderBCC, contents(), akonadiComparator())); - } else if (qstricmp(field(), "") == 0) { + } else if (qstricmp(field().constData(), "") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::Headers, contents(), akonadiComparator())); termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::Subject, contents(), akonadiComparator())); - } else if (qstricmp(field(), "to") == 0) { + } else if (qstricmp(field().constData(), "to") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderTo, contents(), akonadiComparator())); - } else if (qstricmp(field(), "cc") == 0) { + } else if (qstricmp(field().constData(), "cc") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderCC, contents(), akonadiComparator())); - } else if (qstricmp(field(), "bcc") == 0) { + } else if (qstricmp(field().constData(), "bcc") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderBCC, contents(), akonadiComparator())); - } else if (qstricmp(field(), "from") == 0) { + } else if (qstricmp(field().constData(), "from") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderFrom, contents(), akonadiComparator())); - } else if (qstricmp(field(), "list-id") == 0) { + } else if (qstricmp(field().constData(), "list-id") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderListId, contents(), akonadiComparator())); - } else if (qstricmp(field(), "resent-from") == 0) { + } else if (qstricmp(field().constData(), "resent-from") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderResentFrom, contents(), akonadiComparator())); - } else if (qstricmp(field(), "x-loop") == 0) { + } else if (qstricmp(field().constData(), "x-loop") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderXLoop, contents(), akonadiComparator())); - } else if (qstricmp(field(), "x-mailing-list") == 0) { + } else if (qstricmp(field().constData(), "x-mailing-list") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderXMailingList, contents(), akonadiComparator())); - } else if (qstricmp(field(), "x-spam-flag") == 0) { + } else if (qstricmp(field().constData(), "x-spam-flag") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderXSpamFlag, contents(), akonadiComparator())); - } else if (qstricmp(field(), "organization") == 0) { + } else if (qstricmp(field().constData(), "organization") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::HeaderOrganization, contents(), akonadiComparator())); - } else if (qstricmp(field(), "") == 0) { + } else if (qstricmp(field().constData(), "") == 0) { termGroup.addSubTerm(EmailSearchTerm(EmailSearchTerm::MessageTag, contents(), akonadiComparator())); } diff --git a/src/snippets/snippetsmanager.cpp b/src/snippets/snippetsmanager.cpp index 58fbe93..8daacdd 100644 --- a/src/snippets/snippetsmanager.cpp +++ b/src/snippets/snippetsmanager.cpp @@ -366,7 +366,7 @@ void SnippetsManager::Private::insertSelectedSnippet() } const QString text = replaceVariables(index.data(SnippetsModel::TextRole).toString()); - QMetaObject::invokeMethod(mEditor, mEditorInsertMethod, Qt::DirectConnection, + QMetaObject::invokeMethod(mEditor, mEditorInsertMethod.constData(), Qt::DirectConnection, Q_ARG(QString, text)); } @@ -382,7 +382,7 @@ void SnippetsManager::Private::insertActionSnippet() } const QString text = replaceVariables(action->property("snippetText").toString()); - QMetaObject::invokeMethod(mEditor, mEditorInsertMethod, Qt::DirectConnection, + QMetaObject::invokeMethod(mEditor, mEditorInsertMethod.constData(), Qt::DirectConnection, Q_ARG(QString, text)); }