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

QmlDesigner: Fix positioner handling

Change-Id: I519bbbfee939d4568a0de5bbe5c01912a08c6fb1
Reviewed-on: http://codereview.qt.nokia.com/1848

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent 37f6d97f
......@@ -906,6 +906,10 @@ void ObjectNodeInstance::setInPositioner(bool isInPositioner)
m_isInPositioner = isInPositioner;
}
void ObjectNodeInstance::refreshPositioner()
{
}
void ObjectNodeInstance::updateAnchors()
{
}
......
......@@ -165,6 +165,7 @@ public:
virtual bool isMovable() const;
bool isInPositioner() const;
void setInPositioner(bool isInPositioner);
virtual void refreshPositioner();
bool hasBindingForProperty(const QString &name, bool *hasChanged = 0) const;
......
......@@ -84,5 +84,18 @@ PositionerNodeInstance::Pointer PositionerNodeInstance::create(QObject *object)
return instance;
}
QDeclarativeBasePositioner *PositionerNodeInstance::positioner() const
{
Q_ASSERT(qobject_cast<QDeclarativeBasePositioner*>(object()));
return static_cast<QDeclarativeBasePositioner*>(object());
}
void PositionerNodeInstance::refreshPositioner()
{
bool success = QMetaObject::invokeMethod(positioner(), "prePositioning");
Q_ASSERT(success);
}
}
} // namespace QmlDesigner
......@@ -57,9 +57,11 @@ public:
bool isResizable() const;
void refreshPositioner();
protected:
PositionerNodeInstance(QDeclarativeBasePositioner *item);
QDeclarativeBasePositioner *positioner() const;
};
} // namespace Internal
......
......@@ -154,6 +154,8 @@ void QmlGraphicsItemNodeInstance::setPropertyVariant(const QString &name, const
GraphicsObjectNodeInstance::setPropertyVariant(name, value);
refresh();
if (isInPositioner())
parentInstance()->refreshPositioner();
}
void QmlGraphicsItemNodeInstance::setPropertyBinding(const QString &name, const QString &expression)
......@@ -325,6 +327,9 @@ void QmlGraphicsItemNodeInstance::resetProperty(const QString &name)
}
GraphicsObjectNodeInstance::resetProperty(name);
if (isInPositioner())
parentInstance()->refreshPositioner();
}
void QmlGraphicsItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const QString &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const QString &newParentProperty)
......@@ -353,6 +358,8 @@ void QmlGraphicsItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &ol
}
refresh();
if (isInPositioner())
parentInstance()->refreshPositioner();
}
QDeclarativeAnchors::Anchor anchorLineFlagForName(const QString &name)
......
......@@ -45,6 +45,7 @@
#include <limits>
#include <model.h>
#include <qmlanchors.h>
#include <nodemetainfo.h>
#include <variantproperty.h>
#include <nodeabstractproperty.h>
......@@ -108,7 +109,8 @@ void MoveManipulator::synchronizeParent(const QList<FormEditorItem*> &itemList,
}
}
update(m_lastPosition, NoSnapping, UseBaseState);
if (!parentNode.metaInfo().isSubclassOf("<cpp>.QDeclarativeBasePositioner", -1, -1))
update(m_lastPosition, NoSnapping, UseBaseState);
}
void MoveManipulator::synchronizeInstanceParent(const QList<FormEditorItem*> &itemList)
......@@ -363,6 +365,15 @@ void MoveManipulator::reparentTo(FormEditorItem *newParent)
if (!itemsCanReparented())
return;
if (!newParent->qmlItemNode().modelNode().metaInfo().isSubclassOf("<cpp>.QDeclarativeBasePositioner", -1, -1)
&& newParent->qmlItemNode().modelNode().hasParentProperty()) {
ModelNode grandParent = newParent->qmlItemNode().modelNode().parentProperty().parentModelNode();
if (grandParent.metaInfo().isSubclassOf("<cpp>.QDeclarativeBasePositioner", -1, -1))
newParent = m_view.data()->scene()->itemForQmlItemNode(QmlItemNode(grandParent));
}
QVector<ModelNode> nodeReparentVector;
NodeAbstractProperty parentProperty;
......
Markdown is supported
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