Terminal catalog: more manufacturer widths and manufacturer filter

Extend the terminal catalog (terminalcatalog.h) with the widths of
more terminal blocks, from the catalogs of Phoenix Contact (UT),
Weidmuller (WDU), WAGO (TOPJOB S 2002/2006), ABB Entrelec (M series)
and Legrand (Viking 3). For Legrand and ABB Entrelec the value is the
pitch given by the catalog.

Each entry now carries its manufacturer, and the element properties
dialog gets a "Manufacturer" combo box before the width one. The list
of widths is filtered by manufacturer and by the selected section; if
the manufacturer has nothing for that section, all its terminals are
listed. The combo box is created by the code, no change in the .ui.
This commit is contained in:
Laurent Trinques
2026-10-16 12:10:30 +02:00
parent 5e28ec4246
commit 3365817cf1
2 changed files with 111 additions and 21 deletions
+40 -19
View File
@@ -20,6 +20,7 @@
#include <QLocale>
#include <QString>
#include <QStringList>
#include <QVector>
/**
@@ -28,6 +29,7 @@
* usual sections (mm2) and widths (mm) of the terminals sold by the manufacturers.
* Only the values found in the catalogs of the manufacturers are listed,
* any other value can be typed by the user.
* For Legrand and ABB Entrelec the value is the pitch ("pas") of the catalog.
*/
namespace TerminalCatalog
{
@@ -35,7 +37,7 @@ namespace TerminalCatalog
* Width (mm) of a terminal sold by a manufacturer.
* For ABB Entrelec the value is the spacing (pitch) given by the catalog.
*/
struct WidthEntry { double mm; const char *label; double section; };
struct WidthEntry { double mm; const char *label; double section; const char *manufacturer; };
inline const QVector<double> &sections()
{
@@ -91,27 +93,46 @@ namespace TerminalCatalog
inline const QVector<WidthEntry> &widthEntries()
{
static const QVector<WidthEntry> entries_ {
{5.1, "Weidmüller WDU 2.5", 2.5},
{5.2, "WAGO 2002 (TOPJOB S)", 2.5},
{6.0, "ABB Entrelec M 4/6", 4.0},
{6.1, "Weidmüller WDU 4", 4.0},
{6.2, "Phoenix Contact UT 4", 4.0},
{8.0, "ABB Entrelec M 6/8", 6.0},
{8.0, "ABB Entrelec M 4/8", 4.0},
{8.2, "Phoenix Contact UT 6", 6.0},
{10.0, "ABB Entrelec M 10/10", 10.0},
{10.2, "Phoenix Contact UT 10", 10.0},
{11.9, "Weidmüller WDU 16/ZA", 16.0},
{12.2, "Phoenix Contact UT 16", 16.0},
{16.0, "Phoenix Contact UT 35", 35.0},
{16.0, "Weidmüller WDU 35N", 35.0},
{26.0, "ABB Entrelec M 35/26.FF", 35.0},
{31.0, "ABB Entrelec M 70/31.AF", 70.0},
{35.0, "ABB Entrelec M 120/35.F", 120.0},
{42.0, "ABB Entrelec M 300/42.FF", 300.0}
{5.0, "ABB Entrelec MA 2.5/5", 2.5, "ABB Entrelec"},
{5.1, "Weidmüller WDU 2.5", 2.5, "Weidmüller"},
{5.2, "WAGO 2002 (TOPJOB S)", 2.5, "WAGO"},
{6.0, "ABB Entrelec M 4/6", 4.0, "ABB Entrelec"},
{6.0, "Legrand Viking 3 (4 mm²)", 4.0, "Legrand"},
{6.1, "Weidmüller WDU 4", 4.0, "Weidmüller"},
{6.2, "Phoenix Contact UT 4", 4.0, "Phoenix Contact"},
{7.5, "WAGO 2006 (TOPJOB S)", 6.0, "WAGO"},
{7.9, "Weidmüller WDU 6", 6.0, "Weidmüller"},
{8.0, "ABB Entrelec M 6/8", 6.0, "ABB Entrelec"},
{8.0, "ABB Entrelec M 4/8", 4.0, "ABB Entrelec"},
{8.2, "Phoenix Contact UT 6", 6.0, "Phoenix Contact"},
{10.0, "ABB Entrelec M 10/10", 10.0, "ABB Entrelec"},
{10.2, "Phoenix Contact UT 10", 10.0, "Phoenix Contact"},
{11.9, "Weidmüller WDU 16/ZA", 16.0, "Weidmüller"},
{12.0, "ABB Entrelec M 16/12", 16.0, "ABB Entrelec"},
{12.0, "Legrand Viking 3 (16 mm²)", 16.0, "Legrand"},
{12.2, "Phoenix Contact UT 16", 16.0, "Phoenix Contact"},
{16.0, "ABB Entrelec M 35/16", 35.0, "ABB Entrelec"},
{16.0, "Phoenix Contact UT 35", 35.0, "Phoenix Contact"},
{16.0, "Weidmüller WDU 35N", 35.0, "Weidmüller"},
{26.0, "ABB Entrelec M 35/26.FF", 35.0, "ABB Entrelec"},
{31.0, "ABB Entrelec M 70/31.AF", 70.0, "ABB Entrelec"},
{35.0, "ABB Entrelec M 120/35.F", 120.0, "ABB Entrelec"},
{42.0, "ABB Entrelec M 300/42.FF", 300.0, "ABB Entrelec"}
};
return entries_;
}
/// Manufacturers of the catalog, in the order of the first entry.
inline QStringList manufacturers()
{
QStringList list_;
for (const auto &entry : widthEntries()) {
const auto name_ = QString::fromUtf8(entry.manufacturer);
if (!list_.contains(name_)) {
list_ << name_;
}
}
return list_;
}
}
#endif // TERMINALCATALOG_H
@@ -39,6 +39,7 @@
#include <QGroupBox>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QIcon>
#include <QLabel>
#include <QLocale>
@@ -95,6 +96,50 @@ double leadingNumber(const QString &text)
return number.toDouble();
}
/// The manufacturer combo box of the terminal group box, created by the code.
QComboBox *manufacturerCombo(QWidget *width_cb)
{
return width_cb->parentWidget()->findChild<QComboBox *>(QStringLiteral("m_terminal_manufacturer_cb"));
}
/// Insert a "Manufacturer" row in the grid layout of the terminal group box, just before the width row.
QComboBox *createManufacturerCombo(QComboBox *width_cb)
{
auto *parent_ = width_cb->parentWidget();
auto *grid_ = qobject_cast<QGridLayout *>(parent_ ? parent_->layout() : nullptr);
if (!grid_)
return nullptr;
int row_ = 0, column_ = 0, row_span_ = 0, column_span_ = 0;
const auto index_ = grid_->indexOf(width_cb);
if (index_ < 0)
return nullptr;
grid_->getItemPosition(index_, &row_, &column_, &row_span_, &column_span_);
//Move down the rows from the width row
QList<QPair<QWidget *, QPair<int,int>>> moved_;
for (int i = 0; i < grid_->count(); ++i) {
int r = 0, c = 0, rs = 0, cs = 0;
grid_->getItemPosition(i, &r, &c, &rs, &cs);
if (r >= row_ && grid_->itemAt(i)->widget()) {
moved_.append({grid_->itemAt(i)->widget(), {r, c}});
}
}
for (const auto &m : moved_) {
grid_->removeWidget(m.first);
}
for (const auto &m : moved_) {
grid_->addWidget(m.first, m.second.first + 1, m.second.second);
}
auto *label_ = new QLabel(QObject::tr("Manufacturer"), parent_);
auto *cb_ = new QComboBox(parent_);
cb_->setObjectName(QStringLiteral("m_terminal_manufacturer_cb"));
grid_->addWidget(label_, row_, 0);
grid_->addWidget(cb_, row_, 1);
return cb_;
}
/// Value of a terminal size combo (picked in the list or typed).
double comboValue(const QComboBox *cb)
{
@@ -446,6 +491,22 @@ void ElementPropertiesEditorWidget::populateTerminalSizeCombos(double section, d
}
setComboValue(ui->m_terminal_section_cb, section, tr(" mm²"));
auto *man_cb = manufacturerCombo(ui->m_terminal_width_cb);
if (!man_cb) {
man_cb = createManufacturerCombo(ui->m_terminal_width_cb);
if (man_cb) {
connect(man_cb, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, [this]() { refreshTerminalWidthCombo(); });
}
}
if (man_cb) {
QSignalBlocker man_blocker(man_cb);
man_cb->clear();
man_cb->addItem(tr("All manufacturers"), QString());
for (const auto &name_ : TerminalCatalog::manufacturers()) {
man_cb->addItem(name_, name_);
}
}
connect(ui->m_terminal_section_cb, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, [this]() { refreshTerminalWidthCombo(); });
connect(ui->m_terminal_section_cb->lineEdit(), &QLineEdit::editingFinished,
@@ -508,10 +569,17 @@ void ElementPropertiesEditorWidget::refreshTerminalWidthCombo()
+ QStringLiteral(" - ") + QString::fromUtf8(entry.label);
};
const auto *man_cb = manufacturerCombo(ui->m_terminal_width_cb);
const auto manufacturer = man_cb ? man_cb->currentData().toString() : QString();
auto manufacturer_ok = [&manufacturer](const TerminalCatalog::WidthEntry &entry) {
return manufacturer.isEmpty() || manufacturer == QString::fromUtf8(entry.manufacturer);
};
//Prefer the terminals of the selected section, if the selected manufacturer has some
bool has_compatible_entry = false;
if (section > 0) {
for (const auto &entry : TerminalCatalog::widthEntries()) {
if (qFuzzyCompare(1 + entry.section, 1 + section)) {
if (manufacturer_ok(entry) && qFuzzyCompare(1 + entry.section, 1 + section)) {
has_compatible_entry = true;
break;
}
@@ -522,7 +590,8 @@ void ElementPropertiesEditorWidget::refreshTerminalWidthCombo()
ui->m_terminal_width_cb->clear();
ui->m_terminal_width_cb->addItem(tr("None (default)"), 0.0);
for (const auto &entry : TerminalCatalog::widthEntries()) {
if (!has_compatible_entry || qFuzzyCompare(1 + entry.section, 1 + section)) {
if (manufacturer_ok(entry)
&& (!has_compatible_entry || qFuzzyCompare(1 + entry.section, 1 + section))) {
ui->m_terminal_width_cb->addItem(item_text(entry), entry.mm);
}
}