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:51 +02:00
parent 813014ec33
commit 176dcd376b

View File

@@ -20,6 +20,8 @@
#include "qetapp.h" #include "qetapp.h"
#include "qetproject.h" #include "qetproject.h"
#include <QRegularExpression>
/** /**
Constructor Constructor
@param parent Parent QObject @param parent Parent QObject
@@ -408,7 +410,7 @@ QString TitleBlockTemplatesFilesCollection::path(const QString &template_name) c
QStringList TitleBlockTemplatesFilesCollection::templates() QStringList TitleBlockTemplatesFilesCollection::templates()
{ {
QStringList templates_names; QStringList templates_names;
QRegExp replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION)); QRegularExpression replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION));
foreach(QString name, dir_.entryList()) { foreach(QString name, dir_.entryList()) {
templates_names << name.replace(replace_regexp, ""); templates_names << name.replace(replace_regexp, "");
} }
@@ -544,7 +546,7 @@ bool TitleBlockTemplatesFilesCollection::isReadOnly(const QString &template_name
@return the template name for \a file_name @return the template name for \a file_name
*/ */
QString TitleBlockTemplatesFilesCollection::toTemplateName(const QString &file_name) { QString TitleBlockTemplatesFilesCollection::toTemplateName(const QString &file_name) {
static QRegExp replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION)); static QRegularExpression replace_regexp(QString("%1$").arg(TITLEBLOCKS_FILE_EXTENSION));
QString template_name(file_name); QString template_name(file_name);
return(template_name.replace(replace_regexp, "")); return(template_name.replace(replace_regexp, ""));
} }