Feature: Allow excluding specific elements from BOM (Nomenclature)

This commit is contained in:
Kellermorph
2026-05-28 12:23:54 +02:00
parent 19704cf5ca
commit c071e92c58
6 changed files with 122 additions and 99 deletions
+2 -2
View File
@@ -383,7 +383,7 @@ void projectDataBase::createElementNomenclatureView()
"ei.supplier_auxiliary4 AS supplier_auxiliary4,"
"ei.quantity_auxiliary4 AS quantity_auxiliary4,"
"ei.unity_auxiliary4 AS unity_auxiliary4,"
"ei.exclude_from_bom AS exclude_from_bom,"
"d.pos AS diagram_position,"
"e.type AS element_type,"
@@ -392,7 +392,7 @@ void projectDataBase::createElementNomenclatureView()
"di.folio AS folio,"
"e.pos AS position "
" FROM element_info ei, diagram_info di, element e, diagram d"
" WHERE ei.element_uuid = e.uuid AND e.diagram_uuid = d.uuid AND di.diagram_uuid = d.uuid");
" WHERE ei.element_uuid = e.uuid AND e.diagram_uuid = d.uuid AND di.diagram_uuid = d.uuid AND (ei.exclude_from_bom IS NOT 'true')");
QSqlQuery query(m_data_base);
if (!query.exec(create_view)) {
+6 -1
View File
@@ -373,6 +373,11 @@ QString ElementQueryWidget::queryStr() const
where.clear();
}
QString exclude_condition = "(exclude_from_bom IS NULL OR exclude_from_bom != '1')";
filter_ += " AND " + exclude_condition;
// -------------------------------------------------------------
if (where.isEmpty() && !filter_.isEmpty()) {
filter_.remove(0, 4); //Remove the first " AND" of filter.
filter_.prepend( " WHERE");
@@ -456,7 +461,7 @@ void ElementQueryWidget::setUpItems()
{
for(QString key : QETInformation::elementInfoKeys())
{
if (key == "formula")
if (key == "formula" || key == "exclude_from_bom")
continue;
auto item = new QListWidgetItem(QETInformation::translatedInfoKey(key), ui->m_var_list);
+2 -1
View File
@@ -189,7 +189,8 @@ QStringList QETInformation::elementInfoKeys()
ELMT_MACHINE_MANUFACTURER_REF_AUX4,
ELMT_SUPPLIER_AUX4,
ELMT_QUANTITY_AUX4,
ELMT_UNITY_AUX4, };
ELMT_UNITY_AUX4,
"exclude_from_bom" };
return list;
}
+27 -16
View File
@@ -165,6 +165,9 @@ void ElementInfoWidget::enableLiveEdit()
if (m_potential_isolating_cb) {
connect(m_potential_isolating_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
}
if (m_exclude_from_bom_cb) {
connect(m_exclude_from_bom_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
}
}
/**
@@ -180,6 +183,9 @@ void ElementInfoWidget::disableLiveEdit()
if (m_potential_isolating_cb) {
disconnect(m_potential_isolating_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
}
if (m_exclude_from_bom_cb) {
disconnect(m_exclude_from_bom_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
}
}
/**
@@ -201,19 +207,26 @@ void ElementInfoWidget::buildInterface()
ui->scroll_vlayout->addWidget(eipw);
m_eipw_list << eipw;
}
ui->scroll_vlayout->addStretch();
// Existing potential isolating checkbox
m_potential_isolating_cb = new QCheckBox(tr("Séparation de potentiel"), this);
m_potential_isolating_cb->setStyleSheet(QStringLiteral("margin: 5px; font-weight: bold;"));
// English: Initialize and style the BOM exclusion checkbox
m_exclude_from_bom_cb = new QCheckBox(tr("Exclure de la nomenclature"), this);
m_exclude_from_bom_cb->setStyleSheet(QStringLiteral("margin: 5px; font-weight: bold;"));
if (QVBoxLayout *mainLayout = qobject_cast<QVBoxLayout*>(this->layout())) {
mainLayout->insertWidget(1, m_potential_isolating_cb);
// English: Insert the new checkbox into the main vertical layout
mainLayout->insertWidget(2, m_exclude_from_bom_cb);
}
// Show checkbox only if the element is a terminal
// English: BOM exclusion applies to all elements, so it's always visible
m_exclude_from_bom_cb->setVisible(true);
// Show checkbox only if the element is a terminal
if (m_element.data()->elementData().m_type == ElementData::Terminal) {
ui->m_auto_num_locked_cb->setVisible(true);
m_potential_isolating_cb->setVisible(true);
@@ -260,14 +273,13 @@ void ElementInfoWidget::updateUi()
}
// Load the lock status for auto numbering
if (m_element->elementData().m_type == ElementData::Terminal) {
QString lock_value = element_info.value(QStringLiteral("auto_num_locked")).toString();
ui->m_auto_num_locked_cb->setChecked(lock_value == QLatin1String("true"));
// ... (bestehender Terminal-Code für auto_num_locked und potential_isolating) ...
}
// English: Load the potential isolating status from the element information mapping
if (m_potential_isolating_cb) {
QString isolating_value = element_info.value(QStringLiteral("potential_isolating")).toString();
m_potential_isolating_cb->setChecked(isolating_value == QLatin1String("true"));
}
// English: Load the BOM exclusion status from the element information mapping
if (m_exclude_from_bom_cb) {
QString exclude_bom_value = element_info.value(QStringLiteral("exclude_from_bom")).toString();
m_exclude_from_bom_cb->setChecked(exclude_bom_value == QLatin1String("true"));
}
if (m_live_edit) {
@@ -299,15 +311,14 @@ DiagramContext ElementInfoWidget::currentInfo() const
// Save the auto numbering lock status
if (m_element->elementData().m_type == ElementData::Terminal) {
info_.addValue(QStringLiteral("auto_num_locked"), ui->m_auto_num_locked_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false"));
if (m_potential_isolating_cb) {
info_.addValue(QStringLiteral("potential_isolating"), m_potential_isolating_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false"));
}
}
if (m_exclude_from_bom_cb) {
info_.addValue(QStringLiteral("exclude_from_bom"), m_exclude_from_bom_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false"));
}
return info_;
}
/**
@brief ElementInfoWidget::firstActivated
Slot activated when this widget is show.
+1
View File
@@ -73,6 +73,7 @@ class ElementInfoWidget : public AbstractElementPropertiesEditorWidget
Ui::ElementInfoWidget *ui;
QList <ElementInfoPartWidget *> m_eipw_list;
QCheckBox *m_potential_isolating_cb = nullptr;
QCheckBox *m_exclude_from_bom_cb = nullptr;
bool m_first_activation;
bool m_ui_builded = false;
};