Commit 64da60dc authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.DragTool: fixing creating file imports



Creating file imports from the item library was broken.
If the version is -1.-1 we have to create a FileImport
instead of a library import.

Change-Id: I6bef68ba308d2254c9c2cb607a91c81055a360d4
Reviewed-by: default avatarMarco Bubke <marco.bubke@digia.com>
parent 6376b2bb
......@@ -204,6 +204,24 @@ FormEditorItem* DragTool::calculateContainer(const QPointF &point, FormEditorIte
return 0;
}
QList<Import> DragTool::missingImportList(const ItemLibraryEntry &itemLibraryEntry)
{
QList<Import> importToBeAddedList;
if (!itemLibraryEntry.requiredImport().isEmpty()) {
const QString newImportUrl = itemLibraryEntry.requiredImport();
const QString newImportVersion = QString("%1.%2").arg(QString::number(itemLibraryEntry.majorVersion()), QString::number(itemLibraryEntry.minorVersion()));
Import newImport = Import::createLibraryImport(newImportUrl, newImportVersion);
if (itemLibraryEntry.majorVersion() == -1 && itemLibraryEntry.minorVersion() == -1) {
newImport = Import::createFileImport(newImportUrl, QString());
} else {
newImport = Import::createLibraryImport(newImportUrl, newImportVersion);
}
}
return importToBeAddedList;
}
void DragTool::formEditorItemsChanged(const QList<FormEditorItem*> & itemList)
{
......@@ -296,17 +314,9 @@ void DragTool::dragEnterEvent(QGraphicsSceneDragDropEvent * event)
view()->widget()->setFocus();
m_Aborted = false;
Q_ASSERT(!event->mimeData()->data("application/vnd.bauhaus.itemlibraryinfo").isEmpty());
ItemLibraryEntry itemLibraryEntry = itemLibraryEntryFromData(event->mimeData()->data("application/vnd.bauhaus.itemlibraryinfo"));
if (!itemLibraryEntry.requiredImport().isEmpty()) {
const QString newImportUrl = itemLibraryEntry.requiredImport();
const QString newImportVersion = QString("%1.%2").arg(QString::number(itemLibraryEntry.majorVersion()), QString::number(itemLibraryEntry.minorVersion()));
Import newImport = Import::createLibraryImport(newImportUrl, newImportVersion);
if (!view()->model()->hasImport(newImport, true, true)) {
importToBeAddedList.append(newImport);
}
}
importToBeAddedList = missingImportList(
itemLibraryEntryFromData(event->mimeData()->data("application/vnd.bauhaus.itemlibraryinfo")));
}
view()->model()->changeImports(importToBeAddedList, QList<Import>());
......
......@@ -114,6 +114,7 @@ private:
void createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, QmlItemNode parentNode, QPointF scenePos);
void createQmlItemNodeFromImage(const QString &imageName, QmlItemNode parentNode, QPointF scenePos);
FormEditorItem* calculateContainer(const QPointF &point, FormEditorItem * currentItem = 0);
QList<Import> missingImportList(const ItemLibraryEntry &itemLibraryEntry);
void begin(QPointF scenePos);
void end(QPointF scenePos);
......
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