Commit f444ebe5 authored by Ahmad Samir's avatar Ahmad Samir

Port some usage of QRegExp to QRegularExpression

Test Plan: make && ctest

Reviewers: #plasma, davidedmundson, apol, broulik

Reviewed By: apol

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D27857
parent 758b237f
......@@ -25,6 +25,7 @@
#include <QClipboard>
#include <QGuiApplication>
#include <QMenu>
#include <QRegularExpression>
ClipboardMenu::ClipboardMenu(QObject *parent) : QObject(parent)
{
......@@ -75,7 +76,7 @@ void ClipboardMenu::setupMenu(QAction *action)
const QDate date = m_currentDate.date();
const QTime time = m_currentDate.time();
const QRegExp rx ("[^0-9:]");
const QRegularExpression rx ("[^0-9:]");
const QChar ws = QLatin1Char(' ');
QString s;
QAction *a;
......@@ -111,7 +112,7 @@ void ClipboardMenu::setupMenu(QAction *action)
a = menu->addAction(s);
a->setData(s);
if (m_secondsIncluded) {
s = date.toString(Qt::SystemLocaleShortDate) + ws + time.toString(Qt::SystemLocaleLongDate).replace(rx, "");
s = date.toString(Qt::SystemLocaleShortDate) + ws + time.toString(Qt::SystemLocaleLongDate).remove(rx);
a = menu->addAction(s);
a->setData(s);
s = date.toString(Qt::SystemLocaleShortDate) + ws + time.toString(Qt::SystemLocaleLongDate);
......@@ -122,7 +123,7 @@ void ClipboardMenu::setupMenu(QAction *action)
a = menu->addAction(s);
a->setData(s);
if (m_secondsIncluded) {
s = date.toString(Qt::ISODate) + ws + time.toString(Qt::SystemLocaleLongDate).replace(rx, "");
s = date.toString(Qt::ISODate) + ws + time.toString(Qt::SystemLocaleLongDate).remove(rx);
a = menu->addAction(s);
a->setData(s);
s = date.toString(Qt::ISODate) + ws + time.toString(Qt::SystemLocaleLongDate);
......
......@@ -37,6 +37,7 @@
#include <QStringList>
#include <QProcess>
#include <QRegularExpression>
KSolidNotify::KSolidNotify(QObject *parent):
QObject(parent)
......@@ -127,9 +128,9 @@ void KSolidNotify::queryBlockingApps(const QString &devicePath)
connect(p, static_cast<void (QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), [=](int,QProcess::ExitStatus) {
QStringList blockApps;
QString out(p->readAll());
const QStringList &pidList = out.split(QRegExp(QStringLiteral("\\s+")), QString::SkipEmptyParts);
const QVector<QStringRef> pidList = out.splitRef(QRegularExpression(QStringLiteral("\\s+")), QString::SkipEmptyParts);
KSysGuard::Processes procs;
Q_FOREACH (const QString &pidStr, pidList) {
for (const QStringRef &pidStr : pidList) {
int pid = pidStr.toInt();
if (!pid) {
continue;
......
......@@ -31,6 +31,7 @@
#include <QJsonObject>
#include <QJsonArray>
#include <QXmlStreamReader>
#include <QRegularExpression>
#include <QTimeZone>
......@@ -825,8 +826,8 @@ void UKMETIon::parseFiveDayForecast(const QString& source, QXmlStreamReader& xml
QString line;
QString period;
QString summary;
QRegExp high(QStringLiteral("Maximum Temperature: (-?\\d+).C"), Qt::CaseInsensitive);
QRegExp low(QStringLiteral("Minimum Temperature: (-?\\d+).C"), Qt::CaseInsensitive);
const QRegularExpression high(QStringLiteral("Maximum Temperature: (-?\\d+).C"), QRegularExpression::CaseInsensitiveOption);
const QRegularExpression low(QStringLiteral("Minimum Temperature: (-?\\d+).C"), QRegularExpression::CaseInsensitiveOption);
while (!xml.atEnd()) {
xml.readNext();
if (xml.name() == QLatin1String("title")) {
......@@ -840,11 +841,12 @@ void UKMETIon::parseFiveDayForecast(const QString& source, QXmlStreamReader& xml
const QString temps = line.section(QLatin1Char(','), 1, 1);
// Sometimes only one of min or max are reported
if (high.indexIn(temps) != -1) {
parseFloat(forecast->tempHigh, high.cap(1));
QRegularExpressionMatch rmatch;
if (temps.contains(high, &rmatch)) {
parseFloat(forecast->tempHigh, rmatch.captured(1));
}
if (low.indexIn(temps) != -1) {
parseFloat(forecast->tempLow, low.cap(1));
if (temps.contains(low, &rmatch)) {
parseFloat(forecast->tempLow, rmatch.captured(1));
}
const QString summaryLC = summary.toLower();
......
......@@ -65,7 +65,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <QFile>
#include <QPushButton>
#include <QRegExp>
#include <QRegularExpression>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QSocketNotifier>
......@@ -668,7 +668,7 @@ KSMServer::KSMServer( const QString& windowManager, InitFlags flags )
qCDebug(KSMSERVER) << fName;
QString display = QString::fromLocal8Bit(::getenv("DISPLAY"));
// strip the screen number from the display
display.remove(QRegExp(QStringLiteral("\\.[0-9]+$")));
display.remove(QRegularExpression(QStringLiteral("\\.[0-9]+$")));
int i;
while( (i = display.indexOf(QLatin1Char(':'))) >= 0)
display[i] = '_';
......@@ -751,7 +751,7 @@ void KSMServer::cleanUp()
QByteArray fName = QFile::encodeName(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) + QLatin1Char('/') + QStringLiteral("KSMserver"));
QString display = QString::fromLocal8Bit(::getenv("DISPLAY"));
// strip the screen number from the display
display.remove(QRegExp(QStringLiteral("\\.[0-9]+$")));
display.remove(QRegularExpression(QStringLiteral("\\.[0-9]+$")));
int i;
while( (i = display.indexOf(QLatin1Char(':'))) >= 0)
display[i] = '_';
......@@ -895,7 +895,7 @@ void KSMServer::storeSession()
config->reparseConfiguration(); // config may have changed in the KControl module
KConfigGroup generalGroup(config, "General");
excludeApps = generalGroup.readEntry( "excludeApps" ).toLower()
.split( QRegExp( QStringLiteral("[,:]") ), QString::SkipEmptyParts );
.split( QRegularExpression( QStringLiteral("[,:]") ), QString::SkipEmptyParts );
KConfigGroup configSessionGroup(config, sessionGroup);
int count = configSessionGroup.readEntry( "count", 0 );
for ( int i = 1; i <= count; i++ ) {
......
......@@ -32,7 +32,6 @@
#include <QDBusMetaType>
#include <QDBusConnectionInterface>
#include <QCoreApplication>
#include <QRegExp>
#include <QX11Info>
#include <X11/Xauth.h>
......
......@@ -102,7 +102,7 @@ void propagateSessionManager()
QByteArray fName = QFile::encodeName(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation)+"/KSMserver");
QString display = QString::fromLocal8Bit( ::getenv(DISPLAY) );
// strip the screen number from the display
display.remove(QRegExp(QStringLiteral("\\.[0-9]+$")));
display.remove(QRegularExpression(QStringLiteral("\\.\\d+$")));
int i;
while( (i = display.indexOf(':')) >= 0)
display[i] = '_';
......
......@@ -27,6 +27,7 @@
#include <QJSEngine>
#include <QGuiApplication>
#include <QClipboard>
#include <QRegularExpression>
#endif
#include <QIcon>
......@@ -195,14 +196,14 @@ void CalculatorRunner::userFriendlySubstitutions(QString& cmd)
hexSubstitutions(cmd);
powSubstitutions(cmd);
if (cmd.contains(QRegExp(QStringLiteral("\\d+and\\d+")))) {
cmd.replace(QRegExp(QStringLiteral("(\\d+)and(\\d+)")), QStringLiteral("\\1&\\2"));
if (cmd.contains(QRegularExpression(QStringLiteral("\\d+and\\d+")))) {
cmd.replace(QRegularExpression(QStringLiteral("(\\d+)and(\\d+)")), QStringLiteral("\\1&\\2"));
}
if (cmd.contains(QRegExp(QStringLiteral("\\d+or\\d+")))) {
cmd.replace(QRegExp(QStringLiteral("(\\d+)or(\\d+)")), QStringLiteral("\\1|\\2"));
if (cmd.contains(QRegularExpression(QStringLiteral("\\d+or\\d+")))) {
cmd.replace(QRegularExpression(QStringLiteral("(\\d+)or(\\d+)")), QStringLiteral("\\1|\\2"));
}
if (cmd.contains(QRegExp(QStringLiteral("\\d+xor\\d+")))) {
cmd.replace(QRegExp(QStringLiteral("(\\d+)xor(\\d+)")), QStringLiteral("\\1^\\2"));
if (cmd.contains(QRegularExpression(QStringLiteral("\\d+xor\\d+")))) {
cmd.replace(QRegularExpression(QStringLiteral("(\\d+)xor(\\d+)")), QStringLiteral("\\1^\\2"));
}
#endif
}
......@@ -261,7 +262,8 @@ void CalculatorRunner::match(Plasma::RunnerContext &context)
userFriendlySubstitutions(cmd);
#ifndef ENABLE_QALCULATE
cmd.replace(QRegExp(QStringLiteral("([a-zA-Z]+)")), QStringLiteral("Math.\\1")); //needed for accessing math functions like sin(),....
//needed for accessing math functions like sin(),....
cmd.replace(QRegularExpression(QStringLiteral("([a-zA-Z]+)")), QStringLiteral("Math.\\1"));
#endif
bool isApproximate = false;
......
......@@ -31,6 +31,7 @@
#include <QQmlEngine>
#include <QQmlContext>
#include <QGuiApplication>
#include <QRegularExpression>
#include <QTimer>
#include <kactioncollection.h>
......@@ -1192,7 +1193,8 @@ void PanelView::containmentChanged()
if (containment()->destroyed()) {
KConfigGroup views(m_corona->applicationConfig(), "PlasmaViews");
for (auto grp : views.groupList()) {
if (grp.contains(QRegExp(QStringLiteral("Panel ") + QString::number(containment()->id()) + QStringLiteral("$")))) {
if (grp.contains(QRegularExpression(QStringLiteral("Panel %1$").arg(
QString::number(containment()->id()))))) {
qDebug() << "Panel" << containment()->id() << "removed by user";
views.deleteGroup(grp);
}
......
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