Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set validator for component name #814

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading