Skip to content

Commit

Permalink
set validator for Node name
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee committed Sep 13, 2023
1 parent 71b8e44 commit efa01a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions tools/cabana/detailwidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ EditMessageDialog::EditMessageDialog(const MessageId &msg_id, const QString &tit
size_spin->setValue(size);

form_layout->addRow(tr("Node"), node = new QLineEdit(this));
node->setValidator(new NameValidator(name_edit));
form_layout->addRow(tr("Comment"), comment_edit = new QTextEdit(this));
form_layout->addRow(btn_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel));

Expand Down
4 changes: 2 additions & 2 deletions tools/cabana/signalview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,12 @@ void SignalItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op

QWidget *SignalItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const {
auto item = (SignalModel::Item *)index.internalPointer();
if (item->type == SignalModel::Item::Name || item->type == SignalModel::Item::Offset ||
if (item->type == SignalModel::Item::Name || item->type == SignalModel::Item::Node || item->type == SignalModel::Item::Offset ||
item->type == SignalModel::Item::Factor || item->type == SignalModel::Item::MultiplexValue ||
item->type == SignalModel::Item::Min || item->type == SignalModel::Item::Max) {
QLineEdit *e = new QLineEdit(parent);
e->setFrame(false);
e->setValidator(item->type == SignalModel::Item::Name ? name_validator : double_validator);
e->setValidator(item->type == SignalModel::Item::Name || item->type == SignalModel::Item::Node ? name_validator : double_validator);

if (item->type == SignalModel::Item::Name) {
QCompleter *completer = new QCompleter(dbc()->signalNames());
Expand Down

0 comments on commit efa01a4

Please sign in to comment.