Nomenclature: an element is where its folio is

element_nomenclature_view gave an element's own plant and location only,
which are empty unless typed into every element. A project structured by
its folios (=plant +location on the title block, %M / %LM) therefore
showed no place in the BOM, nomenclature tables and queries, although the
folio says where each device is -- the way EPLAN builds the device tag
from the page structure.

The view now falls back to the folio's plant and location when the
element has none of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DaTweety
2026-10-18 11:05:16 +02:00
parent 4fee464919
commit 4f0c493a7f
2 changed files with 30 additions and 2 deletions
+11 -2
View File
@@ -2804,10 +2804,15 @@ bool projectDataBase::createDataBase()
*/
void projectDataBase::createElementNomenclatureView()
{
//plant and location: the element's own, else its folio's. An
//installation is structured by its folios (=plant +location, the
//%M / %LM of the folio), as EPLAN builds the device tag from the
//page structure: an element drawn on a +UV1 folio is in +UV1
//without the information being typed into every element.
QString create_view ("CREATE VIEW element_nomenclature_view AS SELECT "
"ei.label AS label,"
"ei.plant AS plant,"
"ei.location AS location,"
"COALESCE(NULLIF(ei.plant, ''), di.plant) AS plant,"
"COALESCE(NULLIF(ei.location, ''), di.locmach) AS location,"
"ei.comment AS comment,"
"ei.function AS function,"
"ei.description AS description,"
@@ -2908,6 +2913,10 @@ void projectDataBase::createElementNomenclatureView()
columns_.replace(QStringLiteral("e.sub_type AS element_sub_type"), QStringLiteral("NULL AS element_sub_type"));
columns_.replace(QStringLiteral("di.title AS title"), QStringLiteral("st.title AS title"));
columns_.replace(QStringLiteral("di.folio AS folio"), QStringLiteral("st.folio AS folio"));
//A spare terminal is on no folio: no folio plant or location
//to fall back to, its own value as before
columns_.replace(QStringLiteral("di.plant"), QStringLiteral("''"));
columns_.replace(QStringLiteral("di.locmach"), QStringLiteral("''"));
columns_.replace(QStringLiteral("e.pos AS position"), QStringLiteral("st.position AS position"));
create_view += QStringLiteral(" UNION ALL SELECT ") + columns_ +
QStringLiteral(" FROM spare_terminal st"