From 129648f92a4091b6c4dbccb30f163727ae8baf9c Mon Sep 17 00:00:00 2001 From: Kellermorph Date: Fri, 23 Oct 2026 13:21:29 +0200 Subject: [PATCH] Keep the terminal number out of the element properties The properties window builds a row for every element info key, so it also offered an editable "Terminal number" row -- both for one element and for several at once. The number is not a property of the element but derived from its label: typing there stored a value nothing reads, and the export has no column for it either (previous commit). Both windows skip the key now, the way they skip exclude_from_bom. The key itself stays an element info key, so the element editor keeps offering %{terminal_number} as a text variable. The test builds both windows for a terminal of the fixture and looks at the rows they offer. --- sources/ui/elementinfowidget.cpp | 7 ++++ sources/ui/multielementinfowidget.cpp | 3 ++ tests/qttest/tst_terminallabeldisplay.cpp | 41 +++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/sources/ui/elementinfowidget.cpp b/sources/ui/elementinfowidget.cpp index 0f204331a..4a4a11a66 100644 --- a/sources/ui/elementinfowidget.cpp +++ b/sources/ui/elementinfowidget.cpp @@ -313,6 +313,13 @@ void ElementInfoWidget::buildInterface() //line that currentInfo() then fills with "true"/"false". keys.removeAll(QStringLiteral("exclude_from_bom")); + //The terminal number is not a property of the element: it is + //derived from its label, so an edit row here would store a value + //nothing reads -- and the nomenclature query has no such column, + //which is why the export does not offer it either. The number + //stays a text variable (%{terminal_number}) of the element editor. + keys.removeAll(QETInformation::ELMT_TERMINAL_NUMBER); + for (auto str : keys) { ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETInformation::translatedInfoKey(str), this); diff --git a/sources/ui/multielementinfowidget.cpp b/sources/ui/multielementinfowidget.cpp index 49d31b56a..b150d36b1 100644 --- a/sources/ui/multielementinfowidget.cpp +++ b/sources/ui/multielementinfowidget.cpp @@ -496,6 +496,9 @@ void MultiElementInfoWidget::buildInterface() QStringList keys = QETInformation::elementInfoKeys(); //It has its own check box above, see ElementInfoWidget::buildInterface keys.removeAll(EXCLUDE_FROM_BOM); + //Not an editable property but derived from the label, see + //ElementInfoWidget::buildInterface + keys.removeAll(QETInformation::ELMT_TERMINAL_NUMBER); int line = 0; for (const QString &key : std::as_const(keys)) diff --git a/tests/qttest/tst_terminallabeldisplay.cpp b/tests/qttest/tst_terminallabeldisplay.cpp index 797e959be..cdba571aa 100644 --- a/tests/qttest/tst_terminallabeldisplay.cpp +++ b/tests/qttest/tst_terminallabeldisplay.cpp @@ -21,6 +21,10 @@ #include "TerminalStrip/terminalstrip.h" #include "dataBase/ui/elementquerywidget.h" #include "diagram.h" +#include "ui/elementinfopartwidget.h" +#include "ui/elementinfowidget.h" +#include "ui/multielementinfowidget.h" +#include #include #include "properties/elementdata.h" #include "qetgraphicsitem/dynamicelementtextitem.h" @@ -440,6 +444,43 @@ private slots: QCOMPARE(QETInformation::elementInfoToVar(QETInformation::ELMT_TERMINAL_NUMBER), QStringLiteral("%{terminal_number}")); } + + //The properties of a terminal have no row for its number: the number + //is derived from the label, so a row there would offer an edit which + //stores a value nothing reads -- the export has no column for it, and + //the drawing takes the number from the label + void propertiesHaveNoRowForTheTerminalNumber() + { + const QString fixture = QFINDTESTDATA("fixtures/every_feature.qet"); + QETProject project(fixture); + QCOMPARE(project.state(), QETProject::Ok); + + Element *element = terminalWithLabel(project, QStringLiteral("X1:1")); + QVERIFY(element); + + //The properties of one element... + ElementInfoWidget one(element); + QStringList one_rows; + const QList parts = one.findChildren(); + for (const ElementInfoPartWidget *part : parts) + one_rows << part->key(); + QVERIFY2(one_rows.contains(QETInformation::ELMT_LABEL), + "The other properties are still offered"); + QVERIFY2(!one_rows.contains(QETInformation::ELMT_TERMINAL_NUMBER), + "The terminal number is no property of the element"); + + //...and the properties of several elements at once + MultiElementInfoWidget many({element}); + QStringList rows; + const QList labels = many.findChildren(); + for (const QLabel *label : labels) + rows << label->text(); + QVERIFY2(rows.contains(QETInformation::translatedInfoKey(QETInformation::ELMT_LABEL)), + "The other properties are still offered"); + QVERIFY2(!rows.contains( + QETInformation::translatedInfoKey(QETInformation::ELMT_TERMINAL_NUMBER)), + "The terminal number is no property of the element"); + } }; QET_APP_TEST_MAIN(tst_terminallabeldisplay)