mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-14 20:33:05 +02:00
Fix QRegularExpression
-add isValid -add debug
This commit is contained in:
parent
b5ae1237e3
commit
2fe53ba6e8
@ -19,6 +19,7 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
#include <QtDebug>
|
||||||
/**
|
/**
|
||||||
Constructeur par defaut
|
Constructeur par defaut
|
||||||
*/
|
*/
|
||||||
@ -789,16 +790,32 @@ void ConductorProperties::readStyle(const QString &style_string) {
|
|||||||
QStringList styles = style_string.split(";", Qt::SkipEmptyParts);
|
QStringList styles = style_string.split(";", Qt::SkipEmptyParts);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QRegularExpression Rx("^\\s*([a-z-]+)\\s*:\\s*([a-z-]+)\\s*$");
|
QRegularExpression Rx("^(?<name>[a-z-]+): (?<value>[a-z-]+)$");
|
||||||
foreach (QString style_str, styles) {
|
if (!Rx.isValid())
|
||||||
if (Rx==QRegularExpression(style_str)) {
|
{
|
||||||
|
qWarning() <<"this is an error in the code"
|
||||||
QString style_name = Rx.namedCaptureGroups().at(1);
|
<< Rx.errorString()
|
||||||
QString style_value = Rx.namedCaptureGroups().at(2);
|
<< Rx.patternErrorOffset();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach (QString style_str, styles)
|
||||||
|
{
|
||||||
|
QRegularExpressionMatch match = Rx.match(style_str);
|
||||||
|
if (!match.hasMatch())
|
||||||
|
{
|
||||||
|
qDebug()<<"no Match"
|
||||||
|
<<style_str;
|
||||||
|
} else {
|
||||||
|
QString style_name = match.captured("name");
|
||||||
|
QString style_value = match.captured("value");
|
||||||
if (style_name == "line-style") {
|
if (style_name == "line-style") {
|
||||||
if (style_value == "dashed") style = Qt::DashLine;
|
if (style_value == "dashed") style = Qt::DashLine;
|
||||||
else if (style_value == "dashdotted") style = Qt::DashDotLine;
|
else if (style_value == "dashdotted") style = Qt::DashDotLine;
|
||||||
else if (style_value == "normal") style = Qt::SolidLine;
|
else if (style_value == "normal") style = Qt::SolidLine;
|
||||||
|
else {
|
||||||
|
qWarning()<<"style_value not known"
|
||||||
|
<<style_value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user