Commit e9096120 authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner: Fix ignored properties for reparenting



We reparented into ignored properties. Now there is a more general mechanism
to prevent this.

Task-number: QTCREATORBUG-11970
Change-Id: Icbd5877dc13c65963079eb3ab67e48bb92056b53
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent 1c7fc450
......@@ -55,22 +55,6 @@ BehaviorNodeInstance::Pointer BehaviorNodeInstance::create(QObject *object)
return instance;
}
void BehaviorNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value)
{
if (name == "enabled")
return;
ObjectNodeInstance::setPropertyVariant(name, value);
}
void BehaviorNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression)
{
if (name == "enabled")
return;
ObjectNodeInstance::setPropertyBinding(name, expression);
}
QVariant BehaviorNodeInstance::property(const PropertyName &name) const
{
if (name == "enabled")
......@@ -87,6 +71,11 @@ void BehaviorNodeInstance::resetProperty(const PropertyName &name)
ObjectNodeInstance::resetProperty(name);
}
PropertyNameList BehaviorNodeInstance::ignoredProperties() const
{
return PropertyNameList() << "enabled";
}
} // namespace Internal
} // namespace QmlDesigner
......@@ -45,13 +45,11 @@ public:
static Pointer create(QObject *objectToBeWrapped);
void setPropertyVariant(const PropertyName &name, const QVariant &value) Q_DECL_OVERRIDE;
void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE;
QVariant property(const PropertyName &name) const Q_DECL_OVERRIDE;
void resetProperty(const PropertyName &name) Q_DECL_OVERRIDE;
PropertyNameList ignoredProperties() const Q_DECL_OVERRIDE;
private:
bool m_isEnabled;
};
......
......@@ -46,22 +46,6 @@ bool LayoutNodeInstance::isResizable() const
return true;
}
void LayoutNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value)
{
if (name == "move" || name == "add" || name == "populate")
return;
QuickItemNodeInstance::setPropertyVariant(name, value);
}
void LayoutNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression)
{
if (name == "move" || name == "add" || name == "populate")
return;
QuickItemNodeInstance::setPropertyBinding(name, expression);
}
LayoutNodeInstance::Pointer LayoutNodeInstance::create(QObject *object)
{
QQuickItem *item = qobject_cast<QQuickItem*>(object);
......@@ -87,5 +71,10 @@ void LayoutNodeInstance::refreshLayoutable()
}
PropertyNameList LayoutNodeInstance::ignoredProperties() const
{
return PropertyNameList() << "move" << "add" << "populate";
}
}
} // namespace QmlDesigner
......@@ -44,15 +44,14 @@ public:
static Pointer create(QObject *objectToBeWrapped);
void setPropertyVariant(const PropertyName &name, const QVariant &value) Q_DECL_OVERRIDE;
void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE;
bool isLayoutable() const Q_DECL_OVERRIDE;
bool isResizable() const Q_DECL_OVERRIDE;
void refreshLayoutable() Q_DECL_OVERRIDE;
PropertyNameList ignoredProperties() const Q_DECL_OVERRIDE;
protected:
LayoutNodeInstance(QQuickItem *item);
};
......
......@@ -381,16 +381,17 @@ void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, c
void ObjectNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty)
{
if (oldParentInstance) {
if (oldParentInstance && !oldParentInstance->ignoredProperties().contains(oldParentProperty)) {
removeFromOldProperty(object(), oldParentInstance->object(), oldParentProperty);
m_parentProperty.clear();
}
if (newParentInstance) {
if (newParentInstance && !newParentInstance->ignoredProperties().contains(newParentProperty)) {
m_parentProperty = newParentProperty;
addToNewProperty(object(), newParentInstance->object(), newParentProperty);
}
}
QVariant ObjectNodeInstance::convertSpecialCharacter(const QVariant& value) const
{
QVariant specialCharacterConvertedValue = value;
......@@ -458,8 +459,16 @@ void ObjectNodeInstance::updateAllDirtyNodesRecursive()
{
}
PropertyNameList ObjectNodeInstance::ignoredProperties() const
{
return PropertyNameList();
}
void ObjectNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value)
{
if (ignoredProperties().contains(name))
return;
QQmlProperty property(object(), name, context());
if (!property.isValid())
......@@ -498,6 +507,9 @@ void ObjectNodeInstance::setPropertyVariant(const PropertyName &name, const QVar
void ObjectNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression)
{
if (ignoredProperties().contains(name))
return;
QQmlProperty property(object(), name, context());
if (!property.isValid())
......@@ -541,6 +553,9 @@ void ObjectNodeInstance::deleteObjectsInList(const QQmlProperty &property)
void ObjectNodeInstance::resetProperty(const PropertyName &name)
{
if (ignoredProperties().contains(name))
return;
doResetProperty(name);
if (name == "font.pixelSize")
......@@ -641,6 +656,9 @@ void ObjectNodeInstance::doResetProperty(const PropertyName &propertyName)
QVariant ObjectNodeInstance::property(const PropertyName &name) const
{
if (ignoredProperties().contains(name))
return QVariant();
if (m_modelAbstractPropertyHash.contains(name))
return QVariant::fromValue(m_modelAbstractPropertyHash.value(name));
......
......@@ -189,6 +189,8 @@ public:
virtual void updateAllDirtyNodesRecursive();
virtual PropertyNameList ignoredProperties() const;
protected:
explicit ObjectNodeInstance(QObject *object);
void doResetProperty(const PropertyName &propertyName);
......
......@@ -52,22 +52,6 @@ bool PositionerNodeInstance::isResizable() const
return true;
}
void PositionerNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value)
{
if (name == "move" || name == "add" || name == "populate")
return;
QuickItemNodeInstance::setPropertyVariant(name, value);
}
void PositionerNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression)
{
if (name == "move" || name == "add" || name == "populate")
return;
QuickItemNodeInstance::setPropertyBinding(name, expression);
}
PositionerNodeInstance::Pointer PositionerNodeInstance::create(QObject *object)
{
QQuickBasePositioner *positioner = qobject_cast<QQuickBasePositioner*>(object);
......@@ -99,5 +83,10 @@ void PositionerNodeInstance::refreshLayoutable()
Q_UNUSED(success)
}
PropertyNameList PositionerNodeInstance::ignoredProperties() const
{
return PropertyNameList() << "move" << "add" << "populate";
}
}
} // namespace QmlDesigner
......@@ -47,9 +47,6 @@ public:
static Pointer create(QObject *objectToBeWrapped);
void setPropertyVariant(const PropertyName &name, const QVariant &value) Q_DECL_OVERRIDE;
void setPropertyBinding(const PropertyName &name, const QString &expression) Q_DECL_OVERRIDE;
bool isPositioner() const Q_DECL_OVERRIDE;
bool isLayoutable() const Q_DECL_OVERRIDE;
......@@ -57,6 +54,8 @@ public:
void refreshLayoutable() Q_DECL_OVERRIDE;
PropertyNameList ignoredProperties() const Q_DECL_OVERRIDE;
protected:
PositionerNodeInstance(QQuickBasePositioner *item);
QQuickBasePositioner *positioner() const;
......
......@@ -59,12 +59,9 @@ bool QmlTransitionNodeInstance::isTransition() const
return true;
}
void QmlTransitionNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value)
PropertyNameList QmlTransitionNodeInstance::ignoredProperties() const
{
if (name == "from" || name == "to")
return;
ObjectNodeInstance::setPropertyVariant(name, value);
return PropertyNameList() << "from" << "to";
}
QQuickTransition *QmlTransitionNodeInstance::qmlTransition() const
......
......@@ -47,10 +47,10 @@ public:
static Pointer create(QObject *objectToBeWrapped);
void setPropertyVariant(const PropertyName &name, const QVariant &value) Q_DECL_OVERRIDE;
bool isTransition() const Q_DECL_OVERRIDE;
PropertyNameList ignoredProperties() const Q_DECL_OVERRIDE;
protected:
QQuickTransition *qmlTransition() const;
......
......@@ -558,21 +558,26 @@ bool QuickItemNodeInstance::childItemsHaveContent(QQuickItem *quickItem)
return false;
}
static bool instanceIsValidLayoutable(const ObjectNodeInstance::Pointer &instance, const PropertyName &propertyName)
{
return instance && instance->isLayoutable() && !instance->ignoredProperties().contains(propertyName);
}
void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty)
{
if (oldParentInstance && oldParentInstance->isLayoutable()) {
if (instanceIsValidLayoutable(oldParentInstance, oldParentProperty)) {
setInLayoutable(false);
setMovable(true);
}
ObjectNodeInstance::reparent(oldParentInstance, oldParentProperty, newParentInstance, newParentProperty);
if (newParentInstance && newParentInstance->isLayoutable()) {
if (instanceIsValidLayoutable(newParentInstance, newParentProperty)) {
setInLayoutable(true);
setMovable(false);
}
if (oldParentInstance && oldParentInstance->isLayoutable() && !(newParentInstance && newParentInstance->isLayoutable())) {
if (instanceIsValidLayoutable(oldParentInstance, oldParentProperty) && !instanceIsValidLayoutable(newParentInstance, newParentProperty)) {
if (!hasBindingForProperty("x"))
setPropertyVariant("x", x());
......@@ -583,12 +588,18 @@ void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParen
refresh();
DesignerSupport::updateDirtyNode(quickItem());
if (parentInstance() && isInLayoutable())
parentInstance()->refreshLayoutable();
if (instanceIsValidLayoutable(oldParentInstance, oldParentProperty))
oldParentInstance->refreshLayoutable();
if (instanceIsValidLayoutable(newParentInstance, newParentProperty))
newParentInstance->refreshLayoutable();
}
void QuickItemNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value)
{
if (ignoredProperties().contains(name))
return;
if (name == "state")
return; // states are only set by us
......@@ -626,6 +637,9 @@ void QuickItemNodeInstance::setPropertyVariant(const PropertyName &name, const Q
void QuickItemNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression)
{
if (ignoredProperties().contains(name))
return;
if (name == "state")
return; // states are only set by us
......@@ -644,6 +658,9 @@ void QuickItemNodeInstance::setPropertyBinding(const PropertyName &name, const Q
QVariant QuickItemNodeInstance::property(const PropertyName &name) const
{
if (ignoredProperties().contains(name))
return QVariant();
if (name == "visible")
return quickItem()->isVisible();
......@@ -652,6 +669,9 @@ QVariant QuickItemNodeInstance::property(const PropertyName &name) const
void QuickItemNodeInstance::resetProperty(const PropertyName &name)
{
if (ignoredProperties().contains(name))
return;
if (name == "height") {
m_hasHeight = false;
m_height = 0.0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment