Skip to content

Commit

Permalink
Merge pull request #814 from ra3xdh/812_fix
Browse files Browse the repository at this point in the history
Set validator for component name
  • Loading branch information
ra3xdh committed Jul 7, 2024
2 parents f42f5f8 + cd516b4 commit 10bb12d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion qucs/components/componentdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d)
Validator2 = new QRegularExpressionValidator(Expr, this);
Expr.setPattern("[\\w_.,\\(\\) @:\\[\\]]+"); // valid expression for property 'NameEdit'. Space to enable Spice-style par sweep
ValRestrict = new QRegularExpressionValidator(Expr, this);
Expr.setPattern("[A-Za-z][A-Za-z0-9_]+");
ValName = new QRegularExpressionValidator(Expr,this);

checkSim = 0; comboSim = 0; comboType = 0; checkParam = 0;
editStart = 0; editStop = 0; editNumber = 0;
Expand Down Expand Up @@ -286,7 +288,7 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d)
CompNameEdit = new QLineEdit;
h5->addWidget(CompNameEdit);

CompNameEdit->setValidator(ValRestrict);
CompNameEdit->setValidator(ValName);
connect(CompNameEdit, SIGNAL(returnPressed()), SLOT(slotButtOK()));

showName = new QCheckBox(tr("display in schematic"));
Expand Down
3 changes: 2 additions & 1 deletion qucs/components/componentdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ protected slots:

private:
QVBoxLayout *all; // the mother of all widgets
QValidator *Validator, *ValRestrict, *Validator2;
QValidator *Validator, *ValRestrict, *Validator2,
*ValName;
QRegularExpression Expr;
QIntValidator *ValInteger;
QTableWidget *prop;
Expand Down

0 comments on commit 10bb12d

Please sign in to comment.