Commit 1fd9707d authored by Marco Bubke's avatar Marco Bubke Committed by Thomas Hartmann

QmlDesigner: Remove QmlModelView::createQmlItemNode functions

Change-Id: I5c3f05beec22f056daa3419fac40ef837a655a8d
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 125eb66b
......@@ -152,7 +152,7 @@ void DragTool::createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, QmlIt
FormEditorItem *parentItem = scene()->itemForQmlItemNode(parentNode);
QPointF pos = parentItem->mapFromScene(scenePos);
m_dragNode = view()->createQmlItemNode(itemLibraryEntry, pos, parentNode);
m_dragNode = QmlItemNode::createQmlItemNode(view(), itemLibraryEntry, pos, parentNode);
Q_ASSERT(m_dragNode.modelNode().isValid());
......@@ -171,7 +171,7 @@ void DragTool::createQmlItemNodeFromImage(const QString &imageName, QmlItemNode
FormEditorItem *parentItem = scene()->itemForQmlItemNode(parentNode);
QPointF pos = parentItem->mapFromScene(scenePos);
m_dragNode = view()->createQmlItemNodeFromImage(imageName, pos, parentNode);
m_dragNode = QmlItemNode::createQmlItemNodeFromImage(view(), imageName, pos, parentNode);
QList<QmlItemNode> nodeList;
nodeList.append(m_dragNode);
......
......@@ -58,9 +58,6 @@ public:
ModelNode createQmlState(const PropertyListType &propertyList = PropertyListType());
QmlItemNode createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, const QPointF &position, QmlItemNode parentNode);
QmlItemNode createQmlItemNodeFromImage(const QString &imageName, const QPointF &position, QmlItemNode parentNode);
QmlItemNode rootQmlItemNode() const;
protected:
......
......@@ -80,83 +80,6 @@ QmlModelStateGroup QmlModelView::rootStateGroup() const
return QmlModelStateGroup(rootModelNode());
}
QmlItemNode QmlModelView::createQmlItemNodeFromImage(const QString &imageName, const QPointF &position, QmlItemNode parentQmlItemNode)
{
if (!parentQmlItemNode.isValid() && rootQmlItemNode().isValid())
parentQmlItemNode = rootQmlItemNode();
else
return QmlItemNode();
QmlItemNode newQmlItemNode;
RewriterTransaction transaction = beginRewriterTransaction();
{
const QString newImportUrl = QLatin1String("QtQuick");
const QString newImportVersion = QLatin1String("1.1");
Import newImport = Import::createLibraryImport(newImportUrl, newImportVersion);
foreach (const Import &import, model()->imports()) {
if (import.isLibraryImport()
&& import.url() == newImport.url()) {
// reuse this import
newImport = import;
break;
}
}
if (!model()->hasImport(newImport, true, true))
model()->changeImports(QList<Import>() << newImport, QList<Import>());
QList<QPair<PropertyName, QVariant> > propertyPairList;
propertyPairList.append(qMakePair(PropertyName("x"), QVariant( round(position.x(), 4))));
propertyPairList.append(qMakePair(PropertyName("y"), QVariant( round(position.y(), 4))));
QString relativeImageName = imageName;
//use relative path
if (QFileInfo(model()->fileUrl().toLocalFile()).exists()) {
QDir fileDir(QFileInfo(model()->fileUrl().toLocalFile()).absolutePath());
relativeImageName = fileDir.relativeFilePath(imageName);
}
propertyPairList.append(qMakePair(PropertyName("source"), QVariant(relativeImageName)));
NodeMetaInfo metaInfo = model()->metaInfo("QtQuick.Image");
if (metaInfo.isValid()) {
int minorVersion = metaInfo.minorVersion();
int majorVersion = metaInfo.majorVersion();
newQmlItemNode = QmlItemNode(createModelNode("QtQuick.Image", majorVersion, minorVersion, propertyPairList));
parentQmlItemNode.nodeAbstractProperty("data").reparentHere(newQmlItemNode);
}
Q_ASSERT(newQmlItemNode.isValid());
QString id;
int i = 1;
QString name("image");
name.remove(QLatin1Char(' '));
do {
id = name + QString::number(i);
i++;
} while (hasId(id)); //If the name already exists count upwards
newQmlItemNode.setId(id);
if (!currentState().isBaseState()) {
newQmlItemNode.modelNode().variantProperty("opacity").setValue(0);
newQmlItemNode.setVariantProperty("opacity", 1);
}
Q_ASSERT(newQmlItemNode.isValid());
}
Q_ASSERT(newQmlItemNode.isValid());
return newQmlItemNode;
}
QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, const QPointF &position, QmlItemNode parentQmlItemNode)
{
return QmlItemNode::createQmlItemNode(this, itemLibraryEntry, position, parentQmlItemNode);
}
QmlItemNode QmlModelView::rootQmlItemNode() const
{
return QmlItemNode(rootModelNode());
......
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