mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-05 18:54:14 +02:00
Added width/height/depth properties to element definitions
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user