Add options to leave junctions and contact blocks out of the parts list (#1178)

Since #849 the parts list has a row for every contact block (slave) and
terminal-type element. Users who draw the dots and bends where wires
branch as terminal-type symbols (114_connections) get one empty row per
junction: 109 of 151 rows on one reported cabinet.

Two options, both off by default so existing exports are unchanged:
- leave out the contact blocks: --no-slaves, "no_slaves" in qet_export,
  or uncheck the new "Contacts esclaves" element type in the dialog;
- leave out the junctions: terminal-type elements with no label,
  designation, manufacturer or manufacturer reference. --no-junctions,
  "no_junctions", or "Laisser de côté les jonctions" in the dialog.
  A terminal block with a label or a part number stays.

The element type filter had no box for slaves, so every query it built
left them out: the export dialog never listed contact blocks, although
the command line has since #849. The dialog now checks the new box by
default and gives the same rows as --export-bom. The box is unchecked by
default elsewhere, so nomenclature tables keep their rows.

docs/smart-device-bom.md still said slaves and terminals were excluded;
corrected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-05 22:08:44 +13:00
parent 32f7b94594
commit 8434b88eb8
17 changed files with 273 additions and 39 deletions
+75 -18
View File
@@ -56,6 +56,7 @@ ElementQueryWidget::ElementQueryWidget(QWidget *parent) :
m_button_group.addButton(ui->m_protection_cb, 5);
m_button_group.addButton(ui->m_thumbnail_cb, 6);
m_button_group.addButton(ui->m_plc_cb, 7);
m_button_group.addButton(ui->m_slave_cb, 8);
connect(&m_button_group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::idClicked), [this](int id)
{
@@ -78,27 +79,12 @@ ElementQueryWidget::ElementQueryWidget(QWidget *parent) :
}
else
{
int checked = 0;
for (int i=1 ; i<8 ; ++i) {
if (m_button_group.button(i)->isChecked()) {++checked;}
}
switch (checked)
{
case 0 :
check_box->setCheckState(Qt::Unchecked);
break;
case 7:
check_box->setCheckState(Qt::Checked);
break;
default:
check_box->setCheckState(Qt::PartiallyChecked);
break;
}
updateAllCheckState();
}
updateQueryLine();
});
updateAllCheckState();
setUpItems();
fillSavedQuery();
@@ -203,8 +189,12 @@ void ElementQueryWidget::setQuery(const QString &query)
if (ui->m_plc_cb->isChecked()) {
++c;
}
ui->m_slave_cb->setChecked (str_type.contains(ElementData::typeToString(ElementData::Slave)));
if (ui->m_slave_cb->isChecked()) {
++c;
}
if (c == 7) {
if (c == 8) {
ui->m_all_cb->setCheckState(Qt::Checked);
} else if (c > 0) {
ui->m_all_cb->setCheckState(Qt::PartiallyChecked);
@@ -395,6 +385,11 @@ QString ElementQueryWidget::queryStr() const
where += QStringLiteral(" element_sub_type = '") += ElementData::masterTypeToString(ElementData::PLC) += "'";
b = true;
}
if (ui->m_slave_cb->isChecked()) {
if (b) where +=" OR";
where += QStringLiteral(" element_type = '") += ElementData::typeToString(ElementData::Slave) += "'";
b = true;
}
where.append(")");
if (where == " WHERE ()") {
@@ -406,6 +401,10 @@ QString ElementQueryWidget::queryStr() const
// widget's query reads FROM that view, so a flagged element never
// reaches this point in the first place.
if (!m_extra_filter.isEmpty()) {
filter_ += QStringLiteral(" AND ") + m_extra_filter;
}
if (where.isEmpty() && !filter_.isEmpty()) {
filter_.remove(0, 4); //Remove the first " AND" of filter.
filter_.prepend( " WHERE");
@@ -456,6 +455,64 @@ void ElementQueryWidget::setCount(QString text, bool set)
updateQueryLine();
}
/**
@brief ElementQueryWidget::setSlavesIncluded
Check or uncheck the contact blocks (slave elements) in the element
type filter. The box is unchecked by default, which keeps the tables
made before it existed as they were.
@param included
*/
void ElementQueryWidget::setSlavesIncluded(bool included)
{
ui->m_slave_cb->setChecked(included);
updateAllCheckState();
updateQueryLine();
}
/**
@brief ElementQueryWidget::updateAllCheckState
Set the "all" check box from the element type check boxes.
*/
void ElementQueryWidget::updateAllCheckState()
{
int checked = 0;
for (int i=1 ; i<9 ; ++i) {
if (m_button_group.button(i)->isChecked()) {++checked;}
}
switch (checked)
{
case 0 :
ui->m_all_cb->setCheckState(Qt::Unchecked);
break;
case 8:
ui->m_all_cb->setCheckState(Qt::Checked);
break;
default:
ui->m_all_cb->setCheckState(Qt::PartiallyChecked);
break;
}
}
/**
@brief ElementQueryWidget::setExtraFilter
Add a condition every row of the query must meet, on top of the filters
chosen in this widget.
@param text : the condition, ex : "label != ''"
@param set :
true by default -> the condition is used.
false -> the condition is removed.
*/
void ElementQueryWidget::setExtraFilter(const QString &text, bool set)
{
if (set) {
m_extra_filter = text;
} else {
m_extra_filter.clear();
}
updateQueryLine();
}
/**
@brief ElementQueryWidget::updateQueryLine
*/
+5 -1
View File
@@ -45,6 +45,8 @@ class ElementQueryWidget : public QWidget
QString queryStr() const;
void setGroupBy(QString text, bool set = true);
void setCount(QString text, bool set = true);
void setSlavesIncluded(bool included);
void setExtraFilter(const QString &text, bool set = true);
static QString modelIdentifier() {return "nomenclature";}
@@ -67,6 +69,7 @@ class ElementQueryWidget : public QWidget
void on_m_choosen_list_itemDoubleClicked(QListWidgetItem *item);
void updateQueryLine();
void updateAllCheckState();
QStringList selectedKeys() const;
void setUpItems();
QPair<int, QString> FilterFor(const QString &key) const;
@@ -82,7 +85,8 @@ class ElementQueryWidget : public QWidget
QList <QListWidgetItem *> m_items_list;
QString m_custom_query,
m_group_by,
m_count;
m_count,
m_extra_filter;
QHash <QString, QPair<int, QString>> m_filter;
};
+10
View File
@@ -318,6 +318,16 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="m_slave_cb">
<property name="text">
<string>Contacts esclaves</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>