diff --git a/core/KGpgGroupNode.cpp b/core/KGpgGroupNode.cpp --- a/core/KGpgGroupNode.cpp +++ b/core/KGpgGroupNode.cpp @@ -29,6 +29,7 @@ #include +#include #include #include @@ -50,7 +51,7 @@ */ int findGroupEntry(QFile &conffile, QTextStream &stream, QStringList &lines); - static const QRegExp &groupPattern(); + static const QRegularExpression &groupPattern(); static const QString &groupTag(); }; @@ -79,7 +80,7 @@ i++; QString parsedLine = rawLine.simplified().section(QLatin1Char('#'), 0, 0); - if (groupPattern().exactMatch(parsedLine)) { + if (groupPattern().match(parsedLine).hasMatch()) { // remove "group " parsedLine.remove(0, 6); if (parsedLine.startsWith(m_name)) { @@ -102,10 +103,10 @@ return index; } -const QRegExp & +const QRegularExpression & KGpgGroupNodePrivate::groupPattern() { - static const QRegExp groupre(QLatin1String("^group [^ ]+ ?= ?([0-9a-fA-F]{8,} ?)*$")); + static const QRegularExpression groupre(QStringLiteral("^group [^ ]+ ?= ?([0-9a-fA-F]{8,} ?)*$")); return groupre; } diff --git a/keyservers.cpp b/keyservers.cpp --- a/keyservers.cpp +++ b/keyservers.cpp @@ -32,6 +32,7 @@ #include #include #include +#include KeyServer::KeyServer(QWidget *parent, KGpgItemModel *model, const bool autoclose) : QDialog(parent), @@ -197,7 +198,7 @@ return; m_resultmodel.resetSourceModel(); - m_resultmodel.setFilterRegExp(QRegExp()); + m_resultmodel.setFilterRegularExpression(QRegularExpression()); m_resultmodel.setFilterByValidity(true); m_dialogserver = new QDialog(this); @@ -340,7 +341,7 @@ { QStringList serverList(KGpgSettings::keyServers()); // From kgpg config if (!serverList.isEmpty()) { - serverList.replaceInStrings(QRegExp(QLatin1String(" .*")), QString()); // Remove kde 3.5 (Default) tag. + serverList.replaceInStrings(QRegularExpression(QStringLiteral(" .*")), QString()); // Remove kde 3.5 (Default) tag. const QString defaultServer(serverList.takeFirst()); std::sort(serverList.begin(), serverList.end()); serverList.prepend(defaultServer); @@ -368,7 +369,7 @@ void KeyServer::slotSetFilterString(const QString &expression) { - m_resultmodel.setFilterRegExp(QRegExp(expression, Qt::CaseInsensitive, QRegExp::RegExp2)); + m_resultmodel.setFilterRegularExpression(QRegularExpression(expression, QRegularExpression::CaseInsensitiveOption)); slotUpdateLabelOnFilterChange(); } diff --git a/keysmanager.cpp b/keysmanager.cpp --- a/keysmanager.cpp +++ b/keysmanager.cpp @@ -106,6 +106,7 @@ #include #include #include +#include #include #include #include @@ -1439,7 +1440,7 @@ sname.prepend(QDir::homePath() + QLatin1Char( '/' )); QStringList serverList(KGpgSettings::keyServers()); - serverList.replaceInStrings(QRegExp(QLatin1String(" .*")), QString()); // Remove kde 3.5 (Default) tag. + serverList.replaceInStrings(QRegularExpression(QStringLiteral(" .*")), QString()); // Remove kde 3.5 (Default) tag. if (!serverList.isEmpty()) { QString defaultServer = serverList.takeFirst(); std::sort(serverList.begin(), serverList.end()); diff --git a/kgpgoptions.cpp b/kgpgoptions.cpp --- a/kgpgoptions.cpp +++ b/kgpgoptions.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include using namespace KgpgCore; @@ -81,7 +82,7 @@ // Remove everything after a whitespace. This will normally be // ' (Default)' from KDE 3.x.x - serverList.replaceInStrings(QRegExp( QLatin1String( " .*") ), QString() ); + serverList.replaceInStrings(QRegularExpression(QStringLiteral(" .*")), QString()); m_serverModel->setStringList(serverList); // if the server from GnuPG config is set and is not in the list of servers put it there @@ -291,10 +292,10 @@ if (!fileEncryptionKey.isEmpty()) { int idpos = m_page1->file_key->findText(fileEncryptionKey); if (idpos == -1) { - idpos = fileEncryptionKey.indexOf(QRegExp( QLatin1String( "([0-9A-Fa-F]{8})+" ))); + idpos = fileEncryptionKey.indexOf(QRegularExpression(QStringLiteral("([0-9A-Fa-f]{8})+"))); if (idpos >= 0) { QString fileId = fileEncryptionKey.mid(idpos); - idpos = fileId.indexOf(QRegExp( QLatin1String( "[^a-fA-F0-9]" ))); + idpos = fileId.indexOf(QRegularExpression(QStringLiteral("[^a-fA-F0-9]"))); if (idpos >= 0) { fileId.truncate(idpos); fileId.chop(fileId.length() % 8); diff --git a/model/kgpgsearchresultmodel.cpp b/model/kgpgsearchresultmodel.cpp --- a/model/kgpgsearchresultmodel.cpp +++ b/model/kgpgsearchresultmodel.cpp @@ -19,6 +19,7 @@ #include +#include #include #include #include @@ -97,11 +98,12 @@ SearchResult::addUid(const QString &id) { Q_ASSERT(m_emails.count() == m_names.count()); - QRegExp hasmail( QLatin1String( "(.*) <(.*)>" )); + const QRegularExpression hasmail(QRegularExpression::anchoredPattern(QStringLiteral("(.*) <(.*)>"))); - if (hasmail.exactMatch(id)) { - m_names.append(hasmail.capturedTexts().at(1)); - m_emails.append(hasmail.capturedTexts().at(2)); + const QRegularExpressionMatch match = hasmail.match(id); + if (match.hasMatch()) { + m_names.append(match.captured(1)); + m_emails.append(match.captured(2)); } else { m_names.append(id); m_emails.append(QString()); @@ -178,14 +180,15 @@ return line; QByteArray tmp(line.toLatin1()); - const QRegExp hex( QLatin1String( "[A-F0-9]{2}" )); // URL-encoding uses only uppercase + const QRegularExpression hex( + QRegularExpression::anchoredPattern(QStringLiteral("[A-F0-9]{2}"))); // URL-encoding uses only uppercase int pos = -1; // avoid error if '%' is URL-encoded while ((pos = tmp.indexOf("%", pos + 1)) >= 0) { const QByteArray hexnum(tmp.mid(pos + 1, 2)); // the input is not properly URL-encoded, so assume it does not need to be decoded at all - if (!hex.exactMatch(QLatin1String( hexnum ))) + if (!hex.match(QLatin1String(hexnum)).hasMatch()) return line; char n[2]; diff --git a/model/selectkeyproxymodel.cpp b/model/selectkeyproxymodel.cpp --- a/model/selectkeyproxymodel.cpp +++ b/model/selectkeyproxymodel.cpp @@ -22,6 +22,7 @@ #include "core/kgpgkey.h" #include +#include #include @@ -63,8 +64,8 @@ return false; // there is probably a better place to do this - QRegExp rx = filterRegExp(); - rx.setCaseSensitivity(Qt::CaseInsensitive); + QRegularExpression rx = filterRegularExpression(); + rx.setPatternOptions(rx.patternOptions() | QRegularExpression::CaseInsensitiveOption); if (l->getName().contains(rx)) return true; diff --git a/transactions/kgpgtextorfiletransaction.cpp b/transactions/kgpgtextorfiletransaction.cpp --- a/transactions/kgpgtextorfiletransaction.cpp +++ b/transactions/kgpgtextorfiletransaction.cpp @@ -19,7 +19,7 @@ #include -#include +#include #include KGpgTextOrFileTransaction::KGpgTextOrFileTransaction(QObject *parent, const QString &text, const bool allowChaining) @@ -45,7 +45,7 @@ m_text = text; cleanUrls(); - int begin = text.indexOf(QRegExp(QLatin1String("^(.*\n)?-----BEGIN PGP [A-Z ]*-----\r?\n"))); + int begin = text.indexOf(QRegularExpression(QStringLiteral("^(.*\n)?-----BEGIN PGP [A-Z ]*-----\r?\n"))); if (begin < 0) return; diff --git a/transactions/kgpgverify.cpp b/transactions/kgpgverify.cpp --- a/transactions/kgpgverify.cpp +++ b/transactions/kgpgverify.cpp @@ -18,6 +18,7 @@ #include "model/kgpgitemmodel.h" #include +#include #include @@ -106,7 +107,7 @@ // newer versions of GnuPG emit both VALIDSIG and GOODSIG // for a good signature. Since VALIDSIG has more information // we use that. - const QRegExp validsig(QLatin1String("^\\[GNUPG:\\] VALIDSIG([ ]+[^ ]+){10,}.*$")); + const QRegularExpression validsig(QStringLiteral("^\\[GNUPG:\\] VALIDSIG([ ]+[^ ]+){10,}.*$")); const bool useGoodSig = (model == nullptr) || (log.indexOf(validsig) == -1); QString sigtime; // timestamp of signature creation