From 8d59d2579616286bb0cf0fa8ee96013a159d599f Mon Sep 17 00:00:00 2001 From: Laurent Trinques Date: Thu, 15 Oct 2026 16:26:45 +0200 Subject: [PATCH] Improve terminal_strip --- .../GraphicsItem/terminalstripdrawer.cpp | 48 ++++++++++++++- .../TerminalStrip/ui/terminalstripmodel.cpp | 59 ++++++++++++------- 2 files changed, 86 insertions(+), 21 deletions(-) diff --git a/sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp b/sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp index fb4040dae..db5558137 100644 --- a/sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp +++ b/sources/TerminalStrip/GraphicsItem/terminalstripdrawer.cpp @@ -468,6 +468,52 @@ TerminalColors terminalColors(const QSharedPointerdrawPolygon(housing); + + // Fine inner edge to give the housing some depth. + if (rect.width() >= 5.0 && rect.height() >= 12.0) { + const qreal margin = qMin(qreal(2.0), rect.width() * 0.12); + painter->drawLine(QPointF(rect.left() + margin, rect.top() + 3.0), + QPointF(rect.right() - margin, rect.top() + 3.0)); + + // Schematic screw head and slot. + const qreal radius = qMin(qreal(1.8), rect.width() * 0.12); + const qreal screw_y = rect.top() + rect.height() * 0.18; + painter->drawEllipse(QPointF(rect.center().x(), screw_y), radius, radius); + painter->drawLine(QPointF(rect.center().x() - radius * 0.65, screw_y), + QPointF(rect.center().x() + radius * 0.65, screw_y)); + + // Wire entry / clamp mark near the lower part of the terminal. + const qreal opening_width = qMin(qreal(5.0), rect.width() * 0.28); + const qreal opening_height = qMin(qreal(2.0), rect.height() * 0.025); + if (opening_width >= 1.0 && opening_height >= 1.0) { + painter->drawRect(QRectF(rect.center().x() - opening_width / 2, + rect.top() + rect.height() * 0.78, + opening_width, opening_height)); + } + } +} + /** * @brief drawStripes * Draw diagonal stripes of @a color inside @a rect. @@ -631,7 +677,7 @@ void TerminalStripDrawer::paint(QPainter *painter) if (fill_color_.isValid()) { painter->setBrush(QBrush(fill_color_)); } - painter->drawRect(terminal_rect); + drawTerminalBody(painter, terminal_rect); if (colors_.stripe.isValid()) { drawStripes(painter, terminal_rect, colors_.stripe); diff --git a/sources/TerminalStrip/ui/terminalstripmodel.cpp b/sources/TerminalStrip/ui/terminalstripmodel.cpp index 77ed70455..165944fa9 100644 --- a/sources/TerminalStrip/ui/terminalstripmodel.cpp +++ b/sources/TerminalStrip/ui/terminalstripmodel.cpp @@ -917,24 +917,26 @@ namespace { * any other width can be typed in the cell. * For ABB Entrelec the value is the spacing (pitch) given by the catalog. */ -struct WidthEntry { double mm; const char *label; }; +struct WidthEntry { double mm; const char *label; double section; }; const WidthEntry WIDTH_ENTRIES[] { - {5.1, "Weidmüller WDU 2.5"}, - {5.2, "WAGO 2002 (TOPJOB S)"}, - {6.0, "ABB Entrelec M 4/6"}, - {6.1, "Weidmüller WDU 4"}, - {6.2, "Phoenix Contact UT 4"}, - {8.0, "ABB Entrelec M 6/8, M 4/8"}, - {8.2, "Phoenix Contact UT 6"}, - {10.0, "ABB Entrelec M 10/10"}, - {10.2, "Phoenix Contact UT 10"}, - {11.9, "Weidmüller WDU 16/ZA"}, - {12.2, "Phoenix Contact UT 16"}, - {16.0, "Phoenix Contact UT 35, Weidmüller WDU 35N"}, - {26.0, "ABB Entrelec M 35/26.FF"}, - {31.0, "ABB Entrelec M 70/31.AF"}, - {35.0, "ABB Entrelec M 120/35.F"}, - {42.0, "ABB Entrelec M 300/42.FF"} + {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} }; QString widthItemText(double mm, const QString &label = QString()) @@ -980,7 +982,7 @@ QWidget *TerminalStripModelDelegate::createEditor(QWidget *parent, const QStyleO qcb->setObjectName(QStringLiteral("terminal_section")); qcb->addItem(tr("None (default)"), 0.0); //Usual sections, in mm2 - static const QVector sections_ {0.5, 0.75, 1, 1.5, 2.5, 4, 6, 10, 16, 25, 35, 50, 70, 95, 120, 150, 185, 240}; + static const QVector sections_ {0.5, 0.75, 1, 1.5, 2.5, 4, 6, 10, 16, 25, 35, 50, 70, 95, 120, 150, 185, 240, 300}; for (const auto section_ : sections_) { qcb->addItem(tr("%1 mm²").arg(QLocale().toString(section_, 'g', 6)), section_); } @@ -991,8 +993,25 @@ QWidget *TerminalStripModelDelegate::createEditor(QWidget *parent, const QStyleO auto qcb = new QComboBox(parent); qcb->setObjectName(QStringLiteral("terminal_width")); qcb->addItem(tr("None (default)"), 0.0); - for (const auto &entry : WIDTH_ENTRIES) { - qcb->addItem(widthItemText(entry.mm, QString::fromUtf8(entry.label)), entry.mm); + + // Show manufacturer products compatible with the section selected in this row. + const auto section_index = index.sibling(index.row(), SECTION_CELL); + bool section_ok = false; + const auto section = parsePositiveNumber(section_index.data(Qt::EditRole).toString(), §ion_ok); + bool has_compatible_entry = false; + if (section_ok && section > 0.0) { + for (const auto &entry : WIDTH_ENTRIES) { + if (qFuzzyCompare(1 + entry.section, 1 + section)) { + qcb->addItem(widthItemText(entry.mm, QString::fromUtf8(entry.label)), entry.mm); + has_compatible_entry = true; + } + } + } + // If the section has no catalog match (or is unspecified), keep all widths available. + if (!has_compatible_entry) { + for (const auto &entry : WIDTH_ENTRIES) { + qcb->addItem(widthItemText(entry.mm, QString::fromUtf8(entry.label)), entry.mm); + } } return qcb;