mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Fix QRegularExpression
-add isValid -add debug
This commit is contained in:
@@ -253,7 +253,8 @@ void ElementsLocation::setPath(const QString &path)
|
|||||||
QRegularExpressionMatch match = re.match(tmp_path);
|
QRegularExpressionMatch match = re.match(tmp_path);
|
||||||
if (!match.hasMatch())
|
if (!match.hasMatch())
|
||||||
{
|
{
|
||||||
qDebug()<<"no Match => return";
|
qDebug()<<"no Match => return"
|
||||||
|
<<tmp_path;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool conv_ok;
|
bool conv_ok;
|
||||||
|
|||||||
@@ -97,15 +97,29 @@ bool TitleBlockTemplateLocation::isValid() const
|
|||||||
/**
|
/**
|
||||||
@param loc_str String describing the location of a title block template.
|
@param loc_str String describing the location of a title block template.
|
||||||
*/
|
*/
|
||||||
void TitleBlockTemplateLocation::fromString(const QString &loc_str) {
|
void TitleBlockTemplateLocation::fromString(const QString &loc_str)
|
||||||
|
{
|
||||||
collection_ = QETApp::titleBlockTemplatesCollection(QUrl(loc_str).scheme());
|
collection_ = QETApp::titleBlockTemplatesCollection(QUrl(loc_str).scheme());
|
||||||
|
|
||||||
QRegularExpression name_from_url("^[^:]*:\\/\\/(.*)$");
|
QRegularExpression name_from_url("//*(?<name>.*)");
|
||||||
if (name_from_url==QRegularExpression(loc_str)) {
|
if (!name_from_url.isValid())
|
||||||
name_ = name_from_url.namedCaptureGroups().at(1);
|
{
|
||||||
} else {
|
qWarning() <<"this is an error in the code"
|
||||||
name_ = QString();
|
<< name_from_url.errorString()
|
||||||
|
<< name_from_url.patternErrorOffset();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRegularExpressionMatch match = name_from_url.match(loc_str);
|
||||||
|
if (!match.hasMatch())
|
||||||
|
{
|
||||||
|
qDebug()<<"no Match => return"
|
||||||
|
<<loc_str;
|
||||||
|
name_ = QString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
name_ = match.captured("name");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user