Check suffix in a dialog.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-05-18 16:38:04 +03:00
parent 180903b807
commit 702245f9fb

View File

@ -37,6 +37,7 @@
#include "../ifc/xml/vdomdocument.h" #include "../ifc/xml/vdomdocument.h"
#include "../../visualization/line/vistoolrotation.h" #include "../../visualization/line/vistoolrotation.h"
#include "../support/dialogeditwrongformula.h" #include "../support/dialogeditwrongformula.h"
#include "../qmuparser/qmudef.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogRotation::DialogRotation(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogRotation::DialogRotation(const VContainer *data, const quint32 &toolId, QWidget *parent)
@ -263,18 +264,33 @@ void DialogRotation::SuffixChanged()
QLineEdit* edit = qobject_cast<QLineEdit*>(sender()); QLineEdit* edit = qobject_cast<QLineEdit*>(sender());
if (edit) if (edit)
{ {
const QString name = edit->text(); const QString suffix = edit->text();
// QRegularExpression rx(NameRegExp()); if (suffix.isEmpty())
if (name.isEmpty()/* || (pointName != name && not data->IsUnique(name)) || not rx.match(name).hasMatch()*/)
{ {
flagName = false; flagName = false;
ChangeColor(ui->labelSuffix, Qt::red); ChangeColor(ui->labelSuffix, Qt::red);
CheckState();
return;
} }
else else
{ {
flagName = true; QRegularExpression rx(NameRegExp());
ChangeColor(ui->labelSuffix, okColor); const QStringList uniqueNames = data->AllUniqueNames();
for (int i=0; i < uniqueNames.size(); ++i)
{
const QString name = uniqueNames.at(i) + suffix;
if (not rx.match(name).hasMatch() || not data->IsUnique(name))
{
flagName = false;
ChangeColor(ui->labelSuffix, Qt::red);
CheckState();
return;
}
}
} }
flagName = true;
ChangeColor(ui->labelSuffix, okColor);
} }
CheckState(); CheckState();
} }