mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
QT6: Fix deprecated QRegExp
This commit is contained in:
@@ -144,11 +144,23 @@ bool ElementsLocation::operator!=(const ElementsLocation &other) const
|
|||||||
*/
|
*/
|
||||||
QString ElementsLocation::baseName() const
|
QString ElementsLocation::baseName() const
|
||||||
{
|
{
|
||||||
QRegExp regexp("^.*([^/]+)\\.elmt$");
|
QRegularExpression regexp("^.*(?<name>[^/]+)\\.elmt$");
|
||||||
if (regexp.exactMatch(m_collection_path)) {
|
if (!regexp.isValid())
|
||||||
return(regexp.capturedTexts().at(1));
|
{
|
||||||
|
qWarning() <<"this is an error in the code"
|
||||||
|
<< regexp.errorString()
|
||||||
|
<< regexp.patternErrorOffset();
|
||||||
|
return QString();
|
||||||
}
|
}
|
||||||
return(QString());
|
|
||||||
|
QRegularExpressionMatch match = regexp.match(m_collection_path);
|
||||||
|
if (!match.hasMatch())
|
||||||
|
{
|
||||||
|
qDebug()<<"no Match => return"
|
||||||
|
<<m_collection_path;
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
return match.captured("name");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -368,12 +380,22 @@ bool ElementsLocation::addToPath(const QString &string)
|
|||||||
ElementsLocation ElementsLocation::parent() const
|
ElementsLocation ElementsLocation::parent() const
|
||||||
{
|
{
|
||||||
ElementsLocation copy(*this);
|
ElementsLocation copy(*this);
|
||||||
QRegExp re1("^([a-z]+://)(.*)/*$");
|
QRegularExpression re ("^(?<path_proto>[a-z]+://.*)/.*$");
|
||||||
if (re1.exactMatch(m_collection_path)) {
|
if (!re.isValid())
|
||||||
QString path_proto = re1.capturedTexts().at(1);
|
{
|
||||||
QString path_path = re1.capturedTexts().at(2);
|
qWarning()
|
||||||
QString parent_path = path_path.remove(QRegExp("/*[^/]+$"));
|
<<QObject::tr("this is an error in the code")
|
||||||
copy.setPath(path_proto + parent_path);
|
<< re.errorString()
|
||||||
|
<< re.patternErrorOffset();
|
||||||
|
}
|
||||||
|
QRegularExpressionMatch match = re.match(m_collection_path);
|
||||||
|
if (!match.hasMatch())
|
||||||
|
{
|
||||||
|
qDebug()
|
||||||
|
<<"no Match => return"
|
||||||
|
<<m_collection_path;
|
||||||
|
}else {
|
||||||
|
copy.setPath(match.captured("path_proto"));
|
||||||
}
|
}
|
||||||
return(copy);
|
return(copy);
|
||||||
}
|
}
|
||||||
@@ -734,6 +756,7 @@ bool ElementsLocation::setXml(const QDomDocument &xml_document) const
|
|||||||
//Element doesn't exist, we create the element
|
//Element doesn't exist, we create the element
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||||
QString path_ = collectionPath(false);
|
QString path_ = collectionPath(false);
|
||||||
QRegExp rx ("^(.*)/(.*\\.elmt)$");
|
QRegExp rx ("^(.*)/(.*\\.elmt)$");
|
||||||
|
|
||||||
@@ -750,7 +773,12 @@ bool ElementsLocation::setXml(const QDomDocument &xml_document) const
|
|||||||
qDebug() << "ElementsLocation::setXml :"
|
qDebug() << "ElementsLocation::setXml :"
|
||||||
" rx don't match";
|
" rx don't match";
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#if TODO_LIST
|
||||||
|
#pragma message("@TODO remove code for QT 6 or later")
|
||||||
|
#endif
|
||||||
|
qDebug()<<"Help code for QT 6 or later";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user