Commit e32cd328 authored by Marco Bubke's avatar Marco Bubke

QmlDesigner.NodeInstances: Refactor server

parent 99336fee
......@@ -155,41 +155,8 @@ void NodeInstanceServer::stopRenderTimer()
void NodeInstanceServer::createScene(const CreateSceneCommand &command)
{
Q_ASSERT(!m_declarativeView.data());
m_declarativeView = new QDeclarativeView;
m_declarativeView->setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
m_declarativeView->show();
m_declarativeView->setAttribute(Qt::WA_DontShowOnScreen, true);
if (!command.fileUrl().isEmpty())
engine()->setBaseUrl(command.fileUrl());
addImports(command.imports());
static_cast<QGraphicsScenePrivate*>(QObjectPrivate::get(m_declarativeView->scene()))->processDirtyItemsEmitted = true;
QList<ServerNodeInstance> instanceList = createInstances(command.instances());
reparentInstances(command.reparentInstances());
foreach(const IdContainer &container, command.ids()) {
if (hasInstanceForId(container.instanceId()))
instanceForId(container.instanceId()).setId(container.id());
}
foreach(const PropertyValueContainer &container, command.valueChanges())
setInstancePropertyVariant(container);
foreach(const PropertyBindingContainer &container, command.bindingChanges())
setInstancePropertyBinding(container);
foreach(ServerNodeInstance instance, instanceList)
instance.doComponentComplete();
m_declarativeView->scene()->setSceneRect(rootNodeInstance().boundingRect());
initializeDeclarativeView();
QList<ServerNodeInstance> instanceList = setupScene(command);
nodeInstanceClient()->informationChanged(createAllInformationChangedCommand(instanceList, true));
nodeInstanceClient()->valuesChanged(createValuesChangedCommand(instanceList));
......@@ -807,6 +774,52 @@ void NodeInstanceServer::resetAllItems()
static_cast<QGraphicsScenePrivate*>(QObjectPrivate::get(m_declarativeView->scene()))->resetDirtyItem(item);
}
void NodeInstanceServer::initializeDeclarativeView()
{
Q_ASSERT(!m_declarativeView.data());
m_declarativeView = new QDeclarativeView;
#ifndef Q_WS_MAC
m_declarativeView->setAttribute(Qt::WA_DontShowOnScreen, true);
#endif
m_declarativeView->setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
m_declarativeView->show();
#ifdef Q_WS_MAC
m_declarativeView->setAttribute(Qt::WA_DontShowOnScreen, true);
#endif
}
QList<ServerNodeInstance> NodeInstanceServer::setupScene(const CreateSceneCommand &command)
{
if (!command.fileUrl().isEmpty())
engine()->setBaseUrl(command.fileUrl());
addImports(command.imports());
static_cast<QGraphicsScenePrivate*>(QObjectPrivate::get(m_declarativeView->scene()))->processDirtyItemsEmitted = true;
QList<ServerNodeInstance> instanceList = createInstances(command.instances());
reparentInstances(command.reparentInstances());
foreach(const IdContainer &container, command.ids()) {
if (hasInstanceForId(container.instanceId()))
instanceForId(container.instanceId()).setId(container.id());
}
foreach(const PropertyValueContainer &container, command.valueChanges())
setInstancePropertyVariant(container);
foreach(const PropertyBindingContainer &container, command.bindingChanges())
setInstancePropertyBinding(container);
foreach(ServerNodeInstance instance, instanceList)
instance.doComponentComplete();
m_declarativeView->scene()->setSceneRect(rootNodeInstance().boundingRect());
return instanceList;
}
void NodeInstanceServer::findItemChangesAndSendChangeCommands()
{
static bool inFunction = false;
......
......@@ -121,6 +121,8 @@ protected:
void startRenderTimer();
void slowDownRenderTimer();
void stopRenderTimer();
void initializeDeclarativeView();
QList<ServerNodeInstance> setupScene(const CreateSceneCommand &command);
private:
ServerNodeInstance m_rootNodeInstance;
......
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