Commit 2b018f23 authored by Marco Bubke's avatar Marco Bubke Committed by Thomas Hartmann

QmlDesigner.NodeInstances: Scene Graph prototype

Change-Id: I0c72519f637f260869b2a76b2a3cc7ece46aef57
Reviewed-on: http://codereview.qt.nokia.com/573Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent 27da3098
......@@ -129,8 +129,13 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
applicationPath = envImportPath;
}
QProcessEnvironment enviroment = QProcessEnvironment::systemEnvironment();
enviroment.insert("QML_NO_THREADED_RENDERER", "true");
if (QFileInfo(applicationPath).exists()) {
m_qmlPuppetEditorProcess = new QProcess;
m_qmlPuppetEditorProcess->setProcessEnvironment(enviroment);
m_qmlPuppetEditorProcess->setObjectName("EditorProcess");
connect(m_qmlPuppetEditorProcess.data(), SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), m_qmlPuppetEditorProcess.data(), SLOT(kill()));
bool fowardQmlpuppetOutput = !qgetenv("FORWARD_QMLPUPPET_OUTPUT").isEmpty();
......@@ -140,6 +145,8 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
if (runModus == NormalModus) {
m_qmlPuppetPreviewProcess = new QProcess;
m_qmlPuppetPreviewProcess->setProcessEnvironment(enviroment);
m_qmlPuppetPreviewProcess->setObjectName("PreviewProcess");
connect(m_qmlPuppetPreviewProcess.data(), SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), m_qmlPuppetPreviewProcess.data(), SLOT(kill()));
if (fowardQmlpuppetOutput)
......@@ -147,6 +154,8 @@ NodeInstanceServerProxy::NodeInstanceServerProxy(NodeInstanceView *nodeInstanceV
m_qmlPuppetPreviewProcess->start(applicationPath, QStringList() << socketToken << "previewmode" << "-graphicssystem raster");
m_qmlPuppetRenderProcess = new QProcess;
m_qmlPuppetRenderProcess->setProcessEnvironment(enviroment);
m_qmlPuppetRenderProcess->setObjectName("RenderProcess");
connect(m_qmlPuppetRenderProcess.data(), SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), m_qmlPuppetRenderProcess.data(), SLOT(kill()));
if (fowardQmlpuppetOutput)
......@@ -298,6 +307,7 @@ void NodeInstanceServerProxy::writeCommand(const QVariant &command)
void NodeInstanceServerProxy::processFinished(int /*exitCode*/, QProcess::ExitStatus exitStatus)
{
qDebug() << "Process finished:" << sender();
if (m_firstSocket)
m_firstSocket->close();
if (m_secondSocket)
......
......@@ -123,6 +123,9 @@ public:
QStringList imports() const;
QObject *dummyContextObject() const;
virtual QDeclarativeView *declarativeView() const = 0;
virtual QSGView *sgView() const = 0;
public slots:
void refreshLocalFileProperty(const QString &path);
void refreshDummyData(const QString &path);
......@@ -176,8 +179,6 @@ protected:
void setTimerId(int timerId);
int timerId() const;
virtual QDeclarativeView *declarativeView() const = 0;
virtual QSGView *sgView() const = 0;
QDeclarativeContext *rootContext() const;
......
......@@ -64,6 +64,8 @@
#include "qt5informationnodeinstanceserver.h"
#include <QSGItem>
#include "servernodeinstance.h"
#include "childrenchangeeventfilter.h"
#include "propertyabstractcontainer.h"
......@@ -93,6 +95,8 @@
#include "dummycontextobject.h"
#include "designersupportfunctions.h"
namespace QmlDesigner {
Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) :
......@@ -102,6 +106,87 @@ Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceC
void Qt5InformationNodeInstanceServer::collectItemChangesAndSendChangeCommands()
{
static bool inFunction = false;
if (!inFunction) {
inFunction = true;
QSet<ServerNodeInstance> informationChangedInstanceSet;
QVector<InstancePropertyPair> propertyChangedList;
bool adjustSceneRect = false;
if (sgView()) {
foreach (QSGItem *item, allItems()) {
if (item && hasInstanceForObject(item)) {
ServerNodeInstance instance = instanceForObject(item);
DesignerSupport::DirtyType informationsDirty = DesignerSupport::DirtyType(DesignerSupport::TransformUpdateMask
| DesignerSupport::Visible
| DesignerSupport::ZValue
| DesignerSupport::OpacityValue);
if (DesignerSupport::dirty(item, informationsDirty))
informationChangedInstanceSet.insert(instance);
if (DesignerSupport::dirty(item, DesignerSupport::ParentChanged)) {
m_parentChangedSet.insert(instance);
informationChangedInstanceSet.insert(instance);
}
// if (d->geometryChanged) {
// if (instance.isRootNodeInstance())
// declarativeView()->scene()->setSceneRect(item->boundingRect());
// }
}
}
foreach (const InstancePropertyPair& property, changedPropertyList()) {
const ServerNodeInstance instance = property.first;
const QString propertyName = property.second;
if (instance.isValid()) {
if (instance.isRootNodeInstance() && (propertyName == "width" || propertyName == "height"))
adjustSceneRect = true;
if (propertyName.contains("anchors"))
informationChangedInstanceSet.insert(instance);
propertyChangedList.append(property);
}
}
resetAllItems();
clearChangedPropertyList();
if (!informationChangedInstanceSet.isEmpty())
nodeInstanceClient()->informationChanged(createAllInformationChangedCommand(informationChangedInstanceSet.toList()));
if (!propertyChangedList.isEmpty())
nodeInstanceClient()->valuesChanged(createValuesChangedCommand(propertyChangedList));
if (!m_parentChangedSet.isEmpty()) {
sendChildrenChangedCommand(m_parentChangedSet.toList());
m_parentChangedSet.clear();
}
// if (adjustSceneRect) {
// QRectF boundingRect = rootNodeInstance().boundingRect();
// if (boundingRect.isValid()) {
// declarativeView()->setSceneRect(boundingRect);
// }
// }
if (!m_completedComponentList.isEmpty()) {
nodeInstanceClient()->componentCompleted(createComponentCompletedCommand(m_completedComponentList));
m_completedComponentList.clear();
}
slowDownRenderTimer();
nodeInstanceClient()->flush();
nodeInstanceClient()->synchronizeWithClientProcess();
}
inFunction = false;
}
}
void Qt5InformationNodeInstanceServer::reparentInstances(const ReparentInstancesCommand &command)
......@@ -113,12 +198,12 @@ void Qt5InformationNodeInstanceServer::reparentInstances(const ReparentInstances
}
}
NodeInstanceServer::reparentInstances(command);
Qt5NodeInstanceServer::reparentInstances(command);
}
void Qt5InformationNodeInstanceServer::clearScene(const ClearSceneCommand &command)
{
NodeInstanceServer::clearScene(command);
Qt5NodeInstanceServer::clearScene(command);
m_parentChangedSet.clear();
m_completedComponentList.clear();
......@@ -126,7 +211,7 @@ void Qt5InformationNodeInstanceServer::clearScene(const ClearSceneCommand &comma
void Qt5InformationNodeInstanceServer::createScene(const CreateSceneCommand &command)
{
NodeInstanceServer::createScene(command);
Qt5NodeInstanceServer::createScene(command);
QList<ServerNodeInstance> instanceList;
foreach (const InstanceContainer &container, command.instances()) {
......@@ -149,13 +234,18 @@ void Qt5InformationNodeInstanceServer::sendChildrenChangedCommand(const QList<Se
QList<ServerNodeInstance> noParentList;
foreach (const ServerNodeInstance &child, childList) {
if (!child.hasParent())
if (!child.hasParent()) {
noParentList.append(child);
else
parentSet.insert(child.parent());
} else {
ServerNodeInstance parent = child.parent();
if (parent.isValid()) {
parentSet.insert(parent);
} else {
noParentList.append(child);
}
}
}
foreach (const ServerNodeInstance &parent, parentSet)
nodeInstanceClient()->childrenChanged(createChildrenChangedCommand(parent, parent.childItems()));
......@@ -166,7 +256,7 @@ void Qt5InformationNodeInstanceServer::sendChildrenChangedCommand(const QList<Se
void Qt5InformationNodeInstanceServer::completeComponent(const CompleteComponentCommand &command)
{
NodeInstanceServer::completeComponent(command);
Qt5NodeInstanceServer::completeComponent(command);
QList<ServerNodeInstance> instanceList;
foreach (qint32 instanceId, command.instances()) {
......
......@@ -106,6 +106,7 @@ void Qt5NodeInstanceServer::initializeView(const QVector<AddImportContainer> &/*
#ifdef Q_WS_MAC
sgView()->setAttribute(Qt::WA_DontShowOnScreen, true);
#endif
sgView()->setUpdatesEnabled(false);
}
QDeclarativeView *Qt5NodeInstanceServer::declarativeView() const
......@@ -129,7 +130,8 @@ void Qt5NodeInstanceServer::resizeCanvasSizeToRootItemSize()
void Qt5NodeInstanceServer::resetAllItems()
{
foreach (QSGItem *item, allItems())
DesignerSupport::resetDirty(item);
}
QList<ServerNodeInstance> Qt5NodeInstanceServer::setupScene(const CreateSceneCommand &command)
......
......@@ -64,6 +64,8 @@
#include "qt5rendernodeinstanceserver.h"
#include <QSGItem>
#include "servernodeinstance.h"
#include "childrenchangeeventfilter.h"
#include "propertyabstractcontainer.h"
......@@ -93,6 +95,8 @@
#include "dummycontextobject.h"
#include "designersupportfunctions.h"
namespace QmlDesigner {
Qt5RenderNodeInstanceServer::Qt5RenderNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) :
......@@ -102,8 +106,46 @@ Qt5RenderNodeInstanceServer::Qt5RenderNodeInstanceServer(NodeInstanceClientInter
void Qt5RenderNodeInstanceServer::collectItemChangesAndSendChangeCommands()
{
static bool inFunction = false;
if (!inFunction) {
inFunction = true;
bool adjustSceneRect = false;
if (sgView()) {
foreach (QSGItem *item, allItems()) {
if (item && hasInstanceForObject(item)) {
ServerNodeInstance instance = instanceForObject(item);
if (DesignerSupport::dirty(item, DesignerSupport::ContentUpdateMask))
m_dirtyInstanceSet.insert(instance);
}
}
clearChangedPropertyList();
resetAllItems();
if (!m_dirtyInstanceSet.isEmpty() && nodeInstanceClient()->bytesToWrite() < 10000) {
nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(m_dirtyInstanceSet.toList()));
m_dirtyInstanceSet.clear();
}
// if (adjustSceneRect) {
// QRectF boundingRect = rootNodeInstance().boundingRect();
// if (boundingRect.isValid()) {
// declarativeView()->setSceneRect(boundingRect);
// }
// }
slowDownRenderTimer();
nodeInstanceClient()->flush();
nodeInstanceClient()->synchronizeWithClientProcess();
}
inFunction = false;
}
}
void Qt5RenderNodeInstanceServer::createScene(const CreateSceneCommand &command)
{
NodeInstanceServer::createScene(command);
......
......@@ -69,11 +69,13 @@
#include "qt5nodeinstanceserver.h"
#include <QDeclarativeExpression>
#include <QSGView>
#include <cmath>
#include <QHash>
#include <QtDebug>
namespace QmlDesigner {
namespace Internal {
......@@ -233,7 +235,7 @@ void SGItemNodeInstance::setMovable(bool movable)
SGItemNodeInstance::Pointer SGItemNodeInstance::create(QObject *object)
{
QSGItem *sgItem = dynamic_cast<QSGItem*>(object);
QSGItem *sgItem = qobject_cast<QSGItem*>(object);
Q_ASSERT(sgItem);
......@@ -252,10 +254,17 @@ SGItemNodeInstance::Pointer SGItemNodeInstance::create(QObject *object)
return instance;
}
void SGItemNodeInstance::initialize(const Pointer &objectNodeInstance)
void SGItemNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance)
{
if (instanceId() == 0) {
DesignerSupport::setRootItem(nodeInstanceServer()->sgView(), sgItem());
} else {
sgItem()->setParentItem(qobject_cast<QSGItem*>(nodeInstanceServer()->sgView()->rootObject()));
}
designerSupport()->refFromEffectItem(sgItem());
ObjectNodeInstance::initialize(objectNodeInstance);
sgItem()->update();
}
bool SGItemNodeInstance::isSGItem() const
......@@ -559,6 +568,7 @@ void SGItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentIn
}
refresh();
DesignerSupport::updateDirtyNode(sgItem());
}
static bool isValidAnchorName(const QString &name)
......
......@@ -86,7 +86,7 @@ public:
~SGItemNodeInstance();
static Pointer create(QObject *objectToBeWrapped);
void initialize(const Pointer &objectNodeInstance);
void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance);
bool isSGItem() const;
......
......@@ -210,7 +210,7 @@ void Qt4InformationNodeInstanceServer::reparentInstances(const ReparentInstances
}
}
NodeInstanceServer::reparentInstances(command);
Qt4NodeInstanceServer::reparentInstances(command);
}
void Qt4InformationNodeInstanceServer::clearScene(const ClearSceneCommand &command)
......@@ -223,7 +223,7 @@ void Qt4InformationNodeInstanceServer::clearScene(const ClearSceneCommand &comma
void Qt4InformationNodeInstanceServer::createScene(const CreateSceneCommand &command)
{
NodeInstanceServer::createScene(command);
Qt4NodeInstanceServer::createScene(command);
QList<ServerNodeInstance> instanceList;
foreach(const InstanceContainer &container, command.instances()) {
......@@ -263,7 +263,7 @@ void Qt4InformationNodeInstanceServer::sendChildrenChangedCommand(const QList<Se
void Qt4InformationNodeInstanceServer::completeComponent(const CompleteComponentCommand &command)
{
NodeInstanceServer::completeComponent(command);
Qt4NodeInstanceServer::completeComponent(command);
QList<ServerNodeInstance> instanceList;
foreach(qint32 instanceId, command.instances()) {
......
......@@ -148,7 +148,7 @@ void Qt4RenderNodeInstanceServer::collectItemChangesAndSendChangeCommands()
void Qt4RenderNodeInstanceServer::createScene(const CreateSceneCommand &command)
{
NodeInstanceServer::createScene(command);
Qt4NodeInstanceServer::createScene(command);
QList<ServerNodeInstance> instanceList;
foreach(const InstanceContainer &container, command.instances()) {
......@@ -163,14 +163,14 @@ void Qt4RenderNodeInstanceServer::createScene(const CreateSceneCommand &command)
void Qt4RenderNodeInstanceServer::clearScene(const ClearSceneCommand &command)
{
NodeInstanceServer::clearScene(command);
Qt4NodeInstanceServer::clearScene(command);
m_dirtyInstanceSet.clear();
}
void Qt4RenderNodeInstanceServer::completeComponent(const CompleteComponentCommand &command)
{
NodeInstanceServer::completeComponent(command);
Qt4NodeInstanceServer::completeComponent(command);
QList<ServerNodeInstance> instanceList;
foreach(qint32 instanceId, command.instances()) {
......
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