Commit afa830ec authored by Kai Koehne's avatar Kai Koehne

Fix compilation against latest Qt master

The API of QmlView has changed. Also, the QmlDom classes became private.

Patch provided by Aaron Kennedy.

Reviewed-by: akennedy
parent d215737d
......@@ -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();
}
......
......@@ -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&)));
}
......
......@@ -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));
......
......@@ -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 {
......
......@@ -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);
}
}
......
......@@ -32,6 +32,7 @@
#include <QWeakPointer>
#include <QmlView>
#include <QmlGraphicsItem>
#include "graphicsviewnodeinstance.h"
......
......@@ -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 };
......
......@@ -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;
......
......@@ -35,7 +35,7 @@
#include "nodelistproperty.h"
#include "modelnode.h"
#include <QmlDomObject>
#include <private/qmldom_p.h>
namespace QmlDesigner {
......
......@@ -38,7 +38,7 @@
#include "objecttree.h"
Q_DECLARE_METATYPE(QmlDebugObjectReference)
//Q_DECLARE_METATYPE(QmlDebugObjectReference)
ObjectTree::ObjectTree(QmlEngineDebug *client, QWidget *parent)
: QTreeWidget(parent),
......
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