diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp index 26c53fde10665c6cf5d1f9846e6f82d72b1ca424..ff763826388e936b1dea8aa418cfb41ba70577b4 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrary.cpp @@ -147,19 +147,13 @@ ItemLibrary::ItemLibrary(QWidget *parent) : m_d->m_ui.ItemLibraryTreeView->setAttribute(Qt::WA_MacShowFocusRect, false); m_d->m_ui.ItemLibraryTreeView->setRootIndex(m_d->m_resourcesDirModel->index(m_d->m_resourcePath)); - const QString qmlSourcePath(":/ItemLibrary/qml/ItemsView.qml"); - QFile qmlSourceFile(qmlSourcePath); - qmlSourceFile.open(QFile::ReadOnly); - Q_ASSERT(qmlSourceFile.isOpen()); - QString qmlSource(qmlSourceFile.readAll()); - m_d->m_itemsView = new QmlView(this); - m_d->m_itemsView->setQml(qmlSource, qmlSourcePath); + m_d->m_itemsView->setSource(QUrl("qrc:/ItemLibrary/qml/ItemsView.qml")); m_d->m_itemsView->setAttribute(Qt::WA_OpaquePaintEvent); m_d->m_itemsView->setAttribute(Qt::WA_NoSystemBackground); m_d->m_itemsView->setAcceptDrops(false); m_d->m_itemsView->setFocusPolicy(Qt::ClickFocus); - m_d->m_itemsView->setContentResizable(true); + m_d->m_itemsView->setResizeMode(QmlView::SizeRootObjectToView); m_d->m_ui.ItemLibraryGridLayout->addWidget(m_d->m_itemsView, 0, 0); m_d->m_itemLibraryModel = new Internal::ItemLibraryModel(QmlEnginePrivate::getScriptEngine(m_d->m_itemsView->engine()), this); @@ -170,9 +164,10 @@ ItemLibrary::ItemLibrary(QWidget *parent) : m_d->m_itemsView->execute(); - connect(m_d->m_itemsView->root(), SIGNAL(itemSelected(int)), this, SLOT(showItemInfo(int))); - connect(m_d->m_itemsView->root(), SIGNAL(itemDragged(int)), this, SLOT(startDragAndDrop(int))); - connect(this, SIGNAL(expandAllItems()), m_d->m_itemsView->root(), SLOT(expandAll())); + QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(m_d->m_itemsView->rootObject()); + connect(rootItem, SIGNAL(itemSelected(int)), this, SLOT(showItemInfo(int))); + connect(rootItem, SIGNAL(itemDragged(int)), this, SLOT(startDragAndDrop(int))); + connect(this, SIGNAL(expandAllItems()), rootItem, SLOT(expandAll())); connect(m_d->m_ui.lineEdit, SIGNAL(textChanged(QString)), this, SLOT(setSearchFilter(QString))); m_d->m_ui.lineEdit->setDragEnabled(false); @@ -267,7 +262,8 @@ void ItemLibrary::startDragAndDrop(int itemLibId) drag->setPreview(QPixmap::fromImage(image)); drag->setMimeData(mimeData); - connect(m_d->m_itemsView->root(), SIGNAL(stopDragAndDrop()), drag, SLOT(stopDrag())); + QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(m_d->m_itemsView->rootObject()); + connect(rootItem, SIGNAL(stopDragAndDrop()), drag, SLOT(stopDrag())); drag->exec(); } diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp index 67937e7a1edcdd5b6de774859f99766ad49e217c..09c835c5b3dc2e4f81b648fdf697df3b2d217fdf 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditor.cpp @@ -65,8 +65,8 @@ PropertyEditor::NodeType::NodeType(const QUrl &qmlFile, PropertyEditor *property { Q_ASSERT(QFileInfo(":/images/button_normal.png").exists()); - m_view->setContentResizable(true); - m_view->setUrl(qmlFile); + m_view->setResizeMode(QmlView::SizeRootObjectToView); + m_view->setSource(qmlFile); connect(&m_backendValuesPropertyMap, SIGNAL(valueChanged(const QString&)), propertyEditor, SLOT(changeValue(const QString&))); } diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp index 1c5d13dbf7a8d6cc8432bde19ba179e4915a2509..d7ccbc5d6ced30c3dc943f8b4d52f9ad28483560 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp @@ -91,14 +91,14 @@ StatesEditorWidgetPrivate::StatesEditorWidgetPrivate(StatesEditorWidget *q) : int StatesEditorWidgetPrivate::currentIndex() const { - Q_ASSERT(listView->root()); - Q_ASSERT(listView->root()->property("currentStateIndex").isValid()); - return listView->root()->property("currentStateIndex").toInt(); + Q_ASSERT(listView->rootObject()); + Q_ASSERT(listView->rootObject()->property("currentStateIndex").isValid()); + return listView->rootObject()->property("currentStateIndex").toInt(); } void StatesEditorWidgetPrivate::setCurrentIndex(int i) { - listView->root()->setProperty("currentStateIndex", i); + listView->rootObject()->setProperty("currentStateIndex", i); } bool StatesEditorWidgetPrivate::validStateName(const QString &name) const @@ -148,10 +148,6 @@ StatesEditorWidget::StatesEditorWidget(QWidget *parent): QWidget(parent), m_d(new Internal::StatesEditorWidgetPrivate(this)) { - QFile qmlFile(":/stateseditor/stateslist.qml"); - qmlFile.open(QFile::ReadOnly); - Q_ASSERT(qmlFile.isOpen()); - m_d->statesEditorModel = new Internal::StatesEditorModel(this); m_d->listView = new QmlView(this); @@ -162,26 +158,24 @@ StatesEditorWidget::StatesEditorWidget(QWidget *parent): layout->setSpacing(0); layout->addWidget(m_d->listView.data()); - QString qmlSource(qmlFile.readAll()); - m_d->listView->setQml(qmlSource,":/stateseditor/stateslist.qml"); - + m_d->listView->setSource(QUrl("qrc:/stateseditor/stateslist.qml")); - m_d->listView->setContentResizable(true); + m_d->listView->setResizeMode(QmlView::SizeRootObjectToView); m_d->listView->rootContext()->setContextProperty(QLatin1String("statesEditorModel"), m_d->statesEditorModel.data()); m_d->listView->execute(); - if (!m_d->listView->root()) - throw InvalidQmlSourceException(__LINE__, __FUNCTION__, __FILE__, qmlSource); + if (!m_d->listView->rootObject()) + throw InvalidQmlSourceException(__LINE__, __FUNCTION__, __FILE__); m_d->listView->setFocusPolicy(Qt::ClickFocus); QApplication::sendEvent(m_d->listView->scene(), new QEvent(QEvent::WindowActivate)); - connect(m_d->listView->root(), SIGNAL(currentStateIndexChanged()), m_d, SLOT(currentStateChanged())); - connect(m_d->listView->root(), SIGNAL(createNewState()), m_d, SLOT(addState())); - connect(m_d->listView->root(), SIGNAL(duplicateCurrentState()), m_d, SLOT(duplicateCurrentState())); - connect(m_d->listView->root(), SIGNAL(deleteCurrentState()), m_d, SLOT(removeState())); + connect(m_d->listView->rootObject(), SIGNAL(currentStateIndexChanged()), m_d, SLOT(currentStateChanged())); + connect(m_d->listView->rootObject(), SIGNAL(createNewState()), m_d, SLOT(addState())); + connect(m_d->listView->rootObject(), SIGNAL(duplicateCurrentState()), m_d, SLOT(duplicateCurrentState())); + connect(m_d->listView->rootObject(), SIGNAL(deleteCurrentState()), m_d, SLOT(removeState())); setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred)); diff --git a/src/plugins/qmldesigner/core/include/subcomponentmanager.h b/src/plugins/qmldesigner/core/include/subcomponentmanager.h index b3a9b24cbde1b16a83717d1cd789413bdb148727..cb2c0a322a98efa35ad236150cabe592ad348e45 100644 --- a/src/plugins/qmldesigner/core/include/subcomponentmanager.h +++ b/src/plugins/qmldesigner/core/include/subcomponentmanager.h @@ -32,12 +32,12 @@ #include "corelib_global.h" +#include <metainfo.h> + #include <QObject> #include <QString> #include <QUrl> -#include <QmlDomImport> - -#include <metainfo.h> +#include <private/qmldom_p.h> namespace QmlDesigner { diff --git a/src/plugins/qmldesigner/core/instances/qmlviewnodeinstance.cpp b/src/plugins/qmldesigner/core/instances/qmlviewnodeinstance.cpp index ca8b50b7163b8727177087742a1a6068ff422f37..70b1c049913310ef2b694bde9f773e23f02397cd 100644 --- a/src/plugins/qmldesigner/core/instances/qmlviewnodeinstance.cpp +++ b/src/plugins/qmldesigner/core/instances/qmlviewnodeinstance.cpp @@ -81,7 +81,9 @@ bool QmlViewNodeInstance::isQmlView() const void QmlViewNodeInstance::addItem(QmlGraphicsItem *item) { - item->setParent(view()->root()); + QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem *>(view()->rootObject()); + Q_ASSERT_X(rootItem, Q_FUNC_INFO, "root item is QmlGraphicsItem based"); + item->setParent(rootItem); } } diff --git a/src/plugins/qmldesigner/core/instances/qmlviewnodeinstance.h b/src/plugins/qmldesigner/core/instances/qmlviewnodeinstance.h index 42bfee1f4249a15399065e265edf4f2266f1d684..40aee296190723f33301ef9f111a0124fddfb0c6 100644 --- a/src/plugins/qmldesigner/core/instances/qmlviewnodeinstance.h +++ b/src/plugins/qmldesigner/core/instances/qmlviewnodeinstance.h @@ -32,6 +32,7 @@ #include <QWeakPointer> #include <QmlView> +#include <QmlGraphicsItem> #include "graphicsviewnodeinstance.h" diff --git a/src/plugins/qmldesigner/core/metainfo/subcomponentmanager.cpp b/src/plugins/qmldesigner/core/metainfo/subcomponentmanager.cpp index 212c8fb1c536e86a7bb58b0fb8f30a401729ed95..a5759f988cdbb1a349be0720b5864f652e1a2319 100644 --- a/src/plugins/qmldesigner/core/metainfo/subcomponentmanager.cpp +++ b/src/plugins/qmldesigner/core/metainfo/subcomponentmanager.cpp @@ -33,10 +33,10 @@ #include <QDir> #include <QMetaType> #include <QUrl> -#include <QmlDomDocument> #include <QmlEngine> #include <QmlMetaType> #include <QFileSystemWatcher> +#include <private/qmldom_p.h> enum { debug = false }; diff --git a/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp index c6b2c1bab599073a38f7a8b456550eb05b96df19..0ef9afafeabf031d1f236dc136beeee07e0367cc 100644 --- a/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/core/model/texttomodelmerger.cpp @@ -37,9 +37,10 @@ #include "texttomodelmerger.h" #include "rewriterview.h" #include "variantproperty.h" -#include <QmlDomDocument> + #include <QmlEngine> #include <QSet> +#include <private/qmldom_p.h> using namespace QmlDesigner; using namespace QmlDesigner::Internal; diff --git a/src/plugins/qmldesigner/core/model/texttomodelmerger.h b/src/plugins/qmldesigner/core/model/texttomodelmerger.h index 74663cd91ca5a6741180cc687934e4401e062a97..10e6f0aee479945ba34c2684cc71161fd70dc881 100644 --- a/src/plugins/qmldesigner/core/model/texttomodelmerger.h +++ b/src/plugins/qmldesigner/core/model/texttomodelmerger.h @@ -35,7 +35,7 @@ #include "nodelistproperty.h" #include "modelnode.h" -#include <QmlDomObject> +#include <private/qmldom_p.h> namespace QmlDesigner { diff --git a/src/plugins/qmlinspector/components/objecttree.cpp b/src/plugins/qmlinspector/components/objecttree.cpp index 05f4fc2d18e913872e71f1f402b854ae659741ad..fa627df5841eabd227d3386d0221f9f7baa8a10f 100644 --- a/src/plugins/qmlinspector/components/objecttree.cpp +++ b/src/plugins/qmlinspector/components/objecttree.cpp @@ -38,7 +38,7 @@ #include "objecttree.h" -Q_DECLARE_METATYPE(QmlDebugObjectReference) +//Q_DECLARE_METATYPE(QmlDebugObjectReference) ObjectTree::ObjectTree(QmlEngineDebug *client, QWidget *parent) : QTreeWidget(parent),