From c23999acd113c20da60a43f809231d8247c1c11e Mon Sep 17 00:00:00 2001 From: Levi Jetzer Date: Tue, 11 Aug 2026 16:09:34 +0200 Subject: [PATCH] Added width/height/depth properties to element definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds three new elementInformation keys — width, height, depth (in mm) — alongside the existing manufacturer/manufacturer_reference fields. These describe the physical dimensions of the device a symbol represents, set once per element definition. Values are restricted to plain decimal numbers via a QDoubleValidator on the information tree's item delegate (fixed-point, "." as decimal separator via QLocale::c(), independent of the UI language), so a later consumer can always parse them with toDouble() without additional sanitization. --- .../ui/elementpropertieseditorwidget.cpp | 19 ++++++++++++++++--- sources/qetinformation.cpp | 11 ++++++++++- sources/qetinformation.h | 3 +++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/sources/editor/ui/elementpropertieseditorwidget.cpp b/sources/editor/ui/elementpropertieseditorwidget.cpp index 6a09de091..01b4b6497 100644 --- a/sources/editor/ui/elementpropertieseditorwidget.cpp +++ b/sources/editor/ui/elementpropertieseditorwidget.cpp @@ -64,9 +64,22 @@ class EditorDelegate : public QItemDelegate { if(index.column() == 1) { - return QItemDelegate::createEditor(parent, - option, - index); + const QString key = index.sibling(index.row(), 0) + .data(Qt::UserRole).toString(); + + if (key == QETInformation::ELMT_WIDTH || + key == QETInformation::ELMT_HEIGHT || + key == QETInformation::ELMT_DEPTH) + { + auto *line_edit = new QLineEdit(parent); + auto *validator = new QDoubleValidator(0.0, 100000.0, 4, line_edit); + validator->setNotation(QDoubleValidator::StandardNotation); + validator->setLocale(QLocale::c()); + line_edit->setValidator(validator); + return line_edit; + } + + return QItemDelegate::createEditor(parent, option, index); } return nullptr; } diff --git a/sources/qetinformation.cpp b/sources/qetinformation.cpp index de28925ef..d5df1cea1 100644 --- a/sources/qetinformation.cpp +++ b/sources/qetinformation.cpp @@ -153,7 +153,10 @@ QStringList QETInformation::elementInfoKeys() ELMT_MACHINE_MANUFACTURER_REF, ELMT_SUPPLIER, ELMT_QUANTITY, - ELMT_UNITY, + ELMT_UNITY, + ELMT_WIDTH, + ELMT_HEIGHT, + ELMT_DEPTH, ELMT_AUX1, ELMT_DESCRIPTION_AUX1, ELMT_DESIGNATION_AUX1, @@ -268,6 +271,9 @@ QString QETInformation::translatedInfoKey(const QString &info) else if (info == ELMT_SUPPLIER) return QObject::tr("Fournisseur"); else if (info == ELMT_QUANTITY) return QObject::tr("Quantité"); else if (info == ELMT_UNITY) return QObject::tr("Unité"); + else if (info == ELMT_WIDTH) return QObject::tr("Largeur [mm]"); + else if (info == ELMT_HEIGHT) return QObject::tr("Hauteur [mm]"); + else if (info == ELMT_DEPTH) return QObject::tr("Profondeur [mm]"); else if (info == ELMT_LOCATION) return QObject::tr("Localisation (+)"); else if (info == COND_FUNCTION) return QObject::tr("Fonction"); else if (info == COND_TENSION_PROTOCOL) return QObject::tr("Tension / Protocole"); @@ -334,6 +340,9 @@ QStringList QETInformation::elementEditorElementInfoKeys() ELMT_SUPPLIER, ELMT_QUANTITY, ELMT_UNITY, + ELMT_WIDTH, + ELMT_HEIGHT, + ELMT_DEPTH, ELMT_AUX1, ELMT_DESCRIPTION_AUX1, ELMT_DESIGNATION_AUX1, diff --git a/sources/qetinformation.h b/sources/qetinformation.h index 2aab78e95..569d9021b 100644 --- a/sources/qetinformation.h +++ b/sources/qetinformation.h @@ -45,6 +45,9 @@ namespace QETInformation static QString ELMT_SUPPLIER = "supplier"; static QString ELMT_QUANTITY = "quantity"; static QString ELMT_UNITY = "unity"; + static QString ELMT_WIDTH = "width"; + static QString ELMT_HEIGHT = "height"; + static QString ELMT_DEPTH = "depth"; static QString ELMT_PLANT = "plant"; static QString ELMT_LOCATION = "location"; static QString ELMT_AUX1 = "auxiliary1";