diff --git a/sources/dataBase/ui/elementquerywidget.cpp b/sources/dataBase/ui/elementquerywidget.cpp index cdd6afc83..0258050d8 100644 --- a/sources/dataBase/ui/elementquerywidget.cpp +++ b/sources/dataBase/ui/elementquerywidget.cpp @@ -548,6 +548,12 @@ void ElementQueryWidget::setUpItems() { if (key == "formula" || key == "exclude_from_bom") continue; + // Terminal number is read-only and not a column of the nomenclature + // query, so offering it as an export/query column would break the + // export (query fails with "no such column"). It stays available as a + // text variable (%{terminal_number}) in the element editor. + if (key == QETInformation::ELMT_TERMINAL_NUMBER) + continue; auto item = new QListWidgetItem(QETInformation::translatedInfoKey(key), ui->m_var_list); item->setData(Qt::UserRole, key); diff --git a/tests/qttest/tst_terminallabeldisplay.cpp b/tests/qttest/tst_terminallabeldisplay.cpp index c21105ffb..797e959be 100644 --- a/tests/qttest/tst_terminallabeldisplay.cpp +++ b/tests/qttest/tst_terminallabeldisplay.cpp @@ -19,7 +19,9 @@ #include "qetapptest.h" #include "TerminalStrip/realterminal.h" #include "TerminalStrip/terminalstrip.h" +#include "dataBase/ui/elementquerywidget.h" #include "diagram.h" +#include #include "properties/elementdata.h" #include "qetgraphicsitem/dynamicelementtextitem.h" #include "qetgraphicsitem/element.h" @@ -407,6 +409,37 @@ private slots: QVERIFY(label->isVisible()); QCOMPARE(label->toPlainText(), QStringLiteral("X1:1")); } + + //The nomenclature/CSV export builds its columns from the element info + //keys, but its query has no terminal_number column: offering the key + //there made the export fail. The key itself stays an info key, so the + //Bauteileditor keeps offering %{terminal_number} as a text variable + void csvExportDoesNotOfferTerminalNumber() + { + ElementQueryWidget widget; + QListWidget *offer = widget.findChild(QStringLiteral("m_var_list")); + QVERIFY2(offer, "the widget which lists the exportable columns"); + + QStringList offered; + for (int row = 0; row < offer->count(); ++row) + offered.append(offer->item(row)->text()); + + const QString terminal_number = QETInformation::translatedInfoKey( + QETInformation::ELMT_TERMINAL_NUMBER); + QVERIFY2(!offered.contains(terminal_number), + qPrintable(QStringLiteral("The export must not offer \"%1\"") + .arg(terminal_number))); + + //The other columns are still offered... + QVERIFY(offered.contains( + QETInformation::translatedInfoKey(QETInformation::ELMT_LABEL))); + + //...and the variable is still a text variable + QVERIFY(QETInformation::elementInfoKeys().contains( + QETInformation::ELMT_TERMINAL_NUMBER)); + QCOMPARE(QETInformation::elementInfoToVar(QETInformation::ELMT_TERMINAL_NUMBER), + QStringLiteral("%{terminal_number}")); + } }; QET_APP_TEST_MAIN(tst_terminallabeldisplay)