24 #include <QFormLayout>
27 #include <QLayoutItem>
29 #include <QStyleOptionViewItem>
43 setToolTip(description);
44 setWhatsThis(description);
54 setTitle(parent_property->
getName());
61 const QString &title,
const QString &description)
62 : QGroupBox(title, parent), d_ptr(d_pointer)
65 setToolTip(description);
66 setWhatsThis(description);
78 d_ptr->EditorWidgets.clear();
82 while (layout()->count() > 0 && (child = layout()->takeAt(0)) !=
nullptr)
86 delete child->widget();
94 if (d_ptr->Properties.isEmpty())
99 QFormLayout* tmpFormLayout =
new QFormLayout(
this);
100 setLayout(tmpFormLayout);
102 for (
int i = 0; i < d_ptr->Properties.count(); ++i)
105 VProperty* tmpProperty = d_ptr->Properties.value(i,
nullptr);
117 for (
int j = 0; j < children.size(); ++j)
119 buildEditor(children[j], tmpFormLayout);
121 Qt::UniqueConnection);
123 d_ptr->Properties.insert(i, children[j]);
129 tmpFormLayout->addRow(tmpNewFormWidget);
138 else if (tmpProperty->
type() ==
"widget")
141 tmpFormLayout->addRow(tmpWidgetProperty->
getWidget());
146 buildEditor(tmpProperty, tmpFormLayout);
155 QWidget* tmpEditor =
property->createEditor(
this, QStyleOptionViewItem(),
nullptr);
158 tmpEditor =
new QWidget(
this);
166 tmpEditor->installEventFilter(
this);
169 property->setEditorData(tmpEditor);
175 QLabel *label =
new QLabel(property->
getName());
176 label->setMinimumWidth(80);
177 label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
178 formLayout->addRow(label, tmpEditor);
182 QLabel *label =
new QLabel(
"<b>"+property->
getName()+
"</b>");
183 label->setMinimumWidth(80);
184 label->setAlignment(Qt::AlignLeft);
185 formLayout->addRow(label, tmpEditor);
186 formLayout->setLabelAlignment(Qt::AlignLeft);
190 QLabel *label =
new QLabel(property->
getName());
191 label->setMinimumWidth(80);
192 label->setAlignment(Qt::AlignRight);
193 formLayout->addRow(label, tmpEditor);
194 formLayout->setFormAlignment(Qt::AlignTop);
202 for (
int i = 0; i < d_ptr->Properties.count(); ++i)
210 for (
int i = 0; i < d_ptr->Properties.count(); ++i)
218 if (row < 0 || row >= d_ptr->EditorWidgets.count() || row >= d_ptr->Properties.count())
224 VProperty* tmpProperty = d_ptr->Properties[row];
229 else if (tmpEditorWidget.
Editor && tmpProperty)
233 if (oldValue != newValue)
239 emit propertyDataSubmitted(tmpProperty);
244 emit propertyDataSubmitted(parent);
252 if (row < 0 || row >= d_ptr->EditorWidgets.count() || row >= d_ptr->Properties.count())
258 VProperty* tmpProperty = d_ptr->Properties[row];
263 else if (tmpEditorWidget.
Editor && tmpProperty)
271 d_ptr->UpdateEditors = auto_commit;
299 if (!d_ptr->UpdateEditors)
304 QWidget* editor = qobject_cast<QWidget*>(
object);
310 if (event->type() == QEvent::KeyPress)
312 switch (
static_cast<QKeyEvent *
>(event)->key())
315 case Qt::Key_Backtab:
326 else if (event->type() == QEvent::FocusOut || (event->type() == QEvent::Hide && editor->isWindow()))
331 else if (event->type() == QEvent::ShortcutOverride)
333 if (
static_cast<QKeyEvent*
>(event)->key() == Qt::Key_Escape)
348 return QGroupBox::eventFilter(
object, event);
362 for (
int i = 0; i < d_ptr->EditorWidgets.count(); ++i)
365 if (tmpEditorWidget.
Editor == editor)
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const
Get the data how it should be displayed.
void childChanged(const QVariant &value, int typeForParent)
virtual int getRowCount() const
Gets the number of children.
virtual QString getName() const
Gets the name of the property.
virtual bool setEditorData(QWidget *editor)
Sets the property's data to the editor (returns false, if the standard delegate should do that)
virtual void setValue(const QVariant &value)
Sets the value of the property.
virtual QString getDescription() const
Gets the name of the property.
virtual VProperty * getParent() const
Gets the parent of this property.
virtual QVariant getEditorData(const QWidget *editor) const
Gets the data from the widget.
virtual void childValueChanged(const QVariant &value, int typeForParent)
virtual void updateParent(const QVariant &value)
Property propertyType() const
virtual QList< VProperty * > & getChildren()
Returns a reference to the list of children.
virtual QString type() const
Returns a string containing the type of the property.
static const int MyCustomEventType