Commit a31ac153 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.NodeInstances: reparenting and componentComplete

Set the parent if no parentItem exists
Call componentComplete
parent fff4c2b2
......@@ -141,6 +141,8 @@ public:
static void registerDeclarativeTypes();
void doComponentComplete();
QString id() const;
#ifdef QTCREATOR_TEST
......
......@@ -644,6 +644,11 @@ void NodeInstance::registerDeclarativeTypes()
// qmlRegisterType<QmlDesigner::Internal::QmlPropertyChangesObject>();
}
void NodeInstance::doComponentComplete()
{
}
QString NodeInstance::id() const
{
return m_nodeInstance->id();
......
......@@ -140,7 +140,10 @@ void NodeInstanceView::modelAboutToBeDetached(Model * model)
*/
void NodeInstanceView::nodeCreated(const ModelNode &createdNode)
{
loadNode(createdNode);
NodeInstance instance = loadNode(createdNode);
if (instance.isValid())
instance.doComponentComplete();
}
/*! \brief Notifing the view that a node was created.
......@@ -401,6 +404,9 @@ void NodeInstanceView::loadNodes(const QList<ModelNode> &nodeList)
foreach (const BindingProperty &property, node.bindingProperties())
instanceForNode(node).setPropertyBinding(property.name(), property.expression());
}
foreach(NodeInstance instance, m_objectInstanceHash.values())
instance.doComponentComplete();
}
// TODO: Set base state as current model state
......
......@@ -381,6 +381,9 @@ void ObjectNodeInstance::removeFromOldProperty(QObject *object, QObject *oldPare
nodeInstanceView()->instanceForObject(oldParent).resetProperty(oldParentProperty);
}
}
if (object && object->parent())
object->setParent(0);
}
void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, const QString &newParentProperty)
......@@ -400,6 +403,11 @@ void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, c
property.write(objectToVariant(object));
}
QGraphicsObject *graphicsObject = qobject_cast<QGraphicsObject*>(object);
if (object && !(graphicsObject && graphicsObject->parentItem()))
object->setParent(newParent);
Q_ASSERT(objectToVariant(object).isValid());
}
......@@ -972,6 +980,11 @@ NodeInstance ObjectNodeInstance::nodeInstanceParentForObject(QObject *currentObj
return nodeInstanceParentForObject(parentObject);
}
void ObjectNodeInstance::doComponentComplete()
{
}
}
}
......@@ -179,6 +179,9 @@ public:
NodeInstance nodeInstanceParentForObject(QObject *currentObject) const;
virtual void doComponentComplete();
protected:
static QObject *createInstance(const NodeMetaInfo &metaInfo, QDeclarativeContext *parentContext);
......
......@@ -286,6 +286,12 @@ void QmlGraphicsItemNodeInstance::resetVertical()
setPropertyVariant("height", qmlGraphicsItem()->implicitHeight());
}
void QmlGraphicsItemNodeInstance::doComponentComplete()
{
if (qmlGraphicsItem())
static_cast<QDeclarativeParserStatus*>(qmlGraphicsItem())->componentComplete();
}
int QmlGraphicsItemNodeInstance::penWidth() const
{
QDeclarativeRectangle *rectangle = qobject_cast<QDeclarativeRectangle*>(object());
......@@ -337,6 +343,11 @@ void QmlGraphicsItemNodeInstance::resetProperty(const QString &name)
}
}
void QmlGraphicsItemNodeInstance::reparent(const NodeInstance &oldParentInstance, const QString &oldParentProperty, const NodeInstance &newParentInstance, const QString &newParentProperty)
{
GraphicsObjectNodeInstance::reparent(oldParentInstance, oldParentProperty, newParentInstance, newParentProperty);
}
//void QmlGraphicsItemNodeInstance::updateAnchors()
//{
// NodeAnchors anchors(modelNode());
......
......@@ -60,19 +60,22 @@ public:
QVariant property(const QString &name) const;
void resetProperty(const QString &name);
void reparent(const NodeInstance &oldParentInstance, const QString &oldParentProperty, const NodeInstance &newParentInstance, const QString &newParentProperty);
int penWidth() const;
bool hasAnchor(const QString &name) const;
QPair<QString, NodeInstance> anchor(const QString &name) const;
bool isAnchoredBySibling() const;
bool isAnchoredByChildren() const;
void doComponentComplete();
protected:
QmlGraphicsItemNodeInstance(QDeclarativeItem *item, bool hasContent);
QDeclarativeItem *qmlGraphicsItem() const;
QDeclarativeAnchors *anchors() const;
void resetHorizontal();
void resetVertical();
void resetVertical();
private: //variables
bool m_hasHeight;
......
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