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);
} }
@@ -2227,10 +2227,10 @@ void QETApp::checkBackupFiles()
for(const KAutoSaveFile *kasf : stale_files) for(const KAutoSaveFile *kasf : stale_files)
{ {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
//Remove the first character '/' before the name of the drive //Remove the first character '/' before the name of the drive
text.append("<br>" + kasf->managedFile().path().remove(0,1)); text.append("<br>" + kasf->managedFile().path().remove(0,1));
#else #else
text.append("<br>" + kasf->managedFile().path()); text.append("<br>" + kasf->managedFile().path());
#endif #endif
} }
@@ -2319,12 +2319,12 @@ void QETApp::fetchWindowStats(
bool QETApp::eventFiltrer(QObject *object, QEvent *e) { bool QETApp::eventFiltrer(QObject *object, QEvent *e) {
// gere l'ouverture de fichiers (sous MacOs) // gere l'ouverture de fichiers (sous MacOs)
if (e -> type() == QEvent::FileOpen) { if (e -> type() == QEvent::FileOpen) {
// nom du fichier a ouvrir // nom du fichier a ouvrir
QString filename = static_cast<QFileOpenEvent *>(e) -> file(); QString filename = static_cast<QFileOpenEvent *>(e) -> file();
openFiles(QStringList() << filename); openFiles(QStringList() << filename);
return(true); return(true);
} else { } else {
return QObject::eventFilter(object, e); return QObject::eventFilter(object, e);
} }
} }
#endif #endif