Commit 4dcc0c2a authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.qmlModelView: fixes adding imports

We use requiredImport() and only add an import if it does
not exists before (even with alias).
parent 9f9bdd72
......@@ -173,7 +173,10 @@ QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryE
try {
RewriterTransaction transaction = beginRewriterTransaction();
if (itemLibraryEntry.typeName().contains('.')) {
const QString newImportUrl = itemLibraryEntry.typeName().split('.').first();
const QString newImportUrl = itemLibraryEntry.requiredImport();
if (!itemLibraryEntry.requiredImport().isEmpty()) {
const QString newImportVersion = QString("%1.%2").arg(QString::number(itemLibraryEntry.majorVersion()), QString::number(itemLibraryEntry.minorVersion()));
Import newImport = Import::createLibraryImport(newImportUrl, newImportVersion);
......@@ -187,10 +190,11 @@ QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryE
}
}
if (!model()->imports().contains(newImport)) {
if (!model()->hasImport(newImport, true)) {
model()->changeImports(QList<Import>() << newImport, QList<Import>());
}
}
}
QList<QPair<QString, QVariant> > propertyPairList;
propertyPairList.append(qMakePair(QString("x"), QVariant(round(position.x(), 4))));
......
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