Commit 62adba9b authored by Ahmad Samir's avatar Ahmad Samir Committed by Volker Krause

Port QRegExp to QRegularExpression, first pass

parent 85f969cf
Pipeline #30707 failed with stage
in 38 minutes and 26 seconds
......@@ -15,7 +15,7 @@ extern "C" {
#include <QCoreApplication>
#include <QByteArray>
#include <QRegExp>
#include <QRegularExpression>
#include "pop3_debug.h"
#include <KLocalizedString>
......@@ -654,7 +654,8 @@ bool POP3Protocol::pop3_open()
// Does the server support APOP?
//QString apop_cmd;
QRegExp re(QStringLiteral("<[A-Za-z0-9\\.\\-_]+@[A-Za-z0-9\\.\\-_]+>$"), Qt::CaseInsensitive);
const QRegularExpression re(QStringLiteral("<[A-Za-z0-9\\.\\-_]+@[A-Za-z0-9\\.\\-_]+>$"),
QRegularExpression::CaseInsensitiveOption);
qCDebug(POP3_LOG) << "greeting: " << greeting;
int apop_pos = greeting.indexOf(re);
......
......@@ -26,7 +26,7 @@
#include <QFile>
#include <QFileInfo>
#include <QPointer>
#include <QRegExp>
#include <QRegularExpression>
#include <QUrl>
#include <QDBusConnection>
#include <QHBoxLayout>
......@@ -517,7 +517,7 @@ void Settings::updateToV2()
QString urlConfigStr = urls.at(0);
UrlConfiguration urlConfig(urlConfigStr);
QRegExp regexp(QLatin1Char('^') + urlConfig.mUser);
const QRegularExpression regexp(QStringLiteral("^") + urlConfig.mUser);
QMutableStringListIterator it(urls);
while (it.hasNext()) {
......
......@@ -24,7 +24,7 @@
#include <QLabel>
#include <QPushButton>
#include <QRadioButton>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
enum GroupwareServers {
Citadel,
......@@ -65,7 +65,7 @@ static QString settingsToUrl(const QWizard *wizard, const QString &protocol)
QString username = wizard->field(QStringLiteral("credentialsUserName")).toString();
QString localPart(username);
localPart.remove(QRegExp(QLatin1String("@.*$")));
localPart.remove(QRegularExpression(QStringLiteral("@.*$")));
pathPattern.replace(QLatin1String("$user$"), username);
pathPattern.replace(QLatin1String("$localpart$"), localPart);
QString providerName;
......@@ -377,10 +377,10 @@ ConnectionPage::ConnectionPage(QWidget *parent)
setSubTitle(i18n("Enter the connection information for the groupware server"));
mLayout = new QFormLayout(this);
QRegExp hostnameRegexp(QStringLiteral("^[a-z0-9][.a-z0-9-]*[a-z0-9](?::[0-9]+)?$"));
const QRegularExpression hostnameRegexp(QStringLiteral("^[a-z0-9][.a-z0-9-]*[a-z0-9](?::[0-9]+)?$"));
mHost = new QLineEdit;
registerField(QStringLiteral("connectionHost*"), mHost);
mHost->setValidator(new QRegExpValidator(hostnameRegexp, this));
mHost->setValidator(new QRegularExpressionValidator(hostnameRegexp, this));
mLayout->addRow(i18n("Host"), mHost);
mPath = new QLineEdit;
......
......@@ -9,6 +9,7 @@
#include <QUuid>
#include <QFile>
#include <QRegularExpression>
#include <kolabevent.h>
#include <kmime/kmime_message.h>
......@@ -84,36 +85,46 @@ KMime::Message::Ptr readMimeFile(const QString &fileName, bool &ok)
void normalizeMimemessage(QString &content)
{
content.replace(QRegExp(QStringLiteral("\\bLibkolab-\\d.\\d.\\d\\b"), Qt::CaseSensitive), QStringLiteral("Libkolab-x.x.x"));
content.replace(QRegExp(QStringLiteral("\\bLibkolabxml-\\d.\\d.\\d\\b"), Qt::CaseSensitive), QStringLiteral("Libkolabxml-x.x.x"));
content.replace(QRegExp(QStringLiteral("\\bLibkolab-\\d.\\d\\b"), Qt::CaseSensitive), QStringLiteral("Libkolab-x.x.x"));
content.replace(QRegExp(QStringLiteral("\\bkdepim-runtime-\\d.\\d\\b"), Qt::CaseSensitive), QStringLiteral("Libkolab-x.x.x"));
content.replace(QRegExp(QStringLiteral("\\bLibkolabxml-\\d.\\d\\b"), Qt::CaseSensitive), QStringLiteral("Libkolabxml-x.x.x"));
content.replace(QRegExp(QStringLiteral("<uri>cid:*@kolab.resource.akonadi</uri>"), Qt::CaseSensitive, QRegExp::Wildcard), QStringLiteral("<uri>cid:id@kolab.resource.akonadi</uri>"));
content.replace(QRegExp(QStringLiteral("Content-ID: <*@kolab.resource.akonadi>"), Qt::CaseSensitive, QRegExp::Wildcard), QStringLiteral("Content-ID: <id@kolab.resource.akonadi>"));
content.replace(QRegExp(QStringLiteral("<uri>mailto:*</uri>"), Qt::CaseSensitive, QRegExp::Wildcard), QStringLiteral("<uri>mailto:</uri>"));
content.replace(QRegExp(QStringLiteral("<cal-address>mailto:*</cal-address>"), Qt::CaseSensitive, QRegExp::Wildcard), QStringLiteral("<cal-address>mailto:</cal-address>"));
content.replace(QRegExp(QStringLiteral("<uri>data:*</uri>"), Qt::CaseSensitive, QRegExp::Wildcard), QStringLiteral("<uri>data:</uri>"));
content.replace(QRegExp(QStringLiteral("<last-modification-date>*</last-modification-date>"), Qt::CaseSensitive, QRegExp::Wildcard),
content.replace(QRegularExpression(QStringLiteral("\\bLibkolab-\\d.\\d.\\d\\b")), QStringLiteral("Libkolab-x.x.x"));
content.replace(QRegularExpression(QStringLiteral("\\bLibkolabxml-\\d.\\d.\\d\\b")), QStringLiteral("Libkolabxml-x.x.x"));
content.replace(QRegularExpression(QStringLiteral("\\bLibkolab-\\d.\\d\\b")), QStringLiteral("Libkolab-x.x.x"));
content.replace(QRegularExpression(QStringLiteral("\\bkdepim-runtime-\\d.\\d\\b")), QStringLiteral("Libkolab-x.x.x"));
content.replace(QRegularExpression(QStringLiteral("\\bLibkolabxml-\\d.\\d\\b")), QStringLiteral("Libkolabxml-x.x.x"));
content.replace(QRegularExpression(QStringLiteral("<uri>cid:.*@kolab.resource.akonadi</uri>")), QStringLiteral("<uri>cid:id@kolab.resource.akonadi</uri>"));
content.replace(QRegularExpression(QStringLiteral("Content-ID: <.*@kolab.resource.akonadi>")), QStringLiteral("Content-ID: <id@kolab.resource.akonadi>"));
content.replace(QRegularExpression(QStringLiteral("<uri>mailto:.*</uri>")), QStringLiteral("<uri>mailto:</uri>"));
content.replace(QRegularExpression(QStringLiteral("<cal-address>mailto:.*</cal-address>")), QStringLiteral("<cal-address>mailto:</cal-address>"));
content.replace(QRegularExpression(QStringLiteral("<uri>data:.*</uri>")), QStringLiteral("<uri>data:</uri>"));
content.replace(QRegularExpression(QStringLiteral("<last-modification-date>.*</last-modification-date>")),
QStringLiteral("<last-modification-date></last-modification-date>"));
//We no longer support pobox, so remove pobox lines
content.replace(QRegExp(QStringLiteral("<pobox>*</pobox>"), Qt::CaseSensitive, QRegExp::Wildcard), QLatin1String(""));
content.replace(QRegExp(QStringLiteral("<timestamp>*</timestamp>"), Qt::CaseSensitive, QRegExp::Wildcard), QStringLiteral("<timestamp></timestamp>"));
content.replace(QRegExp(QStringLiteral("<x-kolab-version>*</x-kolab-version>"), Qt::CaseSensitive, QRegExp::Wildcard), QStringLiteral("<x-kolab-version></x-kolab-version>"));
content.remove(QRegularExpression(QStringLiteral("<pobox>.*</pobox>")));
content.replace(QRegularExpression(QStringLiteral("<timestamp>.*</timestamp>")), QStringLiteral("<timestamp></timestamp>"));
// DotMatchesEverythingOption because <x-koblab-version> spans multiple lines
content.replace(QRegularExpression(QStringLiteral("<x-kolab-version>.*</x-kolab-version>"), QRegularExpression::DotMatchesEverythingOption),
QStringLiteral("<x-kolab-version></x-kolab-version>"));
content.replace(QRegularExpression(QStringLiteral("--nextPart\\S*")), QStringLiteral("--part"));
content.replace(QRegularExpression(QStringLiteral("\\bboundary=\"nextPart[^\\n]*")), QStringLiteral("boundary"));
content.replace(QRegExp(QStringLiteral("--nextPart\\S*"), Qt::CaseSensitive), QStringLiteral("--part"));
content.replace(QRegExp(QStringLiteral("\\bboundary=\"nextPart[^\\n]*"), Qt::CaseSensitive), QStringLiteral("boundary"));
content.replace(QRegExp(QStringLiteral("Date[^\\n]*"), Qt::CaseSensitive), QStringLiteral("Date"));
content.replace(QRegularExpression(QStringLiteral("Date[^\\n]*")), QStringLiteral("Date"));
//The sort order of the attributes in kolabV2 is unpredictable
content.replace(QRegExp(QStringLiteral("<x-custom*/>"), Qt::CaseSensitive, QRegExp::Wildcard), QStringLiteral("<x-custom/>"));
content.replace(QRegularExpression(QStringLiteral("<x-custom.*/>")), QStringLiteral("<x-custom/>"));
//quoted-printable encoding changes where the linebreaks are every now and then (an all are valid), so we remove the linebreaks
content.replace(QRegExp(QStringLiteral("=\\n"), Qt::CaseSensitive), QLatin1String(""));
content.remove(QLatin1String("=\n"));
}
QString normalizeVCardMessage(QString content)
{
//The encoding changes every now and then
content.replace(QRegExp(QStringLiteral("ENCODING=b;TYPE=png:*"), Qt::CaseSensitive, QRegExp::Wildcard), QStringLiteral("ENCODING=b;TYPE=png:picturedata"));
content.replace(QRegularExpression(QStringLiteral("ENCODING=b;TYPE=png:.*")), QStringLiteral("ENCODING=b;TYPE=png:picturedata"));
return content;
}
......
......@@ -17,6 +17,7 @@
#include <QBuffer>
#include <QImage>
#include <QDomElement>
#include <QRegularExpression>
using namespace OXA;
......@@ -232,7 +233,7 @@ void OXA::ContactUtils::parseContact(const QDomElement &propElement, Object &obj
} else if (tagName == QLatin1String("pager")) {
contact.insertPhoneNumber(KContacts::PhoneNumber(text, KContacts::PhoneNumber::Pager));
} else if (tagName == QLatin1String("categories")) {
contact.setCategories(text.split(QRegExp(QLatin1String(",\\s*"))));
contact.setCategories(text.split(QRegularExpression(QStringLiteral(",\\s*"))));
}
element = element.nextSiblingElement();
......
......@@ -20,6 +20,7 @@
#include <QBitArray>
#include <QDebug>
#include <QRegularExpression>
using namespace OXA;
......@@ -114,7 +115,7 @@ static void parseIncidenceAttribute(const QDomElement &element, const KCalendarC
incidence->setSecrecy(KCalendarCore::Incidence::SecrecyPublic);
}
} else if (tagName == QLatin1String("categories")) {
incidence->setCategories(text.split(QRegExp(QLatin1String(",\\s*"))));
incidence->setCategories(text.split(QRegularExpression(QStringLiteral(",\\s*"))));
}
}
......
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