From 884ec4bbb9c09e2768d4479d158c936b18c629f6 Mon Sep 17 00:00:00 2001 From: Levi Jetzer Date: Wed, 19 Aug 2026 17:58:16 +0200 Subject: [PATCH 1/2] Add editable "auto_num_locked"/"potential_isolating"/"exclude_from_bom" checkboxes to the element editor These elementInformation keys were previously only editable on an already-placed instance (via ElementInfoWidget on the diagram side). Since elementInformation values are seeded from the .elmt file's own block at placement time, a symbol author had no proper way to set these as the *default* for every future placement -- only a workaround via the generic, unvalidated key/value tree. Adds dedicated checkboxes to ElementPropertiesEditorWidget, mirroring ElementInfoWidget's own labels/behavior: auto_num_locked and potential_isolating inside the existing terminal-only group (m_terminal_gb, shown only for ElementData::Terminal), exclude_from_bom always visible regardless of type. Written after the generic tree loop so they take precedence over any stale raw entry for the same key. No new storage or file format change -- purely a missing editor UI for an already-existing mechanism. --- .../ui/elementpropertieseditorwidget.cpp | 30 +++++++++++++++---- .../ui/elementpropertieseditorwidget.ui | 30 +++++++++++++++++++ 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/sources/editor/ui/elementpropertieseditorwidget.cpp b/sources/editor/ui/elementpropertieseditorwidget.cpp index 5100c71fe..ee4789bf7 100644 --- a/sources/editor/ui/elementpropertieseditorwidget.cpp +++ b/sources/editor/ui/elementpropertieseditorwidget.cpp @@ -171,8 +171,17 @@ void ElementPropertiesEditorWidget::upDateInterface() ui->m_terminal_func_cb->setCurrentIndex( ui->m_terminal_func_cb->findData( m_data.m_terminal_function)); + + const DiagramContext &info = m_data.m_informations; + ui->m_auto_num_locked_cb->setChecked( + info.value(QStringLiteral("auto_num_locked")).toString() == QLatin1String("true")); + ui->m_potential_isolating_cb->setChecked( + info.value(QStringLiteral("potential_isolating")).toString() == QLatin1String("true")); } + ui->m_exclude_from_bom_cb->setChecked( + m_data.m_informations.value(QStringLiteral("exclude_from_bom")).toString() == QLatin1String("true")); + on_m_base_type_cb_currentIndexChanged(ui->m_base_type_cb->currentIndex()); } @@ -366,8 +375,8 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted() m_data.m_slave_type = ui->m_type_cb->currentData().value(); } m_data.m_contact_count = ui->m_number_ctc->value(); - } - else if (m_data.m_type == ElementData::Master) { + } else if (m_data.m_type == ElementData::Master) + { m_data.m_master_type = ui->m_master_type_cb->currentData().value(); //If the checkbox is checked, save the number; otherwise, -1 (infinity) @@ -382,13 +391,12 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted() } else { readSlaveGroupsFromTable(); } - } - else if (m_data.m_type == ElementData::Terminal) + } else if (m_data.m_type == ElementData::Terminal) { m_data.m_terminal_type = ui->m_terminal_type_cb->currentData().value(); m_data.m_terminal_function = ui->m_terminal_func_cb->currentData().value(); } - + for (QTreeWidgetItem *qtwi : ui->m_tree->invisibleRootItem()->takeChildren()) { QString txt = qtwi->text(1); @@ -399,7 +407,17 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted() m_data.m_informations.addValue(qtwi->data(0, Qt::UserRole).toString(), txt); } - + + if (m_data.m_type == ElementData::Terminal) + { + m_data.m_informations.addValue(QStringLiteral("auto_num_locked"), + ui->m_auto_num_locked_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false")); + m_data.m_informations.addValue(QStringLiteral("potential_isolating"), + ui->m_potential_isolating_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false")); + } + m_data.m_informations.addValue(QStringLiteral("exclude_from_bom"), + ui->m_exclude_from_bom_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false")); + this->close(); } diff --git a/sources/editor/ui/elementpropertieseditorwidget.ui b/sources/editor/ui/elementpropertieseditorwidget.ui index 91802bfb0..98694eb57 100644 --- a/sources/editor/ui/elementpropertieseditorwidget.ui +++ b/sources/editor/ui/elementpropertieseditorwidget.ui @@ -54,6 +54,16 @@ + + + + margin: 5px; font-weight: bold; + + + Exclure de la nomenclature + + + @@ -229,6 +239,26 @@ + + + + margin: 5px; font-weight: bold; + + + Verrouiller la numérotation automatique + + + + + + + margin: 5px; font-weight: bold; + + + Séparation de potentiel + + + From 622791f99440c4f7657e5470c78180b929fdf460 Mon Sep 17 00:00:00 2001 From: Levi Jetzer Date: Fri, 21 Aug 2026 15:59:06 +0200 Subject: [PATCH 2/2] Remove auto_num_locked/potential_isolating/exclude_from_bom checkboxes' "false" writes, delete key instead Unchecking a checkbox previously wrote the key with value "false" rather than omitting it -- behaviorally identical to every consumer (all three do a case-sensitive == "true" comparison), but left dead entries cluttering the .elmt file, inconsistent with how other elementInformation fields (manufacturer, designation) are only present when actually set. Now removes the key entirely when unchecked. --- .../ui/elementpropertieseditorwidget.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/sources/editor/ui/elementpropertieseditorwidget.cpp b/sources/editor/ui/elementpropertieseditorwidget.cpp index ee4789bf7..391a14ba1 100644 --- a/sources/editor/ui/elementpropertieseditorwidget.cpp +++ b/sources/editor/ui/elementpropertieseditorwidget.cpp @@ -410,13 +410,21 @@ void ElementPropertiesEditorWidget::on_m_buttonBox_accepted() if (m_data.m_type == ElementData::Terminal) { - m_data.m_informations.addValue(QStringLiteral("auto_num_locked"), - ui->m_auto_num_locked_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false")); - m_data.m_informations.addValue(QStringLiteral("potential_isolating"), - ui->m_potential_isolating_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false")); + if (ui->m_auto_num_locked_cb->isChecked()) + m_data.m_informations.addValue(QStringLiteral("auto_num_locked"), QStringLiteral("true")); + else + m_data.m_informations.remove(QStringLiteral("auto_num_locked")); + + if (ui->m_potential_isolating_cb->isChecked()) + m_data.m_informations.addValue(QStringLiteral("potential_isolating"), QStringLiteral("true")); + else + m_data.m_informations.remove(QStringLiteral("potential_isolating")); } - m_data.m_informations.addValue(QStringLiteral("exclude_from_bom"), - ui->m_exclude_from_bom_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false")); + + if (ui->m_exclude_from_bom_cb->isChecked()) + m_data.m_informations.addValue(QStringLiteral("exclude_from_bom"), QStringLiteral("true")); + else + m_data.m_informations.remove(QStringLiteral("exclude_from_bom")); this->close(); }