Revert "Fix deprecated QRegExp"

This reverts commit 0a46b83dca.
see https://qelectrotech.org/forum/viewtopic.php?pid=13378#p13378
This commit is contained in:
Simon De Backer
2020-09-22 21:10:02 +02:00
parent 2a69e540d6
commit 77321f6b70

View File

@@ -144,9 +144,9 @@ bool ElementsLocation::operator!=(const ElementsLocation &other) const
*/ */
QString ElementsLocation::baseName() const QString ElementsLocation::baseName() const
{ {
QRegularExpression regexp("^.*([^/]+)\\.elmt$"); QRegExp regexp("^.*([^/]+)\\.elmt$");
if (regexp==QRegularExpression(m_collection_path)) { if (regexp.exactMatch(m_collection_path)) {
return(regexp.namedCaptureGroups().at(1)); return(regexp.capturedTexts().at(1));
} }
return(QString()); return(QString());
} }
@@ -241,19 +241,17 @@ void ElementsLocation::setPath(const QString &path)
//The path start with project, we get the project and the path from the string //The path start with project, we get the project and the path from the string
else if (tmp_path.startsWith("project")) else if (tmp_path.startsWith("project"))
{ {
QRegularExpression rx QRegExp rx("^project([0-9]+)\\+(embed:\\/\\/.*)$", Qt::CaseInsensitive);
("^project([0-9]+)\\+(embed:\\/\\/.*)$", if (rx.exactMatch(tmp_path))
QRegularExpression::CaseInsensitiveOption);
if (rx==QRegularExpression(tmp_path))
{ {
bool conv_ok; bool conv_ok;
uint project_id = rx.namedCaptureGroups().at(1).toUInt(&conv_ok); uint project_id = rx.capturedTexts().at(1).toUInt(&conv_ok);
if (conv_ok) if (conv_ok)
{ {
QETProject *project = QETApp::project(project_id); QETProject *project = QETApp::project(project_id);
if (project) if (project)
{ {
m_collection_path = rx.namedCaptureGroups().at(2); m_collection_path = rx.capturedTexts().at(2);
m_project = project; m_project = project;
} }
} }
@@ -353,11 +351,11 @@ bool ElementsLocation::addToPath(const QString &string)
ElementsLocation ElementsLocation::parent() const ElementsLocation ElementsLocation::parent() const
{ {
ElementsLocation copy(*this); ElementsLocation copy(*this);
QRegularExpression re1("^([a-z]+://)(.*)/*$"); QRegExp re1("^([a-z]+://)(.*)/*$");
if (re1==QRegularExpression(m_collection_path)) { if (re1.exactMatch(m_collection_path)) {
QString path_proto = re1.namedCaptureGroups().at(1); QString path_proto = re1.capturedTexts().at(1);
QString path_path = re1.namedCaptureGroups().at(2); QString path_path = re1.capturedTexts().at(2);
QString parent_path = path_path.remove(QRegularExpression("/*[^/]+$")); QString parent_path = path_path.remove(QRegExp("/*[^/]+$"));
copy.setPath(path_proto + parent_path); copy.setPath(path_proto + parent_path);
} }
return(copy); return(copy);
@@ -720,14 +718,14 @@ bool ElementsLocation::setXml(const QDomDocument &xml_document) const
else else
{ {
QString path_ = collectionPath(false); QString path_ = collectionPath(false);
QRegularExpression rx ("^(.*)/(.*\\.elmt)$"); QRegExp rx ("^(.*)/(.*\\.elmt)$");
if (rx==QRegularExpression(path_)) { if (rx.exactMatch(path_)) {
return project() return project()
->embeddedElementCollection() ->embeddedElementCollection()
->addElementDefinition( ->addElementDefinition(
rx.namedCaptureGroups().at(1), rx.cap(1),
rx.namedCaptureGroups().at(2), rx.cap(2),
xml_document xml_document
.documentElement()); .documentElement());
} }