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
@@ -97,7 +97,7 @@ QETApp::QETApp() :
"splash screen caption")); "splash screen caption"));
if (!collections_cache_) { if (!collections_cache_) {
QString cache_path = QETApp::configDir() + "/elements_cache.sqlite"; QString cache_path = QETApp::configDir() + "/elements_cache.sqlite";
collections_cache_ = new ElementsCollectionCache(cache_path, this); collections_cache_ = new ElementsCollectionCache(cache_path, this);
collections_cache_->setLocale(langFromSetting()); collections_cache_->setLocale(langFromSetting());
} }
@@ -113,12 +113,12 @@ QETApp::QETApp() :
"splash screen caption")); "splash screen caption"));
openFiles(qet_arguments_); openFiles(qet_arguments_);
} }
buildSystemTrayMenu(); buildSystemTrayMenu();
if (m_splash_screen) { if (m_splash_screen) {
m_splash_screen -> hide(); m_splash_screen -> hide();
} }
checkBackupFiles(); checkBackupFiles();
} }
@@ -129,17 +129,17 @@ QETApp::~QETApp()
{ {
m_elements_recent_files->save(); m_elements_recent_files->save();
m_projects_recent_files->save(); m_projects_recent_files->save();
delete m_splash_screen; delete m_splash_screen;
delete m_elements_recent_files; delete m_elements_recent_files;
delete m_projects_recent_files; delete m_projects_recent_files;
delete m_qsti; delete m_qsti;
if (m_custom_tbt_collection) if (m_custom_tbt_collection)
delete m_custom_tbt_collection; delete m_custom_tbt_collection;
if (m_common_tbt_collection) if (m_common_tbt_collection)
delete m_common_tbt_collection; delete m_common_tbt_collection;
ElementFactory::dropInstance(); ElementFactory::dropInstance();
ElementPictureFactory::dropInstance(); ElementPictureFactory::dropInstance();
} }
@@ -409,12 +409,12 @@ QString QETApp::elementTranslatedInfoKey(const QString &info)
else if (info == "label") return tr("Label"); else if (info == "label") return tr("Label");
else if (info == "plant") return tr("Installation"); else if (info == "plant") return tr("Installation");
else if (info == "location") return tr("Localisation"); else if (info == "location") return tr("Localisation");
else if (info == "comment") return tr("Commentaire"); else if (info == "comment") return tr("Commentaire");
else if (info == "function") return tr("Fonction"); else if (info == "function") return tr("Fonction");
else if (info == "auxiliary1") return tr("Bloc auxiliaire 1"); else if (info == "auxiliary1") return tr("Bloc auxiliaire 1");
else if (info == "auxiliary2") return tr("Bloc auxiliaire 2"); else if (info == "auxiliary2") return tr("Bloc auxiliaire 2");
else if (info == "description") return tr("Description textuelle"); else if (info == "description") return tr("Description textuelle");
else if (info == "designation") return tr("Numéro d'article"); else if (info == "designation") return tr("Numéro d'article");
else if (info == "manufacturer") return tr("Fabricant"); else if (info == "manufacturer") return tr("Fabricant");
@@ -455,7 +455,7 @@ QStringList QETApp::conductorInfoKeys()
keys.append("tension/protocol"); keys.append("tension/protocol");
keys.append("conductor_color"); keys.append("conductor_color");
keys.append("conductor_section"); keys.append("conductor_section");
return keys; return keys;
} }
@@ -492,7 +492,7 @@ QStringList QETApp::diagramInfoKeys()
list.append("indexrev"); list.append("indexrev");
list.append("date"); list.append("date");
list.append("display_folio"); list.append("display_folio");
return list; return list;
} }
@@ -625,7 +625,7 @@ QString QETApp::commonElementsDir()
else if (m_user_common_elements_dir != "default") { else if (m_user_common_elements_dir != "default") {
return m_user_common_elements_dir; return m_user_common_elements_dir;
} }
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION #ifdef QET_ALLOW_OVERRIDE_CED_OPTION
if (common_elements_dir != QString()) return(common_elements_dir); if (common_elements_dir != QString()) return(common_elements_dir);
#endif #endif
@@ -687,7 +687,7 @@ QString QETApp::customElementsDir()
else if (m_user_custom_elements_dir != "default") { else if (m_user_custom_elements_dir != "default") {
return m_user_custom_elements_dir; return m_user_custom_elements_dir;
} }
return(configDir() + "elements/"); return(configDir() + "elements/");
} }
@@ -786,7 +786,7 @@ QString QETApp::customTitleBlockTemplatesDir()
else if (m_user_custom_tbt_dir != "default") { else if (m_user_custom_tbt_dir != "default") {
return m_user_custom_tbt_dir; return m_user_custom_tbt_dir;
} }
return(configDir() + "titleblocks/"); return(configDir() + "titleblocks/");
} }
@@ -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);
} }
@@ -1159,7 +1159,7 @@ QFont QETApp::diagramTextsItemFont(qreal size)
).toDouble(); ).toDouble();
QString diagram_texts_item_style = settings.value("diagramitemstyle", QString diagram_texts_item_style = settings.value("diagramitemstyle",
"normal").toString(); "normal").toString();
if (size != -1.0) { if (size != -1.0) {
diagram_texts_item_size = size; diagram_texts_item_size = size;
} }
@@ -1359,9 +1359,9 @@ QList<QETElementEditor *> QETApp::elementEditors(QETProject *project) {
void QETApp::receiveMessage(int instanceId, QByteArray message) void QETApp::receiveMessage(int instanceId, QByteArray message)
{ {
Q_UNUSED(instanceId); Q_UNUSED(instanceId);
QString str(message); QString str(message);
if (str.startsWith("launched-with-args: ")) if (str.startsWith("launched-with-args: "))
{ {
QString my_message(str.mid(20)); QString my_message(str.mid(20));
@@ -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);
} }
@@ -2191,7 +2191,7 @@ void QETApp::buildSystemTrayMenu()
void QETApp::checkBackupFiles() void QETApp::checkBackupFiles()
{ {
QList<KAutoSaveFile *> stale_files = KAutoSaveFile::allStaleFiles(); QList<KAutoSaveFile *> stale_files = KAutoSaveFile::allStaleFiles();
//Remove from the list @stale_files, the stales file of opened project //Remove from the list @stale_files, the stales file of opened project
const QList<KAutoSaveFile *> sf = stale_files; const QList<KAutoSaveFile *> sf = stale_files;
for (KAutoSaveFile *kasf : sf) for (KAutoSaveFile *kasf : sf)
@@ -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