Fix deprecated QRegExp

Use QRegularExpression instead.

https://doc.qt.io/qt-5/qregularexpression.html#notes-for-qregexp-users

This function was introduced in Qt 5
This commit is contained in:
Simon De Backer
2020-09-18 23:05:37 +02:00
parent 3eca82baad
commit 4c54335301

View File

@@ -33,14 +33,14 @@
#include "projectview.h" #include "projectview.h"
#include "elementpicturefactory.h" #include "elementpicturefactory.h"
#include "aboutqetdialog.h" #include "aboutqetdialog.h"
#include "factory/elementfactory.h"
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#define QUOTE(x) STRINGIFY(x) #define QUOTE(x) STRINGIFY(x)
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#include <QProcessEnvironment> #include <QProcessEnvironment>
#include "factory/elementfactory.h" #include <QRegularExpression>
#include <KAutoSaveFile> #include <KAutoSaveFile>
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION #ifdef QET_ALLOW_OVERRIDE_CED_OPTION
@@ -911,7 +911,7 @@ QStringList QETApp::handledFileExtensions()
if (!ext.count()) { if (!ext.count()) {
ext << "qet"; ext << "qet";
ext << "elmt"; ext << "elmt";
ext << QString(TITLEBLOCKS_FILE_EXTENSION).remove(QRegExp("^\\.")); ext << QString(TITLEBLOCKS_FILE_EXTENSION).remove(QRegularExpression("^\\."));
} }
return(ext); return(ext);
} }
@@ -2102,10 +2102,10 @@ template <class T> void QETApp::addWindowsListToMenu(
or -1 if none could be found. or -1 if none could be found.
*/ */
int QETApp::projectIdFromString(const QString &url) { int QETApp::projectIdFromString(const QString &url) {
QRegExp embedded("^project([0-9]+)\\+embed.*$", Qt::CaseInsensitive); QRegularExpression embedded("^project([0-9]+)\\+embed.*$", QRegularExpression::CaseInsensitiveOption);
if (embedded.exactMatch(url)) { if (embedded==QRegularExpression(url)) {
bool conv_ok = false; bool conv_ok = false;
int project_id = embedded.capturedTexts().at(1).toInt(&conv_ok); int project_id = embedded.namedCaptureGroups().at(1).toInt(&conv_ok);
if (conv_ok) { if (conv_ok) {
return(project_id); return(project_id);
} }