mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Fix Revert deprecated QRegExp
Use QRegularExpression instead. https://doc.qt.io/qt-5/qregularexpression.html#notes-for-qregexp-users This function was introduced in Qt 5 see https://qelectrotech.org/forum/viewtopic.php?pid=13406#p13406
This commit is contained in:
@@ -241,20 +241,36 @@ 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"))
|
||||||
{
|
{
|
||||||
QRegExp rx("^project([0-9]+)\\+(embed:\\/\\/.*)$", Qt::CaseInsensitive);
|
QRegularExpression re
|
||||||
if (rx.exactMatch(tmp_path))
|
("^project(?<project_id>[0-9])\\+(?<collection_path>embed://*.*)$");
|
||||||
|
if (!re.isValid())
|
||||||
{
|
{
|
||||||
bool conv_ok;
|
qWarning() <<"this is an error in the code"
|
||||||
uint project_id = rx.capturedTexts().at(1).toUInt(&conv_ok);
|
<< re.errorString()
|
||||||
if (conv_ok)
|
<< re.patternErrorOffset();
|
||||||
{
|
return;
|
||||||
QETProject *project = QETApp::project(project_id);
|
}
|
||||||
if (project)
|
QRegularExpressionMatch match = re.match(tmp_path);
|
||||||
{
|
if (!match.hasMatch())
|
||||||
m_collection_path = rx.capturedTexts().at(2);
|
{
|
||||||
m_project = project;
|
qDebug()<<"no Match => return";
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
|
bool conv_ok;
|
||||||
|
uint project_id = match.captured("project_id").toUInt(&conv_ok);
|
||||||
|
if (!conv_ok)
|
||||||
|
{
|
||||||
|
qWarning()<<"toUint failed"
|
||||||
|
<<match.captured("project_id")
|
||||||
|
<<re
|
||||||
|
<<tmp_path;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QETProject *project = QETApp::project(project_id);
|
||||||
|
if (project)
|
||||||
|
{
|
||||||
|
m_collection_path = match.captured("collection_path");
|
||||||
|
m_project = project;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user