diff --git a/applets/digital-clock/plugin/clipboardmenu.cpp b/applets/digital-clock/plugin/clipboardmenu.cpp --- a/applets/digital-clock/plugin/clipboardmenu.cpp +++ b/applets/digital-clock/plugin/clipboardmenu.cpp @@ -25,6 +25,7 @@ #include #include #include +#include ClipboardMenu::ClipboardMenu(QObject *parent) : QObject(parent) { @@ -75,7 +76,7 @@ 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 @@ 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 @@ 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); diff --git a/dataengines/devicenotifications/ksolidnotify.cpp b/dataengines/devicenotifications/ksolidnotify.cpp --- a/dataengines/devicenotifications/ksolidnotify.cpp +++ b/dataengines/devicenotifications/ksolidnotify.cpp @@ -37,6 +37,7 @@ #include #include +#include KSolidNotify::KSolidNotify(QObject *parent): QObject(parent) @@ -127,9 +128,9 @@ connect(p, static_cast(&QProcess::finished), [=](int,QProcess::ExitStatus) { QStringList blockApps; QString out(p->readAll()); - const QStringList &pidList = out.split(QRegExp(QStringLiteral("\\s+")), QString::SkipEmptyParts); + const QVector 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; diff --git a/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp b/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp --- a/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp +++ b/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -825,8 +826,8 @@ 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 @@ 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(); diff --git a/ksmserver/server.cpp b/ksmserver/server.cpp --- a/ksmserver/server.cpp +++ b/ksmserver/server.cpp @@ -65,7 +65,7 @@ #include #include -#include +#include #include #include #include @@ -668,7 +668,7 @@ 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 @@ 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 @@ 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++ ) { diff --git a/libkworkspace/kdisplaymanager.cpp b/libkworkspace/kdisplaymanager.cpp --- a/libkworkspace/kdisplaymanager.cpp +++ b/libkworkspace/kdisplaymanager.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include diff --git a/libkworkspace/kworkspace.cpp b/libkworkspace/kworkspace.cpp --- a/libkworkspace/kworkspace.cpp +++ b/libkworkspace/kworkspace.cpp @@ -102,7 +102,7 @@ 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] = '_'; diff --git a/runners/calculator/calculatorrunner.cpp b/runners/calculator/calculatorrunner.cpp --- a/runners/calculator/calculatorrunner.cpp +++ b/runners/calculator/calculatorrunner.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #endif #include @@ -195,14 +196,14 @@ 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 @@ 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; diff --git a/shell/panelview.cpp b/shell/panelview.cpp --- a/shell/panelview.cpp +++ b/shell/panelview.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -1192,7 +1193,8 @@ 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); }