Commit 49347f3c authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner: Add QmlItemNode::createQmlItemNodeFromImage overload



We need a parent property overload so we can add a item to a non
default property.

Change-Id: I2044126f1c9f4cb112d1b96db163b70cd12b9042
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 234cc766
......@@ -69,6 +69,10 @@ public:
const QString &imageName,
const QPointF &position,
QmlItemNode parentQmlItemNode);
static QmlItemNode createQmlItemNodeFromImage(AbstractView *view,
const QString &imageName,
const QPointF &position,
NodeAbstractProperty parentproperty);
QmlModelStateGroup states() const;
QList<QmlItemNode> children() const;
......
......@@ -162,11 +162,19 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary
QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QString &imageName, const QPointF &position, QmlItemNode parentQmlItemNode)
{
QmlItemNode newQmlItemNode;
if (!parentQmlItemNode.isValid())
parentQmlItemNode = QmlItemNode(view->rootModelNode());
if (parentQmlItemNode.isValid()) {
NodeAbstractProperty parentProperty = parentQmlItemNode.defaultNodeAbstractProperty();
return QmlItemNode::createQmlItemNodeFromImage(view, imageName, position, parentProperty);
}
QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QString &imageName, const QPointF &position, NodeAbstractProperty parentproperty)
{
QmlItemNode newQmlItemNode;
if (parentproperty.isValid()) {
RewriterTransaction transaction = view->beginRewriterTransaction(QByteArrayLiteral("QmlItemNode::createQmlItemNodeFromImage"));
if (view->model()->hasNodeMetaInfo("QtQuick.Image")) {
......@@ -185,7 +193,7 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS
}
newQmlItemNode = QmlItemNode(view->createModelNode("QtQuick.Image", metaInfo.majorVersion(), metaInfo.minorVersion(), propertyPairList));
parentQmlItemNode.defaultNodeAbstractProperty().reparentHere(newQmlItemNode);
parentproperty.reparentHere(newQmlItemNode);
newQmlItemNode.setId(view->generateNewId("image"));
......@@ -199,7 +207,6 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromImage(AbstractView *view, const QS
Q_ASSERT(newQmlItemNode.isValid());
}
return newQmlItemNode;
}
......
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