Fix clone property and commit data for "simple" property type.

--HG--
branch : feature
This commit is contained in:
dismine 2014-08-29 17:29:24 +03:00
parent ae4bab9d07
commit a251c9e378
3 changed files with 18 additions and 7 deletions

View file

@ -334,6 +334,7 @@ VProperty* VProperty::clone(bool include_children, VProperty* container) const
container->setValue(getValue());
container->setSettings(getSettings());
container->setUpdateBehaviour(getUpdateParent(), getUpdateChildren());
container->setPropertyType(propertyType());
if(include_children) {
foreach(VProperty* tmpChild, d_ptr->Children)
@ -348,6 +349,11 @@ Property VProperty::propertyType() const
return d_ptr->type;
}
void VProperty::setPropertyType(const Property &type)
{
d_ptr->type = type;
}
void VProperty::UpdateParent(const QVariant &value)
{
Q_UNUSED(value);

View file

@ -162,6 +162,7 @@ public:
virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const;
Property propertyType() const;
void setPropertyType(const Property &type);
virtual void UpdateParent(const QVariant &value);
public slots:

View file

@ -164,18 +164,22 @@ void VPropertyFormWidget::commitData(int row)
VProperty* tmpProperty = d_ptr->Properties[row];
if(tmpEditorWidget.FormWidget)
tmpEditorWidget.FormWidget->commitData();
else if(tmpEditorWidget.Editor && tmpProperty) {
else if(tmpEditorWidget.Editor && tmpProperty)
{
QVariant newValue = tmpProperty->getEditorData(tmpEditorWidget.Editor);
QVariant oldValue = tmpProperty->data(VProperty::DPC_Data, Qt::EditRole);
if (oldValue != newValue)
{
if (VProperty *parent = tmpProperty->getParent())
VProperty *parent = tmpProperty->getParent();
if (parent == nullptr)
{
if (parent->propertyType() == Property::Complex)
{
tmpProperty->UpdateParent(newValue);
emit propertyDataSubmitted(parent);
}
tmpProperty->setValue(newValue);
emit propertyDataSubmitted(tmpProperty);
}
else if (parent->propertyType() == Property::Complex)
{
tmpProperty->UpdateParent(newValue);
emit propertyDataSubmitted(parent);
}
else
{