Use a regex to validate alias.
This commit is contained in:
parent
3e682b180c
commit
061c9b502a
|
@ -48,6 +48,7 @@
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
#include "ui_dialogarc.h"
|
#include "ui_dialogarc.h"
|
||||||
#include "../vgeometry/varc.h"
|
#include "../vgeometry/varc.h"
|
||||||
|
#include "../qmuparser/qmudef.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -356,9 +357,11 @@ void DialogArc::closeEvent(QCloseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArc::ValidateAlias()
|
void DialogArc::ValidateAlias()
|
||||||
{
|
{
|
||||||
|
QRegularExpression rx(NameRegExp());
|
||||||
VArc arc;
|
VArc arc;
|
||||||
arc.SetAliasSuffix(GetAliasSuffix());
|
arc.SetAliasSuffix(GetAliasSuffix());
|
||||||
if (not GetAliasSuffix().isEmpty() && not data->IsUnique(arc.GetAlias()))
|
if (not GetAliasSuffix().isEmpty() &&
|
||||||
|
(not rx.match(arc.GetAlias()).hasMatch() || not data->IsUnique(arc.GetAlias())))
|
||||||
{
|
{
|
||||||
flagAlias = false;
|
flagAlias = false;
|
||||||
ChangeColor(ui->labelAlias, errorColor);
|
ChangeColor(ui->labelAlias, errorColor);
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "../../visualization/visualization.h"
|
#include "../../visualization/visualization.h"
|
||||||
#include "ui_dialogarcwithlength.h"
|
#include "ui_dialogarcwithlength.h"
|
||||||
#include "../vgeometry/varc.h"
|
#include "../vgeometry/varc.h"
|
||||||
|
#include "../qmuparser/qmudef.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogArcWithLength::DialogArcWithLength(const VContainer *data, quint32 toolId, QWidget *parent)
|
DialogArcWithLength::DialogArcWithLength(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
|
@ -393,9 +394,11 @@ void DialogArcWithLength::closeEvent(QCloseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArcWithLength::ValidateAlias()
|
void DialogArcWithLength::ValidateAlias()
|
||||||
{
|
{
|
||||||
|
QRegularExpression rx(NameRegExp());
|
||||||
VArc arc;
|
VArc arc;
|
||||||
arc.SetAliasSuffix(GetAliasSuffix());
|
arc.SetAliasSuffix(GetAliasSuffix());
|
||||||
if (not GetAliasSuffix().isEmpty() && not data->IsUnique(arc.GetAlias()))
|
if (not GetAliasSuffix().isEmpty() &&
|
||||||
|
(not rx.match(arc.GetAlias()).hasMatch() || not data->IsUnique(arc.GetAlias())))
|
||||||
{
|
{
|
||||||
flagAlias = false;
|
flagAlias = false;
|
||||||
ChangeColor(ui->labelAlias, errorColor);
|
ChangeColor(ui->labelAlias, errorColor);
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#include "ui_dialogcubicbezier.h"
|
#include "ui_dialogcubicbezier.h"
|
||||||
|
#include "../qmuparser/qmudef.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogCubicBezier::DialogCubicBezier(const VContainer *data, quint32 toolId, QWidget *parent)
|
DialogCubicBezier::DialogCubicBezier(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
|
@ -265,9 +266,11 @@ void DialogCubicBezier::SaveData()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCubicBezier::ValidateAlias()
|
void DialogCubicBezier::ValidateAlias()
|
||||||
{
|
{
|
||||||
|
QRegularExpression rx(NameRegExp());
|
||||||
VCubicBezier spline = spl;
|
VCubicBezier spline = spl;
|
||||||
spline.SetAliasSuffix(ui->lineEditAlias->text());
|
spline.SetAliasSuffix(ui->lineEditAlias->text());
|
||||||
if (not ui->lineEditAlias->text().isEmpty() && not data->IsUnique(spline.GetAlias()))
|
if (not ui->lineEditAlias->text().isEmpty() &&
|
||||||
|
(not rx.match(spline.GetAlias()).hasMatch() || not data->IsUnique(spline.GetAlias())))
|
||||||
{
|
{
|
||||||
flagAlias = false;
|
flagAlias = false;
|
||||||
ChangeColor(ui->labelAlias, errorColor);
|
ChangeColor(ui->labelAlias, errorColor);
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
#include "../vwidgets/vabstractmainwindow.h"
|
#include "../vwidgets/vabstractmainwindow.h"
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#include "ui_dialogcubicbezierpath.h"
|
#include "ui_dialogcubicbezierpath.h"
|
||||||
|
#include "../qmuparser/qmudef.h"
|
||||||
|
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
|
@ -254,9 +255,11 @@ void DialogCubicBezierPath::currentPointChanged(int index)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCubicBezierPath::ValidateAlias()
|
void DialogCubicBezierPath::ValidateAlias()
|
||||||
{
|
{
|
||||||
|
QRegularExpression rx(NameRegExp());
|
||||||
VCubicBezierPath tempPath = path;
|
VCubicBezierPath tempPath = path;
|
||||||
tempPath.SetAliasSuffix(ui->lineEditAlias->text());
|
tempPath.SetAliasSuffix(ui->lineEditAlias->text());
|
||||||
if (not ui->lineEditAlias->text().isEmpty() && not data->IsUnique(tempPath.GetAlias()))
|
if (not ui->lineEditAlias->text().isEmpty() &&
|
||||||
|
(not rx.match(tempPath.GetAlias()).hasMatch() || not data->IsUnique(tempPath.GetAlias())))
|
||||||
{
|
{
|
||||||
flagAlias = false;
|
flagAlias = false;
|
||||||
ChangeColor(ui->labelAlias, errorColor);
|
ChangeColor(ui->labelAlias, errorColor);
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
#include "ui_dialogcutarc.h"
|
#include "ui_dialogcutarc.h"
|
||||||
#include "../vgeometry/varc.h"
|
#include "../vgeometry/varc.h"
|
||||||
|
#include "../qmuparser/qmudef.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -207,9 +208,11 @@ void DialogCutArc::ArcChanged()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutArc::ValidateAlias()
|
void DialogCutArc::ValidateAlias()
|
||||||
{
|
{
|
||||||
|
QRegularExpression rx(NameRegExp());
|
||||||
VArc arc1;
|
VArc arc1;
|
||||||
arc1.SetAliasSuffix(GetAliasSuffix1());
|
arc1.SetAliasSuffix(GetAliasSuffix1());
|
||||||
if (not GetAliasSuffix1().isEmpty() && not data->IsUnique(arc1.GetAlias()))
|
if (not GetAliasSuffix1().isEmpty() &&
|
||||||
|
(not rx.match(arc1.GetAlias()).hasMatch() || not data->IsUnique(arc1.GetAlias())))
|
||||||
{
|
{
|
||||||
flagAlias1 = false;
|
flagAlias1 = false;
|
||||||
ChangeColor(ui->labelAlias1, errorColor);
|
ChangeColor(ui->labelAlias1, errorColor);
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
#include "ui_dialogcutspline.h"
|
#include "ui_dialogcutspline.h"
|
||||||
#include "../vgeometry/vspline.h"
|
#include "../vgeometry/vspline.h"
|
||||||
|
#include "../qmuparser/qmudef.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -214,9 +215,11 @@ void DialogCutSpline::SplineChanged()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutSpline::ValidateAlias()
|
void DialogCutSpline::ValidateAlias()
|
||||||
{
|
{
|
||||||
|
QRegularExpression rx(NameRegExp());
|
||||||
VSpline spl1;
|
VSpline spl1;
|
||||||
spl1.SetAliasSuffix(GetAliasSuffix1());
|
spl1.SetAliasSuffix(GetAliasSuffix1());
|
||||||
if (not GetAliasSuffix1().isEmpty() && not data->IsUnique(spl1.GetAlias()))
|
if (not GetAliasSuffix1().isEmpty() &&
|
||||||
|
(not rx.match(spl1.GetAlias()).hasMatch() || not data->IsUnique(spl1.GetAlias())))
|
||||||
{
|
{
|
||||||
flagAlias1 = false;
|
flagAlias1 = false;
|
||||||
ChangeColor(ui->labelAlias1, errorColor);
|
ChangeColor(ui->labelAlias1, errorColor);
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
#include "ui_dialogcutsplinepath.h"
|
#include "ui_dialogcutsplinepath.h"
|
||||||
#include "../vgeometry/vsplinepath.h"
|
#include "../vgeometry/vsplinepath.h"
|
||||||
|
#include "../qmuparser/qmudef.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -214,9 +215,11 @@ void DialogCutSplinePath::SplinePathChanged()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogCutSplinePath::ValidateAlias()
|
void DialogCutSplinePath::ValidateAlias()
|
||||||
{
|
{
|
||||||
|
QRegularExpression rx(NameRegExp());
|
||||||
VSplinePath path1;
|
VSplinePath path1;
|
||||||
path1.SetAliasSuffix(GetAliasSuffix1());
|
path1.SetAliasSuffix(GetAliasSuffix1());
|
||||||
if (not GetAliasSuffix1().isEmpty() && not data->IsUnique(path1.GetAlias()))
|
if (not GetAliasSuffix1().isEmpty() &&
|
||||||
|
(not rx.match(path1.GetAlias()).hasMatch() || not data->IsUnique(path1.GetAlias())))
|
||||||
{
|
{
|
||||||
flagAlias1 = false;
|
flagAlias1 = false;
|
||||||
ChangeColor(ui->labelAlias1, errorColor);
|
ChangeColor(ui->labelAlias1, errorColor);
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
#include "ui_dialogellipticalarc.h"
|
#include "ui_dialogellipticalarc.h"
|
||||||
#include "../vgeometry/vellipticalarc.h"
|
#include "../vgeometry/vellipticalarc.h"
|
||||||
|
#include "../qmuparser/qmudef.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -598,9 +599,11 @@ void DialogEllipticalArc::closeEvent(QCloseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogEllipticalArc::ValidateAlias()
|
void DialogEllipticalArc::ValidateAlias()
|
||||||
{
|
{
|
||||||
|
QRegularExpression rx(NameRegExp());
|
||||||
VEllipticalArc arc;
|
VEllipticalArc arc;
|
||||||
arc.SetAliasSuffix(GetAliasSuffix());
|
arc.SetAliasSuffix(GetAliasSuffix());
|
||||||
if (not GetAliasSuffix().isEmpty() && not data->IsUnique(arc.GetAlias()))
|
if (not GetAliasSuffix().isEmpty() &&
|
||||||
|
(not rx.match(arc.GetAlias()).hasMatch() || not data->IsUnique(arc.GetAlias())))
|
||||||
{
|
{
|
||||||
flagAlias = false;
|
flagAlias = false;
|
||||||
ChangeColor(ui->labelAlias, errorColor);
|
ChangeColor(ui->labelAlias, errorColor);
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
#include "../vwidgets/vmaingraphicsscene.h"
|
#include "../vwidgets/vmaingraphicsscene.h"
|
||||||
#include "ui_dialogspline.h"
|
#include "ui_dialogspline.h"
|
||||||
#include "vtranslatevars.h"
|
#include "vtranslatevars.h"
|
||||||
|
#include "../qmuparser/qmudef.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -437,9 +438,11 @@ void DialogSpline::EvalLength2()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSpline::ValidateAlias()
|
void DialogSpline::ValidateAlias()
|
||||||
{
|
{
|
||||||
|
QRegularExpression rx(NameRegExp());
|
||||||
VSpline spline = spl;
|
VSpline spline = spl;
|
||||||
spline.SetAliasSuffix(ui->lineEditAlias->text());
|
spline.SetAliasSuffix(ui->lineEditAlias->text());
|
||||||
if (not ui->lineEditAlias->text().isEmpty() && not data->IsUnique(spline.GetAlias()))
|
if (not ui->lineEditAlias->text().isEmpty() &&
|
||||||
|
(not rx.match(spline.GetAlias()).hasMatch() || not data->IsUnique(spline.GetAlias())))
|
||||||
{
|
{
|
||||||
flagAlias = false;
|
flagAlias = false;
|
||||||
ChangeColor(ui->labelAlias, errorColor);
|
ChangeColor(ui->labelAlias, errorColor);
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
#include "../vwidgets/vmaingraphicsscene.h"
|
#include "../vwidgets/vmaingraphicsscene.h"
|
||||||
#include "ui_dialogsplinepath.h"
|
#include "ui_dialogsplinepath.h"
|
||||||
#include "vtranslatevars.h"
|
#include "vtranslatevars.h"
|
||||||
|
#include "../qmuparser/qmudef.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -498,9 +499,11 @@ void DialogSplinePath::FXLength2()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSplinePath::ValidateAlias()
|
void DialogSplinePath::ValidateAlias()
|
||||||
{
|
{
|
||||||
|
QRegularExpression rx(NameRegExp());
|
||||||
VSplinePath tempPath = path;
|
VSplinePath tempPath = path;
|
||||||
tempPath.SetAliasSuffix(ui->lineEditAlias->text());
|
tempPath.SetAliasSuffix(ui->lineEditAlias->text());
|
||||||
if (not ui->lineEditAlias->text().isEmpty() && not data->IsUnique(tempPath.GetAlias()))
|
if (not ui->lineEditAlias->text().isEmpty() &&
|
||||||
|
(not rx.match(tempPath.GetAlias()).hasMatch() || not data->IsUnique(tempPath.GetAlias())))
|
||||||
{
|
{
|
||||||
flagAlias = false;
|
flagAlias = false;
|
||||||
ChangeColor(ui->labelAlias, errorColor);
|
ChangeColor(ui->labelAlias, errorColor);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user