Fix property value update.

Default handler doesn't work in our cases.
This commit is contained in:
Roman Telezhynskyi 2020-11-04 10:53:49 +02:00
parent 37722788bb
commit 8a6003752e
6 changed files with 45 additions and 0 deletions

View File

@ -70,6 +70,17 @@ QWidget *VPE::VLabelProperty::createEditor(QWidget *parent, const QStyleOptionVi
return d_ptr->editor;
}
bool VPE::VLabelProperty::setEditorData(QWidget *editor)
{
if (QLabel* tmpWidget = qobject_cast<QLabel*>(editor))
{
tmpWidget->setText(d_ptr->VariantValue.toString());
return true;
}
return false;
}
QVariant VPE::VLabelProperty::getEditorData(const QWidget *editor) const
{
const QLabel* tmpEditor = qobject_cast<const QLabel*>(editor);

View File

@ -63,6 +63,9 @@ public:
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
const QAbstractItemDelegate* delegate) override;
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
virtual bool setEditorData(QWidget* editor) override;
//! Gets the data from the widget
virtual QVariant getEditorData(const QWidget* editor) const override;

View File

@ -65,6 +65,20 @@ QWidget *VPE::VStringProperty::createEditor(QWidget *parent, const QStyleOptionV
return d_ptr->editor;
}
bool VPE::VStringProperty::setEditorData(QWidget *editor)
{
if (QLineEdit* tmpWidget = qobject_cast<QLineEdit*>(editor))
{
if (not readOnly)
{
tmpWidget->setText(d_ptr->VariantValue.toString());
}
return true;
}
return false;
}
QVariant VPE::VStringProperty::getEditorData(const QWidget *editor) const
{
const QLineEdit* tmpEditor = qobject_cast<const QLineEdit*>(editor);

View File

@ -55,6 +55,9 @@ public:
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
const QAbstractItemDelegate* delegate) override;
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
virtual bool setEditorData(QWidget* editor) override;
//! Gets the data from the widget
virtual QVariant getEditorData(const QWidget* editor) const override;

View File

@ -86,6 +86,17 @@ QWidget *VPE::VTextProperty::createEditor(QWidget *parent, const QStyleOptionVie
return d_ptr->editor;
}
bool VPE::VTextProperty::setEditorData(QWidget *editor)
{
if (QPlainTextEdit* tmpWidget = qobject_cast<QPlainTextEdit*>(editor))
{
tmpWidget->setPlainText(d_ptr->VariantValue.toString());
return true;
}
return false;
}
QVariant VPE::VTextProperty::getEditorData(const QWidget *editor) const
{
const QPlainTextEdit* tmpEditor = qobject_cast<const QPlainTextEdit*>(editor);

View File

@ -52,6 +52,9 @@ public:
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
const QAbstractItemDelegate* delegate) override;
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
virtual bool setEditorData(QWidget* editor) override;
//! Gets the data from the widget
virtual QVariant getEditorData(const QWidget* editor) const override;