Commit 59931b91 authored by Ahmad Samir's avatar Ahmad Samir Committed by Daniel Vrátil
Browse files

Port QRegExp to QRegularExpression

Port QRegExp::exactMatch by using QRegularExpression::anchoredPattern.
parent d1f66f33
Pipeline #29972 passed with stage
in 39 minutes and 29 seconds
......@@ -32,7 +32,7 @@ public:
QStringList mimeTypes;
QStringList capabilities;
QStringList excludeCapabilities;
bool filterAcceptRegExp(const QModelIndex &index, const QRegExp &filterRegExpStr);
bool filterAcceptRegExp(const QModelIndex &index, const QRegularExpression &filterRegExpStr);
};
AgentFilterProxyModel::AgentFilterProxyModel(QObject *parent)
......@@ -73,10 +73,10 @@ void AgentFilterProxyModel::clearFilters()
invalidateFilter();
}
bool AgentFilterProxyModel::Private::filterAcceptRegExp(const QModelIndex &index, const QRegExp &filterRegExpStr)
bool AgentFilterProxyModel::Private::filterAcceptRegExp(const QModelIndex &index, const QRegularExpression &filterRegExpStr)
{
// First see if the name matches a set regexp filter.
if (!filterRegExpStr.isEmpty()) {
if (!filterRegExpStr.pattern().isEmpty()) {
return index.data(AgentTypeModel::IdentifierRole).toString().contains(filterRegExpStr)
|| index.data().toString().contains(filterRegExpStr);
}
......@@ -145,5 +145,5 @@ bool AgentFilterProxyModel::filterAcceptsRow(int row, const QModelIndex & /*sour
}
}
return d->filterAcceptRegExp(index, filterRegExp());
return d->filterAcceptRegExp(index, filterRegularExpression());
}
......@@ -20,6 +20,7 @@
#include <QStringList>
#include <QMimeDatabase>
#include <QMimeType>
#include <QRegularExpression>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/topological_sort.hpp>
......@@ -217,14 +218,15 @@ public:
qCDebug(AKONADICORE_LOG) << "ItemSerializerPluginLoader: "
<< "found" << names.size() << "plugins.";
QMap<QString, MimeTypeEntry> map;
QRegExp rx(QStringLiteral("(.+)@(.+)"));
QRegularExpression rx(QRegularExpression::anchoredPattern(QStringLiteral("(.+)@(.+)")));
QMimeDatabase mimeDb;
for (const QString &name : names) {
if (rx.exactMatch(name)) {
const QMimeType mime = mimeDb.mimeTypeForName(rx.cap(1));
QRegularExpressionMatch match = rx.match(name);
if (match.hasMatch()) {
const QMimeType mime = mimeDb.mimeTypeForName(match.captured(1));
if (mime.isValid()) {
const QString mimeType = mime.name();
const QByteArray classType = rx.cap(2).toLatin1();
const QByteArray classType = match.captured(2).toLatin1();
QMap<QString, MimeTypeEntry>::iterator it = map.find(mimeType);
if (it == map.end()) {
it = map.insert(mimeType, MimeTypeEntry(mimeType));
......
......@@ -10,7 +10,7 @@
#include <QDebug>
#include <QMetaObject>
#include <QRegExp>
#include <QRegularExpression>
#include <QSettings>
#include <QLocalSocket>
#include <QTcpSocket>
......@@ -75,9 +75,10 @@ void DBusBridgeConnection::connectLocal()
// TODO: support for !Linux
#ifdef Q_OS_UNIX
const QByteArray sessionBusAddress = qgetenv("DBUS_SESSION_BUS_ADDRESS");
QRegExp rx(QStringLiteral("=(.*)[,$]"));
if (rx.indexIn(QString::fromLatin1(sessionBusAddress)) >= 0) {
const QString dbusPath = rx.cap(1);
const QRegularExpression rx(QStringLiteral("=(.*)[,$]"));
QRegularExpressionMatch match = rx.match(QString::fromLatin1(sessionBusAddress));
if (match.hasMatch()) {
const QString dbusPath = match.captured(1);
qDebug() << dbusPath;
if (sessionBusAddress.contains("abstract")) {
const int fd = socket(PF_UNIX, SOCK_STREAM, 0);
......
......@@ -45,6 +45,7 @@
#include <QItemSelectionModel>
#include <QPointer>
#include <QInputDialog>
#include <QRegularExpression>
using namespace Akonadi;
......@@ -1536,7 +1537,7 @@ public:
}
const QString str = text.subs(count).toString();
const int argCount = str.count(QRegExp(QStringLiteral("%[0-9]")));
const int argCount = str.count(QRegularExpression(QStringLiteral("%[0-9]")));
if (argCount > 0) {
return text.subs(count).subs(value).toString();
} else {
......
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