Fixed issue #299. Error when opening .val file.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2015-05-11 16:12:39 +03:00
parent f1d7caaba5
commit 1c1077a0e6
5 changed files with 7 additions and 9 deletions

View File

@ -712,11 +712,9 @@ void DialogTool::NamePointChanged()
if (edit) if (edit)
{ {
QString name = edit->text(); QString name = edit->text();
name.replace(" ", ""); QRegularExpression rx(nameRegExp);
QRegExpValidator v(QRegExp(nameRegExp), this);
int pos = 0;
if (name.isEmpty() || (pointName != name && data->IsUnique(name) == false) || if (name.isEmpty() || (pointName != name && data->IsUnique(name) == false) ||
v.validate(name, pos) == QValidator::Invalid) rx.match(name).hasMatch() == false)
{ {
flagName = false; flagName = false;
ChangeColor(labelEditNamePoint, Qt::red); ChangeColor(labelEditNamePoint, Qt::red);

View File

@ -31,7 +31,7 @@
#include <QStringList> #include <QStringList>
//Same regexp in pattern.xsd shema file. Don't forget synchronize. //Same regexp in pattern.xsd shema file. Don't forget synchronize.
const QString nameRegExp = QStringLiteral("^([^0-9-*/^+=\\s\\(\\)%:;!.,`'\"]){1,1}([^-*/^+=\\s\\(\\)%:;!.,`'\"]){0,}$"); const QString nameRegExp = QStringLiteral("^([^0-9*/^+\\-=\\s()?%:;!.,`'\"]){1,1}([^*/^+\\-=\\s()?%:;!.,`'\"]){0,}$");
// From documantation: If you use QStringLiteral you should avoid declaring the same literal in multiple places: This // From documantation: If you use QStringLiteral you should avoid declaring the same literal in multiple places: This
// furthermore blows up the binary sizes. // furthermore blows up the binary sizes.

View File

@ -60,7 +60,7 @@ QWidget *TextDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem
QLineEdit *editor = new QLineEdit(parent); QLineEdit *editor = new QLineEdit(parent);
editor->setLocale(parent->locale()); editor->setLocale(parent->locale());
//Same regex pattern in xsd file //Same regex pattern in xsd file
editor->setValidator( new QRegExpValidator(QRegExp(regex)) ); editor->setValidator( new QRegularExpressionValidator(QRegularExpression(regex)) );
connect(editor, &QLineEdit::editingFinished, this, &TextDelegate::commitAndCloseEditor); connect(editor, &QLineEdit::editingFinished, this, &TextDelegate::commitAndCloseEditor);
return editor; return editor;
} }

View File

@ -431,8 +431,8 @@ void VToolOptionsPropertyBrowser::SetPointName(const QString &name)
return; return;
} }
QRegExp rx(nameRegExp); QRegularExpression rx(nameRegExp);
if (name.isEmpty() || VContainer::IsUnique(name) == false || rx.exactMatch(name) == false) if (name.isEmpty() || VContainer::IsUnique(name) == false || rx.match(name).hasMatch() == false)
{ {
idToProperty[VAbstractTool::AttrName]->setValue(i->name()); idToProperty[VAbstractTool::AttrName]->setValue(i->name());
} }

View File

@ -274,7 +274,7 @@
</xs:element> </xs:element>
<xs:simpleType name="shortName"> <xs:simpleType name="shortName">
<xs:restriction base="xs:string"> <xs:restriction base="xs:string">
<xs:pattern value="^([^0-9-*/^+=\s\(\)%:;!.,`'\&quot;]){1,1}([^-*/^+=\s\(\)%:;!.,`'\&quot;]){0,}$"/> <xs:pattern value="^([^0-9*/^+\-=\s()?%:;!.,`'\&quot;]){1,1}([^*/^+\-=\s()?%:;!.,`'\&quot;]){0,}$"/>
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
<xs:simpleType name="units"> <xs:simpleType name="units">