QmlDesigner.Instances: Refactor the qml2 puppet

Change-Id: Iaa7a744ecf13e011addc573a381ea523d2d50a55
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
Marco Bubke
2012-09-19 15:57:22 +02:00
parent 51f847246e
commit 770ab68c45
51 changed files with 6199 additions and 197 deletions
@@ -30,6 +30,8 @@
#include "changenodesourcecommand.h"
#include <QDataStream>
namespace QmlDesigner {
ChangeNodeSourceCommand::ChangeNodeSourceCommand()
@@ -32,6 +32,7 @@
#define CHANGENODESOURCECOMMAND_H
#include <QMetaType>
#include <QString>
namespace QmlDesigner {
@@ -30,6 +30,8 @@
#include "completecomponentcommand.h"
#include <QDataStream>
namespace QmlDesigner {
CompleteComponentCommand::CompleteComponentCommand()
@@ -30,6 +30,8 @@
#include "componentcompletedcommand.h"
#include <QDataStream>
namespace QmlDesigner {
ComponentCompletedCommand::ComponentCompletedCommand()
@@ -30,6 +30,8 @@
#include "removeinstancescommand.h"
#include <QDataStream>
namespace QmlDesigner {
RemoveInstancesCommand::RemoveInstancesCommand()
@@ -33,6 +33,8 @@
#include "removesharedmemorycommand.h"
#include <QDataStream>
namespace QmlDesigner {
RemoveSharedMemoryCommand::RemoveSharedMemoryCommand()
@@ -30,6 +30,8 @@
#include "reparentinstancescommand.h"
#include <QDataStream>
namespace QmlDesigner {
ReparentInstancesCommand::ReparentInstancesCommand()
@@ -30,6 +30,8 @@
#include "tokencommand.h"
#include <QDataStream>
namespace QmlDesigner {
TokenCommand::TokenCommand()
@@ -34,6 +34,7 @@
#include <QMetaType>
#include <QVector>
#include <QString>
namespace QmlDesigner {
@@ -30,6 +30,8 @@
#include "instancecontainer.h"
#include <QDataStream>
namespace QmlDesigner {
InstanceContainer::InstanceContainer()
@@ -30,6 +30,8 @@
#include "reparentcontainer.h"
#include <QDataStream>
namespace QmlDesigner {
ReparentContainer::ReparentContainer()
@@ -32,6 +32,7 @@
#define REPARENTCONTAINER_H
#include <qmetatype.h>
#include <QString>
namespace QmlDesigner {
@@ -0,0 +1,85 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "anchorchangesnodeinstance.h"
namespace QmlDesigner {
namespace Internal {
AnchorChangesNodeInstance::AnchorChangesNodeInstance(QObject *object) :
ObjectNodeInstance(object)
{
}
AnchorChangesNodeInstance::Pointer AnchorChangesNodeInstance::create(QObject *object)
{
Q_ASSERT(object);
Pointer instance(new AnchorChangesNodeInstance(object));
return instance;
}
void AnchorChangesNodeInstance::setPropertyVariant(const QString &/*name*/, const QVariant &/*value*/)
{
}
void AnchorChangesNodeInstance::setPropertyBinding(const QString &/*name*/, const QString &/*expression*/)
{
}
QVariant AnchorChangesNodeInstance::property(const QString &/*name*/) const
{
return QVariant();
}
void AnchorChangesNodeInstance::resetProperty(const QString &/*name*/)
{
}
void AnchorChangesNodeInstance::reparent(const ServerNodeInstance &/*oldParentInstance*/,
const QString &/*oldParentProperty*/,
const ServerNodeInstance &/*newParentInstance*/,
const QString &/*newParentProperty*/)
{
}
QObject *AnchorChangesNodeInstance::changesObject() const
{
return object();
}
} // namespace Internal
} // namespace QmlDesigner
@@ -0,0 +1,76 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef QMLDESIGNER_ANCHORCHANGESNODEINSTANCE_H
#define QMLDESIGNER_ANCHORCHANGESNODEINSTANCE_H
#include "objectnodeinstance.h"
#include <QPair>
#include <QWeakPointer>
QT_BEGIN_NAMESPACE
class QQmlProperty;
QT_END_NAMESPACE
namespace QmlDesigner {
namespace Internal {
class AnchorChangesNodeInstance : public ObjectNodeInstance
{
public:
typedef QSharedPointer<AnchorChangesNodeInstance> Pointer;
typedef QWeakPointer<AnchorChangesNodeInstance> WeakPointer;
static Pointer create(QObject *objectToBeWrapped);
virtual void setPropertyVariant(const QString &name, const QVariant &value);
virtual void setPropertyBinding(const QString &name, const QString &expression);
virtual QVariant property(const QString &name) const;
virtual void resetProperty(const QString &name);
using ObjectNodeInstance::reparent; // keep the virtual reparent(...) method around
void reparent(const ServerNodeInstance &oldParentInstance,
const QString &oldParentProperty,
const ServerNodeInstance &newParentInstance,
const QString &newParentProperty);
protected:
AnchorChangesNodeInstance(QObject *object);
QObject *changesObject() const;
};
} // namespace Internal
} // namespace QmlDesigner
#endif // QMLDESIGNER_ANCHORCHANGESNODEINSTANCE_H
@@ -0,0 +1,93 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "behaviornodeinstance.h"
#include <private/qquickbehavior_p.h>
namespace QmlDesigner {
namespace Internal {
BehaviorNodeInstance::BehaviorNodeInstance(QObject *object)
: ObjectNodeInstance(object),
m_isEnabled(true)
{
}
BehaviorNodeInstance::Pointer BehaviorNodeInstance::create(QObject *object)
{
QQuickBehavior* behavior = qobject_cast<QQuickBehavior*>(object);
Q_ASSERT(behavior);
Pointer instance(new BehaviorNodeInstance(behavior));
instance->populateResetHashes();
behavior->setEnabled(false);
return instance;
}
void BehaviorNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)
{
if (name == "enabled")
return;
ObjectNodeInstance::setPropertyVariant(name, value);
}
void BehaviorNodeInstance::setPropertyBinding(const QString &name, const QString &expression)
{
if (name == "enabled")
return;
ObjectNodeInstance::setPropertyBinding(name, expression);
}
QVariant BehaviorNodeInstance::property(const QString &name) const
{
if (name == "enabled")
return QVariant::fromValue(m_isEnabled);
return ObjectNodeInstance::property(name);
}
void BehaviorNodeInstance::resetProperty(const QString &name)
{
if (name == "enabled")
m_isEnabled = true;
ObjectNodeInstance::resetProperty(name);
}
} // namespace Internal
} // namespace QmlDesigner
@@ -0,0 +1,63 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef BEHAVIORNODEINSTANCE_H
#define BEHAVIORNODEINSTANCE_H
#include "objectnodeinstance.h"
namespace QmlDesigner {
namespace Internal {
class BehaviorNodeInstance : public ObjectNodeInstance
{
public:
typedef QSharedPointer<BehaviorNodeInstance> Pointer;
typedef QWeakPointer<BehaviorNodeInstance> WeakPointer;
BehaviorNodeInstance(QObject *object);
static Pointer create(QObject *objectToBeWrapped);
void setPropertyVariant(const QString &name, const QVariant &value);
void setPropertyBinding(const QString &name, const QString &expression);
QVariant property(const QString &name) const;
void resetProperty(const QString &name);
private:
bool m_isEnabled;
};
} // namespace Internal
} // namespace QmlDesigner
#endif // BEHAVIORNODEINSTANCE_H
@@ -0,0 +1,59 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "childrenchangeeventfilter.h"
#include <QEvent>
namespace QmlDesigner {
namespace Internal {
ChildrenChangeEventFilter::ChildrenChangeEventFilter(QObject *parent)
: QObject(parent)
{
}
bool ChildrenChangeEventFilter::eventFilter(QObject * /*object*/, QEvent *event)
{
switch (event->type()) {
case QEvent::ChildAdded:
case QEvent::ChildRemoved:
{
QChildEvent *childEvent = static_cast<QChildEvent*>(event);
emit childrenChanged(childEvent->child()); break;
}
default: break;
}
return false;
}
} // namespace Internal
} // namespace QmlDesigner
@@ -0,0 +1,57 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef CHILDRENCHANGEEVENTFILTER_H
#define CHILDRENCHANGEEVENTFILTER_H
#include <QObject>
namespace QmlDesigner {
namespace Internal {
class ChildrenChangeEventFilter : public QObject
{
Q_OBJECT
public:
ChildrenChangeEventFilter(QObject *parent);
signals:
void childrenChanged(QObject *object);
protected:
bool eventFilter(QObject *object, QEvent *event);
};
} // namespace Internal
} // namespace QmlDesigner
#endif // CHILDRENCHANGEEVENTFILTER_H
@@ -0,0 +1,95 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "componentnodeinstance.h"
#include <QQmlComponent>
#include <QQmlContext>
#include <QDebug>
namespace QmlDesigner {
namespace Internal {
ComponentNodeInstance::ComponentNodeInstance(QQmlComponent *component)
: ObjectNodeInstance(component)
{
}
QQmlComponent *ComponentNodeInstance::component() const
{
Q_ASSERT(qobject_cast<QQmlComponent*>(object()));
return static_cast<QQmlComponent*>(object());
}
ComponentNodeInstance::Pointer ComponentNodeInstance::create(QObject *object)
{
QQmlComponent *component = qobject_cast<QQmlComponent *>(object);
Q_ASSERT(component);
Pointer instance(new ComponentNodeInstance(component));
instance->populateResetHashes();
return instance;
}
bool ComponentNodeInstance::hasContent() const
{
return true;
}
void ComponentNodeInstance::setNodeSource(const QString &source)
{
QByteArray importArray;
foreach (const QString &import, nodeInstanceServer()->imports()) {
importArray.append(import.toUtf8());
}
QByteArray data(source.toUtf8());
data.prepend(importArray);
data.append("\n");
component()->setData(data, QUrl(nodeInstanceServer()->fileUrl().toString() +
QLatin1Char('_')+ id()));
setId(id());
if (component()->isError()) {
foreach (const QQmlError &error, component()->errors())
qDebug() << error;
}
}
} // Internal
} // QmlDesigner
@@ -0,0 +1,63 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef COMPONENTNODEINSTANCE_H
#define COMPONENTNODEINSTANCE_H
#include "objectnodeinstance.h"
QT_BEGIN_NAMESPACE
class QQmlComponent;
QT_END_NAMESPACE
namespace QmlDesigner {
namespace Internal {
class ComponentNodeInstance : public ObjectNodeInstance
{
public:
typedef QSharedPointer<ComponentNodeInstance> Pointer;
typedef QWeakPointer<ComponentNodeInstance> WeakPointer;
ComponentNodeInstance(QQmlComponent *component);
static Pointer create(QObject *objectToBeWrapped);
bool hasContent() const;
void setNodeSource(const QString &source);
private: //function
QQmlComponent *component() const;
};
} // Internal
} // QmlDesigner
#endif // COMPONENTNODEINSTANCE_H
@@ -0,0 +1,53 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "dummycontextobject.h"
namespace QmlDesigner {
DummyContextObject::DummyContextObject(QObject *parent) :
QObject(parent)
{
}
QObject *DummyContextObject::parentDummy() const
{
return m_dummyParent.data();
}
void DummyContextObject::setParentDummy(QObject *parentDummy)
{
if (m_dummyParent.data() != parentDummy) {
m_dummyParent = parentDummy;
emit parentDummyChanged();
}
}
} // namespace QmlDesigner
@@ -0,0 +1,61 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef DUMMYCONTEXTOBJECT_H
#define DUMMYCONTEXTOBJECT_H
#include <QObject>
#include <QWeakPointer>
#include <qqml.h>
namespace QmlDesigner {
class DummyContextObject : public QObject
{
Q_OBJECT
Q_PROPERTY(QObject * parent READ parentDummy WRITE setParentDummy NOTIFY parentDummyChanged DESIGNABLE false FINAL)
public:
explicit DummyContextObject(QObject *parent = 0);
QObject *parentDummy() const;
void setParentDummy(QObject *parentDummy);
signals:
void parentDummyChanged();
private:
QWeakPointer<QObject> m_dummyParent;
};
} // namespace QmlDesigner
QML_DECLARE_TYPE(QmlDesigner::DummyContextObject)
#endif // DUMMYCONTEXTOBJECT_H
@@ -0,0 +1,110 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "dummynodeinstance.h"
namespace QmlDesigner {
namespace Internal {
DummyNodeInstance::DummyNodeInstance()
: ObjectNodeInstance(new QObject)
{
}
DummyNodeInstance::Pointer DummyNodeInstance::create()
{
return Pointer(new DummyNodeInstance);
}
void DummyNodeInstance::paint(QPainter * /*painter*/)
{
}
QRectF DummyNodeInstance::boundingRect() const
{
return QRectF();
}
QPointF DummyNodeInstance::position() const
{
return QPointF();
}
QSizeF DummyNodeInstance::size() const
{
return QSizeF();
}
QTransform DummyNodeInstance::transform() const
{
return QTransform();
}
double DummyNodeInstance::opacity() const
{
return 0.0;
}
void DummyNodeInstance::setPropertyVariant(const QString &/*name*/, const QVariant &/*value*/)
{
}
void DummyNodeInstance::setPropertyBinding(const QString &/*name*/, const QString &/*expression*/)
{
}
void DummyNodeInstance::setId(const QString &/*id*/)
{
}
QVariant DummyNodeInstance::property(const QString &/*name*/) const
{
return QVariant();
}
QStringList DummyNodeInstance::properties()
{
return QStringList();
}
QStringList DummyNodeInstance::localProperties()
{
return QStringList();
}
void DummyNodeInstance::initializePropertyWatcher(const ObjectNodeInstance::Pointer &/*objectNodeInstance*/)
{
}
} // namespace Internal
} // namespace QmlDesigner
@@ -0,0 +1,73 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef DUMMYNODEINSTANCE_H
#define DUMMYNODEINSTANCE_H
#include <QWeakPointer>
#include "objectnodeinstance.h"
namespace QmlDesigner {
namespace Internal {
class DummyNodeInstance : public ObjectNodeInstance
{
public:
typedef QSharedPointer<DummyNodeInstance> Pointer;
typedef QWeakPointer<DummyNodeInstance> WeakPointer;
static Pointer create();
void paint(QPainter *painter);
QRectF boundingRect() const;
QPointF position() const;
QSizeF size() const;
QTransform transform() const;
double opacity() const;
void setPropertyVariant(const QString &name, const QVariant &value);
void setPropertyBinding(const QString &name, const QString &expression);
void setId(const QString &id);
QVariant property(const QString &name) const;
QStringList properties();
QStringList localProperties();
void initializePropertyWatcher(const ObjectNodeInstance::Pointer &objectNodeInstance);
protected:
DummyNodeInstance();
};
}
}
#endif // DUMMYNODEINSTANCE_H
@@ -1,15 +1,45 @@
INCLUDEPATH += $$PWD/
HEADERS += $$PWD/qt5nodeinstanceserver.h \
instances/qt5informationnodeinstanceserver.h \
instances/qt5rendernodeinstanceserver.h \
instances/qt5previewnodeinstanceserver.h
HEADERS += $$PWD/qt5nodeinstanceserver.h
HEADERS += $$PWD/qt5informationnodeinstanceserver.h
HEADERS += $$PWD/qt5rendernodeinstanceserver.h
HEADERS += $$PWD/qt5previewnodeinstanceserver.h
HEADERS += $$PWD/qt5nodeinstanceclientproxy.h
HEADERS += $$PWD/sgitemnodeinstance.h
HEADERS += $$PWD/behaviornodeinstance.h
HEADERS += $$PWD/dummycontextobject.h
HEADERS += $$PWD/childrenchangeeventfilter.h
HEADERS += $$PWD/componentnodeinstance.h
HEADERS += $$PWD/dummynodeinstance.h
HEADERS += $$PWD/nodeinstanceclientproxy.h
HEADERS += $$PWD/nodeinstancemetaobject.h
HEADERS += $$PWD/nodeinstanceserver.h
HEADERS += $$PWD/nodeinstancesignalspy.h
HEADERS += $$PWD/objectnodeinstance.h
HEADERS += $$PWD/qmlpropertychangesnodeinstance.h
HEADERS += $$PWD/qmlstatenodeinstance.h
HEADERS += $$PWD/qmltransitionnodeinstance.h
HEADERS += $$PWD/servernodeinstance.h
HEADERS += $$PWD/anchorchangesnodeinstance.h
SOURCES += $$PWD/qt5nodeinstanceserver.cpp \
instances/qt5informationnodeinstanceserver.cpp \
instances/qt5rendernodeinstanceserver.cpp \
instances/qt5previewnodeinstanceserver.cpp
SOURCES += $$PWD/qt5nodeinstanceserver.cpp
SOURCES += $$PWD/qt5informationnodeinstanceserver.cpp
SOURCES += $$PWD/qt5rendernodeinstanceserver.cpp
SOURCES += $$PWD/qt5previewnodeinstanceserver.cpp
SOURCES += $$PWD/qt5nodeinstanceclientproxy.cpp
SOURCES += $$PWD/sgitemnodeinstance.cpp
SOURCES += $$PWD/behaviornodeinstance.cpp
SOURCES += $$PWD/dummycontextobject.cpp
SOURCES += $$PWD/childrenchangeeventfilter.cpp
SOURCES += $$PWD/componentnodeinstance.cpp
SOURCES += $$PWD/dummynodeinstance.cpp
SOURCES += $$PWD/nodeinstanceclientproxy.cpp
SOURCES += $$PWD/nodeinstancemetaobject.cpp
SOURCES += $$PWD/nodeinstanceserver.cpp
SOURCES += $$PWD/nodeinstancesignalspy.cpp
SOURCES += $$PWD/objectnodeinstance.cpp
SOURCES += $$PWD/qmlpropertychangesnodeinstance.cpp
SOURCES += $$PWD/qmlstatenodeinstance.cpp
SOURCES += $$PWD/qmltransitionnodeinstance.cpp
SOURCES += $$PWD/servernodeinstance.cpp
SOURCES += $$PWD/anchorchangesnodeinstance.cpp
@@ -0,0 +1,346 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "nodeinstanceclientproxy.h"
#include <QLocalSocket>
#include <QVariant>
#include <QCoreApplication>
#include <QStringList>
#include "nodeinstanceserverinterface.h"
#include "propertyabstractcontainer.h"
#include "propertyvaluecontainer.h"
#include "propertybindingcontainer.h"
#include "instancecontainer.h"
#include "createinstancescommand.h"
#include "createscenecommand.h"
#include "changevaluescommand.h"
#include "changebindingscommand.h"
#include "changeauxiliarycommand.h"
#include "changefileurlcommand.h"
#include "removeinstancescommand.h"
#include "clearscenecommand.h"
#include "removepropertiescommand.h"
#include "reparentinstancescommand.h"
#include "changeidscommand.h"
#include "changestatecommand.h"
#include "completecomponentcommand.h"
#include "synchronizecommand.h"
#include "removesharedmemorycommand.h"
#include "tokencommand.h"
#include "informationchangedcommand.h"
#include "pixmapchangedcommand.h"
#include "valueschangedcommand.h"
#include "childrenchangedcommand.h"
#include "imagecontainer.h"
#include "statepreviewimagechangedcommand.h"
#include "componentcompletedcommand.h"
#include "changenodesourcecommand.h"
namespace QmlDesigner {
NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent)
: QObject(parent),
m_nodeInstanceServer(0),
m_blockSize(0),
m_writeCommandCounter(0),
m_lastReadCommandCounter(0),
m_synchronizeId(-1)
{
}
void NodeInstanceClientProxy::initializeSocket()
{
m_socket = new QLocalSocket(this);
connect(m_socket, SIGNAL(readyRead()), this, SLOT(readDataStream()));
connect(m_socket, SIGNAL(error(QLocalSocket::LocalSocketError)), QCoreApplication::instance(), SLOT(quit()));
connect(m_socket, SIGNAL(disconnected()), QCoreApplication::instance(), SLOT(quit()));
m_socket->connectToServer(QCoreApplication::arguments().at(1), QIODevice::ReadWrite | QIODevice::Unbuffered);
m_socket->waitForConnected(-1);
}
void NodeInstanceClientProxy::writeCommand(const QVariant &command)
{
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
out << quint32(0);
out << quint32(m_writeCommandCounter);
m_writeCommandCounter++;
out << command;
out.device()->seek(0);
out << quint32(block.size() - sizeof(quint32));
m_socket->write(block);
}
void NodeInstanceClientProxy::informationChanged(const InformationChangedCommand &command)
{
writeCommand(QVariant::fromValue(command));
}
void NodeInstanceClientProxy::valuesChanged(const ValuesChangedCommand &command)
{
writeCommand(QVariant::fromValue(command));
}
void NodeInstanceClientProxy::pixmapChanged(const PixmapChangedCommand &command)
{
writeCommand(QVariant::fromValue(command));
}
void NodeInstanceClientProxy::childrenChanged(const ChildrenChangedCommand &command)
{
writeCommand(QVariant::fromValue(command));
}
void NodeInstanceClientProxy::statePreviewImagesChanged(const StatePreviewImageChangedCommand &command)
{
writeCommand(QVariant::fromValue(command));
}
void NodeInstanceClientProxy::componentCompleted(const ComponentCompletedCommand &command)
{
writeCommand(QVariant::fromValue(command));
}
void NodeInstanceClientProxy::token(const TokenCommand &command)
{
writeCommand(QVariant::fromValue(command));
}
void NodeInstanceClientProxy::flush()
{
}
void NodeInstanceClientProxy::synchronizeWithClientProcess()
{
if (m_synchronizeId >= 0) {
SynchronizeCommand synchronizeCommand(m_synchronizeId);
writeCommand(QVariant::fromValue(synchronizeCommand));
}
}
qint64 NodeInstanceClientProxy::bytesToWrite() const
{
return m_socket->bytesToWrite();
}
void NodeInstanceClientProxy::readDataStream()
{
QList<QVariant> commandList;
while (!m_socket->atEnd()) {
if (m_socket->bytesAvailable() < int(sizeof(quint32)))
break;
QDataStream in(m_socket);
if (m_blockSize == 0) {
in >> m_blockSize;
}
if (m_socket->bytesAvailable() < m_blockSize)
break;
quint32 commandCounter;
in >> commandCounter;
bool commandLost = !((m_lastReadCommandCounter == 0 && commandCounter == 0) || (m_lastReadCommandCounter + 1 == commandCounter));
if (commandLost)
qDebug() << "client command lost: " << m_lastReadCommandCounter << commandCounter;
m_lastReadCommandCounter = commandCounter;
QVariant command;
in >> command;
m_blockSize = 0;
if (in.status() != QDataStream::Ok) {
qWarning() << "Stream is no ok!!!";
exit(1);
}
commandList.append(command);
}
foreach (const QVariant &command, commandList) {
dispatchCommand(command);
}
}
NodeInstanceServerInterface *NodeInstanceClientProxy::nodeInstanceServer() const
{
return m_nodeInstanceServer;
}
void NodeInstanceClientProxy::setNodeInstanceServer(NodeInstanceServerInterface *nodeInstanceServer)
{
m_nodeInstanceServer = nodeInstanceServer;
}
void NodeInstanceClientProxy::createInstances(const CreateInstancesCommand &command)
{
nodeInstanceServer()->createInstances(command);
}
void NodeInstanceClientProxy::changeFileUrl(const ChangeFileUrlCommand &command)
{
nodeInstanceServer()->changeFileUrl(command);
}
void NodeInstanceClientProxy::createScene(const CreateSceneCommand &command)
{
nodeInstanceServer()->createScene(command);
}
void NodeInstanceClientProxy::clearScene(const ClearSceneCommand &command)
{
nodeInstanceServer()->clearScene(command);
}
void NodeInstanceClientProxy::removeInstances(const RemoveInstancesCommand &command)
{
nodeInstanceServer()->removeInstances(command);
}
void NodeInstanceClientProxy::removeProperties(const RemovePropertiesCommand &command)
{
nodeInstanceServer()->removeProperties(command);
}
void NodeInstanceClientProxy::changePropertyBindings(const ChangeBindingsCommand &command)
{
nodeInstanceServer()->changePropertyBindings(command);
}
void NodeInstanceClientProxy::changePropertyValues(const ChangeValuesCommand &command)
{
nodeInstanceServer()->changePropertyValues(command);
}
void NodeInstanceClientProxy::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command)
{
nodeInstanceServer()->changeAuxiliaryValues(command);
}
void NodeInstanceClientProxy::reparentInstances(const ReparentInstancesCommand &command)
{
nodeInstanceServer()->reparentInstances(command);
}
void NodeInstanceClientProxy::changeIds(const ChangeIdsCommand &command)
{
nodeInstanceServer()->changeIds(command);
}
void NodeInstanceClientProxy::changeState(const ChangeStateCommand &command)
{
nodeInstanceServer()->changeState(command);
}
void NodeInstanceClientProxy::completeComponent(const CompleteComponentCommand &command)
{
nodeInstanceServer()->completeComponent(command);
}
void NodeInstanceClientProxy::changeNodeSource(const ChangeNodeSourceCommand &command)
{
nodeInstanceServer()->changeNodeSource(command);
}
void NodeInstanceClientProxy::removeSharedMemory(const RemoveSharedMemoryCommand &command)
{
nodeInstanceServer()->removeSharedMemory(command);
}
void NodeInstanceClientProxy::redirectToken(const TokenCommand &command)
{
nodeInstanceServer()->token(command);
}
void NodeInstanceClientProxy::dispatchCommand(const QVariant &command)
{
static const int createInstancesCommandType = QMetaType::type("CreateInstancesCommand");
static const int changeFileUrlCommandType = QMetaType::type("ChangeFileUrlCommand");
static const int createSceneCommandType = QMetaType::type("CreateSceneCommand");
static const int clearSceneCommandType = QMetaType::type("ClearSceneCommand");
static const int removeInstancesCommandType = QMetaType::type("RemoveInstancesCommand");
static const int removePropertiesCommandType = QMetaType::type("RemovePropertiesCommand");
static const int changeBindingsCommandType = QMetaType::type("ChangeBindingsCommand");
static const int changeValuesCommandType = QMetaType::type("ChangeValuesCommand");
static const int changeAuxiliaryCommandType = QMetaType::type("ChangeAuxiliaryCommand");
static const int reparentInstancesCommandType = QMetaType::type("ReparentInstancesCommand");
static const int changeIdsCommandType = QMetaType::type("ChangeIdsCommand");
static const int changeStateCommandType = QMetaType::type("ChangeStateCommand");
static const int completeComponentCommandType = QMetaType::type("CompleteComponentCommand");
static const int synchronizeCommandType = QMetaType::type("SynchronizeCommand");
static const int changeNodeSourceCommandType = QMetaType::type("ChangeNodeSourceCommand");
static const int removeSharedMemoryCommandType = QMetaType::type("RemoveSharedMemoryCommand");
static const int tokenCommandType = QMetaType::type("TokenCommand");
if (command.userType() == createInstancesCommandType) {
createInstances(command.value<CreateInstancesCommand>());
} else if (command.userType() == changeFileUrlCommandType)
changeFileUrl(command.value<ChangeFileUrlCommand>());
else if (command.userType() == createSceneCommandType)
createScene(command.value<CreateSceneCommand>());
else if (command.userType() == clearSceneCommandType)
clearScene(command.value<ClearSceneCommand>());
else if (command.userType() == removeInstancesCommandType)
removeInstances(command.value<RemoveInstancesCommand>());
else if (command.userType() == removePropertiesCommandType)
removeProperties(command.value<RemovePropertiesCommand>());
else if (command.userType() == changeBindingsCommandType)
changePropertyBindings(command.value<ChangeBindingsCommand>());
else if (command.userType() == changeValuesCommandType)
changePropertyValues(command.value<ChangeValuesCommand>());
else if (command.userType() == changeAuxiliaryCommandType)
changeAuxiliaryValues(command.value<ChangeAuxiliaryCommand>());
else if (command.userType() == reparentInstancesCommandType)
reparentInstances(command.value<ReparentInstancesCommand>());
else if (command.userType() == changeIdsCommandType)
changeIds(command.value<ChangeIdsCommand>());
else if (command.userType() == changeStateCommandType)
changeState(command.value<ChangeStateCommand>());
else if (command.userType() == completeComponentCommandType)
completeComponent(command.value<CompleteComponentCommand>());
else if (command.userType() == changeNodeSourceCommandType)
changeNodeSource(command.value<ChangeNodeSourceCommand>());
else if (command.userType() == removeSharedMemoryCommandType)
removeSharedMemory(command.value<RemoveSharedMemoryCommand>());
else if (command.userType() == tokenCommandType)
redirectToken(command.value<TokenCommand>());
else if (command.userType() == synchronizeCommandType) {
SynchronizeCommand synchronizeCommand = command.value<SynchronizeCommand>();
m_synchronizeId = synchronizeCommand.synchronizeId();
} else
Q_ASSERT(false);
}
} // namespace QmlDesigner
@@ -0,0 +1,120 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef NODEINSTANCECLIENTPROXY_H
#define NODEINSTANCECLIENTPROXY_H
#include "nodeinstanceclientinterface.h"
#include <QObject>
#include <QHash>
#include <QWeakPointer>
QT_BEGIN_NAMESPACE
class QLocalSocket;
QT_END_NAMESPACE
namespace QmlDesigner {
class NodeInstanceServerInterface;
class CreateSceneCommand;
class CreateInstancesCommand;
class ClearSceneCommand;
class ReparentInstancesCommand;
class ChangeFileUrlCommand;
class ChangeValuesCommand;
class ChangeAuxiliaryCommand;
class ChangeBindingsCommand;
class ChangeIdsCommand;
class RemoveInstancesCommand;
class RemovePropertiesCommand;
class CompleteComponentCommand;
class ChangeStateCommand;
class ChangeNodeSourceCommand;
class NodeInstanceClientProxy : public QObject, public NodeInstanceClientInterface
{
Q_OBJECT
public:
NodeInstanceClientProxy(QObject *parent = 0);
void informationChanged(const InformationChangedCommand &command);
void valuesChanged(const ValuesChangedCommand &command);
void pixmapChanged(const PixmapChangedCommand &command);
void childrenChanged(const ChildrenChangedCommand &command);
void statePreviewImagesChanged(const StatePreviewImageChangedCommand &command);
void componentCompleted(const ComponentCompletedCommand &command);
void token(const TokenCommand &command);
void flush();
void synchronizeWithClientProcess();
qint64 bytesToWrite() const;
protected:
void initializeSocket();
void writeCommand(const QVariant &command);
void dispatchCommand(const QVariant &command);
NodeInstanceServerInterface *nodeInstanceServer() const;
void setNodeInstanceServer(NodeInstanceServerInterface *nodeInstanceServer);
void createInstances(const CreateInstancesCommand &command);
void changeFileUrl(const ChangeFileUrlCommand &command);
void createScene(const CreateSceneCommand &command);
void clearScene(const ClearSceneCommand &command);
void removeInstances(const RemoveInstancesCommand &command);
void removeProperties(const RemovePropertiesCommand &command);
void changePropertyBindings(const ChangeBindingsCommand &command);
void changePropertyValues(const ChangeValuesCommand &command);
void changeAuxiliaryValues(const ChangeAuxiliaryCommand &command);
void reparentInstances(const ReparentInstancesCommand &command);
void changeIds(const ChangeIdsCommand &command);
void changeState(const ChangeStateCommand &command);
void completeComponent(const CompleteComponentCommand &command);
void changeNodeSource(const ChangeNodeSourceCommand &command);
void removeSharedMemory(const RemoveSharedMemoryCommand &command);
void redirectToken(const TokenCommand &command);
private slots:
void readDataStream();
private:
QLocalSocket *m_socket;
NodeInstanceServerInterface *m_nodeInstanceServer;
quint32 m_blockSize;
quint32 m_writeCommandCounter;
quint32 m_lastReadCommandCounter;
int m_synchronizeId;
};
} // namespace QmlDesigner
#endif // NODEINSTANCECLIENTPROXY_H
@@ -0,0 +1,140 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "nodeinstancemetaobject.h"
#include "objectnodeinstance.h"
#include <QSharedPointer>
#include <QMetaProperty>
#include <qnumeric.h>
#include <QDebug>
namespace QmlDesigner {
namespace Internal {
NodeInstanceMetaObject::NodeInstanceMetaObject(const ObjectNodeInstance::Pointer &nodeInstance, QQmlEngine *engine)
: QQmlOpenMetaObject(nodeInstance->object(), new QQmlOpenMetaObjectType(nodeInstance->object()->metaObject(), engine), true),
m_nodeInstance(nodeInstance),
m_context(nodeInstance->isRootNodeInstance() ? nodeInstance->context() : 0)
{
setCached(true);
}
NodeInstanceMetaObject::NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const QString &prefix, QQmlEngine *engine)
: QQmlOpenMetaObject(object, new QQmlOpenMetaObjectType(object->metaObject(), engine), true),
m_nodeInstance(nodeInstance),
m_prefix(prefix)
{
setCached(true);
}
void NodeInstanceMetaObject::createNewProperty(const QString &name)
{
int id = createProperty(name.toLatin1(), 0);
setValue(id, QVariant());
Q_ASSERT(id >= 0);
Q_UNUSED(id)
}
int NodeInstanceMetaObject::metaCall(QMetaObject::Call call, int id, void **a)
{
int metaCallReturnValue = -1;
if (call == QMetaObject::WriteProperty
&& property(id).userType() == QMetaType::QVariant
&& reinterpret_cast<QVariant *>(a[0])->type() == QVariant::Double
&& qIsNaN(reinterpret_cast<QVariant *>(a[0])->toDouble())) {
return -1;
}
if (call == QMetaObject::WriteProperty
&& property(id).userType() == QMetaType::Double
&& qIsNaN(*reinterpret_cast<double*>(a[0]))) {
return -1;
}
if (call == QMetaObject::WriteProperty
&& property(id).userType() == QMetaType::Float
&& qIsNaN(*reinterpret_cast<float*>(a[0]))) {
return -1;
}
QVariant oldValue;
if (call == QMetaObject::WriteProperty && !property(id).hasNotifySignal())
{
oldValue = property(id).read(object());
}
ObjectNodeInstance::Pointer objectNodeInstance = m_nodeInstance.toStrongRef();
if (parent() && id < parent()->propertyOffset()) {
metaCallReturnValue = parent()->metaCall(call, id, a);
} else {
metaCallReturnValue = QQmlOpenMetaObject::metaCall(call, id, a);
}
if ((call == QMetaObject::WriteProperty || call == QMetaObject::ReadProperty) && metaCallReturnValue < 0) {
if (objectNodeInstance
&& objectNodeInstance->nodeInstanceServer()
&& objectNodeInstance->nodeInstanceServer()->dummyContextObject()
&& !(objectNodeInstance && !objectNodeInstance->isRootNodeInstance() && property(id).name() == QLatin1String("parent"))) {
QObject *contextDummyObject = objectNodeInstance->nodeInstanceServer()->dummyContextObject();
int properyIndex = contextDummyObject->metaObject()->indexOfProperty(property(id).name());
if (properyIndex >= 0)
metaCallReturnValue = contextDummyObject->qt_metacall(call, properyIndex, a);
}
}
if (metaCallReturnValue >= 0
&& call == QMetaObject::WriteProperty
&& !property(id).hasNotifySignal()
&& oldValue != property(id).read(object()))
notifyPropertyChange(id);
return metaCallReturnValue;
}
void NodeInstanceMetaObject::notifyPropertyChange(int id)
{
ObjectNodeInstance::Pointer objectNodeInstance = m_nodeInstance.toStrongRef();
if (objectNodeInstance && objectNodeInstance->nodeInstanceServer()) {
if (id < type()->propertyOffset()) {
objectNodeInstance->nodeInstanceServer()->notifyPropertyChange(objectNodeInstance->instanceId(), m_prefix + property(id).name());
} else {
objectNodeInstance->nodeInstanceServer()->notifyPropertyChange(objectNodeInstance->instanceId(), m_prefix + name(id - type()->propertyOffset()));
}
}
}
} // namespace Internal
} // namespace QmlDesigner
@@ -0,0 +1,64 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef NODEINSTANCEMETAOBJECT_H
#define NODEINSTANCEMETAOBJECT_H
#include <QQmlContext>
#include <private/qqmlopenmetaobject_p.h>
namespace QmlDesigner {
namespace Internal {
class ObjectNodeInstance;
typedef QSharedPointer<ObjectNodeInstance> ObjectNodeInstancePointer;
typedef QWeakPointer<ObjectNodeInstance> ObjectNodeInstanceWeakPointer;
class NodeInstanceMetaObject : public QQmlOpenMetaObject
{
public:
NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QQmlEngine *engine);
NodeInstanceMetaObject(const ObjectNodeInstancePointer &nodeInstance, QObject *object, const QString &prefix, QQmlEngine *engine);
void createNewProperty(const QString &name);
protected:
int metaCall(QMetaObject::Call _c, int _id, void **_a);
void notifyPropertyChange(int id);
private:
ObjectNodeInstanceWeakPointer m_nodeInstance;
QString m_prefix;
QWeakPointer<QQmlContext> m_context;
};
} // namespace Internal
} // namespace QmlDesigner
#endif // NODEINSTANCEMETAOBJECT_H
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,228 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef NODEINSTANCESERVER_H
#define NODEINSTANCESERVER_H
#include <QUrl>
#include <QVector>
#include <QSet>
#include <QStringList>
#include <nodeinstanceserverinterface.h>
#include "servernodeinstance.h"
QT_BEGIN_NAMESPACE
class QFileSystemWatcher;
class QQmlView;
class QQuickView;
class QQmlEngine;
class QGraphicsObject;
class QFileInfo;
class QQmlComponent;
QT_END_NAMESPACE
namespace QmlDesigner {
class NodeInstanceClientInterface;
class ValuesChangedCommand;
class PixmapChangedCommand;
class InformationChangedCommand;
class ChildrenChangedCommand;
class ReparentContainer;
class ComponentCompletedCommand;
class AddImportContainer;
namespace Internal {
class ChildrenChangeEventFilter;
}
class NodeInstanceServer : public NodeInstanceServerInterface
{
Q_OBJECT
public:
typedef QPair<QWeakPointer<QObject>, QString> ObjectPropertyPair;
typedef QPair<qint32, QString> IdPropertyPair;
typedef QPair<ServerNodeInstance, QString> InstancePropertyPair;
typedef QPair<QString, QWeakPointer<QObject> > DummyPair;
explicit NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient);
~NodeInstanceServer();
void createInstances(const CreateInstancesCommand &command);
void changeFileUrl(const ChangeFileUrlCommand &command);
void changePropertyValues(const ChangeValuesCommand &command);
void changePropertyBindings(const ChangeBindingsCommand &command);
void changeAuxiliaryValues(const ChangeAuxiliaryCommand &command);
void changeIds(const ChangeIdsCommand &command);
void createScene(const CreateSceneCommand &command);
void clearScene(const ClearSceneCommand &command);
void removeInstances(const RemoveInstancesCommand &command);
void removeProperties(const RemovePropertiesCommand &command);
void reparentInstances(const ReparentInstancesCommand &command);
void changeState(const ChangeStateCommand &command);
void completeComponent(const CompleteComponentCommand &command);
void changeNodeSource(const ChangeNodeSourceCommand &command);
void token(const TokenCommand &command);
void removeSharedMemory(const RemoveSharedMemoryCommand &command);
ServerNodeInstance instanceForId(qint32 id) const;
bool hasInstanceForId(qint32 id) const;
ServerNodeInstance instanceForObject(QObject *object) const;
bool hasInstanceForObject(QObject *object) const;
virtual QQmlEngine *engine() const = 0;
QQmlContext *context() const;
void removeAllInstanceRelationships();
QFileSystemWatcher *fileSystemWatcher();
QFileSystemWatcher *dummydataFileSystemWatcher();
Internal::ChildrenChangeEventFilter *childrenChangeEventFilter() const;
void addFilePropertyToFileSystemWatcher(QObject *object, const QString &propertyName, const QString &path);
void removeFilePropertyFromFileSystemWatcher(QObject *object, const QString &propertyName, const QString &path);
QUrl fileUrl() const;
ServerNodeInstance activeStateInstance() const;
void setStateInstance(const ServerNodeInstance &stateInstance);
void clearStateInstance();
ServerNodeInstance rootNodeInstance() const;
void notifyPropertyChange(qint32 instanceid, const QString &propertyName);
QStringList imports() const;
QObject *dummyContextObject() const;
virtual QQmlView *declarativeView() const = 0;
virtual QQuickView *quickView() const = 0;
public slots:
void refreshLocalFileProperty(const QString &path);
void refreshDummyData(const QString &path);
void emitParentChanged(QObject *child);
protected:
QList<ServerNodeInstance> createInstances(const QVector<InstanceContainer> &container);
void reparentInstances(const QVector<ReparentContainer> &containerVector);
void addImportString(const QString &import);
Internal::ChildrenChangeEventFilter *childrenChangeEventFilter();
void resetInstanceProperty(const PropertyAbstractContainer &propertyContainer);
void setInstancePropertyBinding(const PropertyBindingContainer &bindingContainer);
void setInstancePropertyVariant(const PropertyValueContainer &valueContainer);
void setInstanceAuxiliaryData(const PropertyValueContainer &auxiliaryContainer);
void removeProperties(const QList<PropertyAbstractContainer> &propertyList);
void insertInstanceRelationship(const ServerNodeInstance &instance);
void removeInstanceRelationsip(qint32 instanceId);
NodeInstanceClientInterface *nodeInstanceClient() const;
void timerEvent(QTimerEvent *);
virtual void collectItemChangesAndSendChangeCommands() = 0;
ValuesChangedCommand createValuesChangedCommand(const QList<ServerNodeInstance> &instanceList) const;
ValuesChangedCommand createValuesChangedCommand(const QVector<InstancePropertyPair> &propertyList) const;
PixmapChangedCommand createPixmapChangedCommand(const QList<ServerNodeInstance> &instanceList) const;
InformationChangedCommand createAllInformationChangedCommand(const QList<ServerNodeInstance> &instanceList, bool initial = false) const;
ChildrenChangedCommand createChildrenChangedCommand(const ServerNodeInstance &parentInstance, const QList<ServerNodeInstance> &instanceList) const;
ComponentCompletedCommand createComponentCompletedCommand(const QList<ServerNodeInstance> &instanceList);
void addChangedProperty(const InstancePropertyPair &property);
virtual void startRenderTimer();
void slowDownRenderTimer();
void stopRenderTimer();
void setRenderTimerInterval(int timerInterval);
int renderTimerInterval() const;
void setSlowRenderTimerInterval(int timerInterval);
virtual void initializeView(const QVector<AddImportContainer> &importVector) = 0;
virtual QList<ServerNodeInstance> setupScene(const CreateSceneCommand &command) = 0;
void loadDummyDataFiles(const QString& directory);
void loadDummyDataContext(const QString& directory);
void loadDummyDataFile(const QFileInfo& fileInfo);
void loadDummyContextObjectFile(const QFileInfo& fileInfo);
static QStringList dummyDataDirectories(const QString& directoryPath);
void setTimerId(int timerId);
int timerId() const;
QQmlContext *rootContext() const;
const QVector<InstancePropertyPair> changedPropertyList() const;
void clearChangedPropertyList();
virtual void refreshBindings() = 0;
void setupDummysForContext(QQmlContext *context);
void setupFileUrl(const QUrl &fileUrl);
void setupImports(const QVector<AddImportContainer> &container);
void setupDummyData(const QUrl &fileUrl);
void setupDefaultDummyData();
QList<ServerNodeInstance> setupInstances(const CreateSceneCommand &command);
QList<QQmlContext*> allSubContextsForObject(QObject *object);
static QList<QObject*> allSubObjectsForObject(QObject *object);
virtual void resizeCanvasSizeToRootItemSize() = 0;
private:
ServerNodeInstance m_rootNodeInstance;
ServerNodeInstance m_activeStateInstance;
QHash<qint32, ServerNodeInstance> m_idInstanceHash;
QHash<QObject*, ServerNodeInstance> m_objectInstanceHash;
QMultiHash<QString, ObjectPropertyPair> m_fileSystemWatcherHash;
QList<QPair<QString, QWeakPointer<QObject> > > m_dummyObjectList;
QWeakPointer<QFileSystemWatcher> m_fileSystemWatcher;
QWeakPointer<QFileSystemWatcher> m_dummdataFileSystemWatcher;
QWeakPointer<Internal::ChildrenChangeEventFilter> m_childrenChangeEventFilter;
QUrl m_fileUrl;
NodeInstanceClientInterface *m_nodeInstanceClient;
int m_timer;
int m_renderTimerInterval;
bool m_slowRenderTimer;
int m_slowRenderTimerInterval;
QVector<InstancePropertyPair> m_changedPropertyList;
QStringList m_importList;
QWeakPointer<QObject> m_dummyContextObject;
QWeakPointer<QQmlComponent> m_importComponent;
QWeakPointer<QObject> m_importComponentObject;
};
}
#endif // NODEINSTANCESERVER_H
@@ -0,0 +1,125 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "nodeinstancesignalspy.h"
#include "objectnodeinstance.h"
#include <QMetaProperty>
#include <QMetaObject>
#include <QDebug>
#include <QSharedPointer>
#include <private/qqmlmetatype_p.h>
namespace QmlDesigner {
namespace Internal {
NodeInstanceSignalSpy::NodeInstanceSignalSpy() :
QObject()
{
blockSignals(true);
}
void NodeInstanceSignalSpy::setObjectNodeInstance(const ObjectNodeInstance::Pointer &nodeInstance)
{
methodeOffset = QObject::staticMetaObject.methodCount() + 1;
registerObject(nodeInstance->object());
m_objectNodeInstance = nodeInstance;
}
void NodeInstanceSignalSpy::registerObject(QObject *spiedObject, const QString &prefix)
{
if (m_registeredObjectList.contains(spiedObject)) // prevent cycles
return;
m_registeredObjectList.append(spiedObject);
for (int index = QObject::staticMetaObject.propertyOffset();
index < spiedObject->metaObject()->propertyCount();
index++) {
QMetaProperty metaProperty = spiedObject->metaObject()->property(index);
// handle dot properties and connect the signals to the object
if (metaProperty.isReadable()
&& !metaProperty.isWritable()
&& QQmlMetaType::isQObject(metaProperty.userType())) {
QObject *propertyObject = QQmlMetaType::toQObject(metaProperty.read(spiedObject));
if (propertyObject)
registerObject(propertyObject, prefix + metaProperty.name() + QLatin1Char('.'));
} else if (metaProperty.hasNotifySignal()) {
QMetaMethod metaMethod = metaProperty.notifySignal();
bool isConnecting = QMetaObject::connect(spiedObject, metaMethod.methodIndex(), this, methodeOffset, Qt::DirectConnection);
Q_ASSERT(isConnecting);
Q_UNUSED(isConnecting);
m_indexPropertyHash.insert(methodeOffset, prefix + metaProperty.name());
methodeOffset++;
}
// search recursive in objects
if (metaProperty.isReadable()
&& metaProperty.isWritable()
&& QQmlMetaType::isQObject(metaProperty.userType())) {
QObject *propertyObject = QQmlMetaType::toQObject(metaProperty.read(spiedObject));
if (propertyObject)
registerObject(propertyObject, prefix + metaProperty.name() + QLatin1Char('/'));
}
// search recursive in objects list
if (metaProperty.isReadable()
&& QQmlMetaType::isList(metaProperty.userType())) {
QQmlListReference list(spiedObject, metaProperty.name());
if (list.canCount() && list.canAt()) {
for (int i = 0; i < list.count(); i++) {
QObject *propertyObject = list.at(i);
if (propertyObject)
registerObject(propertyObject, prefix + metaProperty.name() + QLatin1Char('/'));
}
}
}
}
}
int NodeInstanceSignalSpy::qt_metacall(QMetaObject::Call call, int methodId, void **a)
{
if (call == QMetaObject::InvokeMetaMethod && methodId > QObject::staticMetaObject.methodCount()) {
ObjectNodeInstance::Pointer nodeInstance = m_objectNodeInstance.toStrongRef();
if (nodeInstance && nodeInstance->nodeInstanceServer() && nodeInstance->isValid()) {
nodeInstance->nodeInstanceServer()->notifyPropertyChange(nodeInstance->instanceId(), m_indexPropertyHash.value(methodId));
}
}
return QObject::qt_metacall(call, methodId, a);
}
} // namespace Internal
} // namespace QmlDesigner
@@ -0,0 +1,67 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef NODEINSTANCESIGNALSPY_H
#define NODEINSTANCESIGNALSPY_H
#include <QObject>
#include <QHash>
#include <QSharedPointer>
namespace QmlDesigner {
namespace Internal {
class ObjectNodeInstance;
typedef QSharedPointer<ObjectNodeInstance> ObjectNodeInstancePointer;
typedef QWeakPointer<ObjectNodeInstance> ObjectNodeInstanceWeakPointer;
class NodeInstanceSignalSpy : public QObject
{
public:
explicit NodeInstanceSignalSpy();
void setObjectNodeInstance(const ObjectNodeInstancePointer &nodeInstance);
virtual int qt_metacall(QMetaObject::Call, int, void **);
protected:
void registerObject(QObject *spiedObject, const QString &prefix = QString());
private:
int methodeOffset;
QHash<int, QString> m_indexPropertyHash;
QObjectList m_registeredObjectList;
ObjectNodeInstanceWeakPointer m_objectNodeInstance;
};
} // namespace Internal
} // namespace QmlDesigner
#endif // NODEINSTANCESIGNALSPY_H
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,212 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef ABSTRACTNODEINSTANCE_H
#define ABSTRACTNODEINSTANCE_H
#include "nodeinstanceserver.h"
#include "nodeinstancemetaobject.h"
#include "nodeinstancesignalspy.h"
#include <QPainter>
#include <QSharedPointer>
#include <QWeakPointer>
QT_BEGIN_NAMESPACE
class QGraphicsItem;
class QQmlContext;
class QQmlEngine;
class QQmlProperty;
class QQmlAbstractBinding;
QT_END_NAMESPACE
namespace QmlDesigner {
class NodeInstanceServer;
namespace Internal {
class QmlGraphicsItemNodeInstance;
class GraphicsWidgetNodeInstance;
class GraphicsViewNodeInstance;
class GraphicsSceneNodeInstance;
class ProxyWidgetNodeInstance;
class WidgetNodeInstance;
class ObjectNodeInstance
{
public:
typedef QSharedPointer<ObjectNodeInstance> Pointer;
typedef QWeakPointer<ObjectNodeInstance> WeakPointer;
explicit ObjectNodeInstance(QObject *object);
virtual ~ObjectNodeInstance();
void destroy();
//void setModelNode(const ModelNode &node);
static Pointer create(QObject *objectToBeWrapped);
static QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context);
static QObject *createCustomParserObject(const QString &nodeSource, const QStringList &imports, QQmlContext *context);
static QObject *createComponent(const QString &componentPath, QQmlContext *context);
static QObject *createComponentWrap(const QString &nodeSource, const QStringList &imports, QQmlContext *context);
void setInstanceId(qint32 id);
qint32 instanceId() const;
NodeInstanceServer *nodeInstanceServer() const;
void setNodeInstanceServer(NodeInstanceServer *server);
virtual void initializePropertyWatcher(const Pointer &objectNodeInstance);
virtual void initialize(const Pointer &objectNodeInstance);
virtual void paint(QPainter *painter);
virtual QImage renderImage() const;
virtual QObject *parent() const;
Pointer parentInstance() const;
virtual void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const QString &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const QString &newParentProperty);
virtual void setId(const QString &id);
virtual QString id() const;
virtual bool isQmlGraphicsItem() const;
virtual bool isGraphicsObject() const;
virtual bool isTransition() const;
virtual bool isPositioner() const;
virtual bool isSGItem() const;
virtual bool equalGraphicsItem(QGraphicsItem *item) const;
virtual QRectF boundingRect() const;
virtual QPointF position() const;
virtual QSizeF size() const;
virtual QTransform transform() const;
virtual QTransform customTransform() const;
virtual QTransform sceneTransform() const;
virtual double opacity() const;
virtual int penWidth() const;
virtual bool hasAnchor(const QString &name) const;
virtual QPair<QString, ServerNodeInstance> anchor(const QString &name) const;
virtual bool isAnchoredBySibling() const;
virtual bool isAnchoredByChildren() const;
virtual double rotation() const;
virtual double scale() const;
virtual QList<QGraphicsTransform *> transformations() const;
virtual QPointF transformOriginPoint() const;
virtual double zValue() const;
virtual void setPropertyVariant(const QString &name, const QVariant &value);
virtual void setPropertyBinding(const QString &name, const QString &expression);
virtual QVariant property(const QString &name) const;
virtual void resetProperty(const QString &name);
virtual void refreshProperty(const QString &name);
virtual QString instanceType(const QString &name) const;
QStringList propertyNames() const;
virtual QList<ServerNodeInstance> childItems() const;
void createDynamicProperty(const QString &name, const QString &typeName);
void setDeleteHeldInstance(bool deleteInstance);
bool deleteHeldInstance() const;
virtual void updateAnchors();
virtual void paintUpdate();
virtual void activateState();
virtual void deactivateState();
void populateResetHashes();
bool hasValidResetBinding(const QString &propertyName) const;
QQmlAbstractBinding *resetBinding(const QString &propertyName) const;
QVariant resetValue(const QString &propertyName) const;
void setResetValue(const QString &propertyName, const QVariant &value);
QObject *object() const;
virtual bool hasContent() const;
virtual bool isResizable() const;
virtual bool isMovable() const;
bool isInPositioner() const;
void setInPositioner(bool isInPositioner);
virtual void refreshPositioner();
bool hasBindingForProperty(const QString &name, bool *hasChanged = 0) const;
QQmlContext *context() const;
QQmlEngine *engine() const;
virtual bool updateStateVariant(const ObjectNodeInstance::Pointer &target, const QString &propertyName, const QVariant &value);
virtual bool updateStateBinding(const ObjectNodeInstance::Pointer &target, const QString &propertyName, const QString &expression);
virtual bool resetStateProperty(const ObjectNodeInstance::Pointer &target, const QString &propertyName, const QVariant &resetValue);
bool isValid() const;
bool isRootNodeInstance() const;
virtual void doComponentComplete();
virtual QList<ServerNodeInstance> stateInstances() const;
virtual void setNodeSource(const QString &source);
static QVariant fixResourcePaths(const QVariant &value);
protected:
void doResetProperty(const QString &propertyName);
void removeFromOldProperty(QObject *object, QObject *oldParent, const QString &oldParentProperty);
void addToNewProperty(QObject *object, QObject *newParent, const QString &newParentProperty);
void deleteObjectsInList(const QQmlProperty &metaProperty);
QVariant convertSpecialCharacter(const QVariant& value) const;
private:
QHash<QString, QVariant> m_resetValueHash;
QHash<QString, QWeakPointer<QQmlAbstractBinding> > m_resetBindingHash;
QHash<QString, ServerNodeInstance> m_modelAbstractPropertyHash;
mutable QHash<QString, bool> m_hasBindingHash;
qint32 m_instanceId;
QString m_id;
QWeakPointer<NodeInstanceServer> m_nodeInstanceServer;
QString m_parentProperty;
bool m_deleteHeldInstance;
QWeakPointer<QObject> m_object;
NodeInstanceMetaObject *m_metaObject;
NodeInstanceSignalSpy m_signalSpy;
bool m_isInPositioner;
};
} // namespace Internal
} // namespace QmlDesigner
#endif // ABSTRACTNODEINSTANCE_H
@@ -0,0 +1,119 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "qmlpropertychangesnodeinstance.h"
#include "qmlstatenodeinstance.h"
#include <QQmlEngine>
#include <QQmlContext>
#include <QQmlExpression>
#include <private/qqmlbinding_p.h>
#include <QMutableListIterator>
#include <private/qquickstate_p_p.h>
#include <private/qquickpropertychanges_p.h>
#include <private/qqmlproperty_p.h>
namespace QmlDesigner {
namespace Internal {
QmlPropertyChangesNodeInstance::QmlPropertyChangesNodeInstance(QQuickPropertyChanges *propertyChangesObject) :
ObjectNodeInstance(propertyChangesObject)
{
}
QmlPropertyChangesNodeInstance::Pointer QmlPropertyChangesNodeInstance::create(QObject *object)
{
QQuickPropertyChanges *propertyChange = qobject_cast<QQuickPropertyChanges*>(object);
Q_ASSERT(propertyChange);
Pointer instance(new QmlPropertyChangesNodeInstance(propertyChange));
instance->populateResetHashes();
return instance;
}
void QmlPropertyChangesNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)
{
QMetaObject metaObject = QQuickPropertyChanges::staticMetaObject;
if (metaObject.indexOfProperty(name.toLatin1()) > 0) { // 'restoreEntryValues', 'explicit'
ObjectNodeInstance::setPropertyVariant(name, value);
} else {
changesObject()->changeValue(name.toLatin1(), value);
QObject *targetObject = changesObject()->object();
if (targetObject && nodeInstanceServer()->activeStateInstance().isWrappingThisObject(changesObject()->state())) {
ServerNodeInstance targetInstance = nodeInstanceServer()->instanceForObject(targetObject);
targetInstance.setPropertyVariant(name, value);
}
}
}
void QmlPropertyChangesNodeInstance::setPropertyBinding(const QString &name, const QString &expression)
{
QMetaObject metaObject = QQuickPropertyChanges::staticMetaObject;
if (metaObject.indexOfProperty(name.toLatin1()) > 0) { // 'restoreEntryValues', 'explicit'
ObjectNodeInstance::setPropertyBinding(name, expression);
} else {
changesObject()->changeExpression(name.toLatin1(), expression);
}
}
QVariant QmlPropertyChangesNodeInstance::property(const QString &name) const
{
return changesObject()->property(name.toLatin1());
}
void QmlPropertyChangesNodeInstance::resetProperty(const QString &name)
{
changesObject()->removeProperty(name.toLatin1());
}
void QmlPropertyChangesNodeInstance::reparent(const ServerNodeInstance &oldParentInstance, const QString &oldParentProperty, const ServerNodeInstance &newParentInstance, const QString &newParentProperty)
{
changesObject()->detachFromState();
ObjectNodeInstance::reparent(oldParentInstance.internalInstance(), oldParentProperty, newParentInstance.internalInstance(), newParentProperty);
changesObject()->attachToState();
}
QQuickPropertyChanges *QmlPropertyChangesNodeInstance::changesObject() const
{
Q_ASSERT(qobject_cast<QQuickPropertyChanges*>(object()));
return static_cast<QQuickPropertyChanges*>(object());
}
} // namespace Internal
} // namespace QmlDesigner
@@ -0,0 +1,77 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef QMLPROPERTYCHANGESNODEINSTANCE_H
#define QMLPROPERTYCHANGESNODEINSTANCE_H
#include "objectnodeinstance.h"
#include <private/qquickstateoperations_p.h>
#include <private/qquickpropertychanges_p.h>
#include <QPair>
#include <QWeakPointer>
QT_BEGIN_NAMESPACE
class QQuickProperty;
QT_END_NAMESPACE
namespace QmlDesigner {
namespace Internal {
class QmlPropertyChangesNodeInstance;
class QmlPropertyChangesNodeInstance : public ObjectNodeInstance
{
public:
typedef QSharedPointer<QmlPropertyChangesNodeInstance> Pointer;
typedef QWeakPointer<QmlPropertyChangesNodeInstance> WeakPointer;
static Pointer create(QObject *objectToBeWrapped);
virtual void setPropertyVariant(const QString &name, const QVariant &value);
virtual void setPropertyBinding(const QString &name, const QString &expression);
virtual QVariant property(const QString &name) const;
virtual void resetProperty(const QString &name);
using ObjectNodeInstance::reparent; // keep the virtual reparent(...) method around
void reparent(const ServerNodeInstance &oldParentInstance, const QString &oldParentProperty, const ServerNodeInstance &newParentInstance, const QString &newParentProperty);
protected:
QmlPropertyChangesNodeInstance(QQuickPropertyChanges *object);
QQuickPropertyChanges *changesObject() const;
};
} // namespace Internal
} // namespace QmlDesigner
//QML_DECLARE_TYPE(QmlDesigner::Internal::QmlPropertyChangesObject)
#endif // QMLPROPERTYCHANGESNODEINSTANCE_H
@@ -0,0 +1,139 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "qmlstatenodeinstance.h"
#include <private/qquickstategroup_p.h>
#include "qmlpropertychangesnodeinstance.h"
#include <private/qquickstateoperations_p.h>
namespace QmlDesigner {
namespace Internal {
/**
\class QmlStateNodeInstance
QmlStateNodeInstance manages a QQuickState object.
*/
QmlStateNodeInstance::QmlStateNodeInstance(QQuickState *object) :
ObjectNodeInstance(object)
{
}
QmlStateNodeInstance::Pointer
QmlStateNodeInstance::create(QObject *object)
{
QQuickState *stateObject = qobject_cast<QQuickState*>(object);
Q_ASSERT(stateObject);
Pointer instance(new QmlStateNodeInstance(stateObject));
instance->populateResetHashes();
return instance;
}
void QmlStateNodeInstance::activateState()
{
if (stateGroup()) {
if (!isStateActive()) {
nodeInstanceServer()->setStateInstance(nodeInstanceServer()->instanceForObject(object()));
stateGroup()->setState(property("name").toString());
}
}
}
void QmlStateNodeInstance::deactivateState()
{
if (stateGroup()) {
if (isStateActive()) {
nodeInstanceServer()->clearStateInstance();
stateGroup()->setState(QString());
}
}
}
QQuickState *QmlStateNodeInstance::stateObject() const
{
Q_ASSERT(object());
Q_ASSERT(qobject_cast<QQuickState*>(object()));
return static_cast<QQuickState*>(object());
}
QQuickStateGroup *QmlStateNodeInstance::stateGroup() const
{
return stateObject()->stateGroup();
}
bool QmlStateNodeInstance::isStateActive() const
{
return stateObject() && stateGroup() && stateGroup()->state() == property("name");
}
void QmlStateNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)
{
bool hasParent = parent();
bool isStateOfTheRootModelNode = parentInstance() && parentInstance()->isRootNodeInstance();
if (name == "when" && (!hasParent || isStateOfTheRootModelNode))
return;
ObjectNodeInstance::setPropertyVariant(name, value);
}
void QmlStateNodeInstance::setPropertyBinding(const QString &name, const QString &expression)
{
bool hasParent = parent();
bool isStateOfTheRootModelNode = parentInstance() && parentInstance()->isRootNodeInstance();
if (name == "when" && (!hasParent || isStateOfTheRootModelNode))
return;
ObjectNodeInstance::setPropertyBinding(name, expression);
}
bool QmlStateNodeInstance::updateStateVariant(const ObjectNodeInstance::Pointer &target, const QString &propertyName, const QVariant &value)
{
return stateObject()->changeValueInRevertList(target->object(), propertyName.toLatin1(), value);
}
bool QmlStateNodeInstance::updateStateBinding(const ObjectNodeInstance::Pointer &target, const QString &propertyName, const QString &expression)
{
return stateObject()->changeValueInRevertList(target->object(), propertyName.toLatin1(), expression);
}
bool QmlStateNodeInstance::resetStateProperty(const ObjectNodeInstance::Pointer &target, const QString &propertyName, const QVariant & /* resetValue */)
{
return stateObject()->removeEntryFromRevertList(target->object(), propertyName.toLatin1());
}
} // namespace Internal
} // namespace QmlDesigner
@@ -0,0 +1,77 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef QMLSTATENODEINSTANCE_H
#define QMLSTATENODEINSTANCE_H
#include "objectnodeinstance.h"
QT_BEGIN_NAMESPACE
class QQuickState;
class QQuickStateGroup;
QT_END_NAMESPACE
namespace QmlDesigner {
namespace Internal {
class QmlStateNodeInstance : public ObjectNodeInstance
{
public:
typedef QSharedPointer<QmlStateNodeInstance> Pointer;
typedef QWeakPointer<QmlStateNodeInstance> WeakPointer;
static Pointer create(QObject *objectToBeWrapped);
void setPropertyVariant(const QString &name, const QVariant &value);
void setPropertyBinding(const QString &name, const QString &expression);
void activateState();
void deactivateState();
bool updateStateVariant(const ObjectNodeInstance::Pointer &target, const QString &propertyName, const QVariant &value);
bool updateStateBinding(const ObjectNodeInstance::Pointer &target, const QString &propertyName, const QString &expression);
bool resetStateProperty(const ObjectNodeInstance::Pointer &target, const QString &propertyName, const QVariant &resetValue);
protected:
QmlStateNodeInstance(QQuickState *object);
bool isStateActive() const;
QQuickState *stateObject() const;
QQuickStateGroup *stateGroup() const;
};
} // namespace Internal
} // namespace QmlDesigner
#endif // QMLSTATENODEINSTANCE_H
@@ -0,0 +1,77 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "qmltransitionnodeinstance.h"
#include <private/qquicktransition_p.h>
namespace QmlDesigner {
namespace Internal {
QmlTransitionNodeInstance::QmlTransitionNodeInstance(QQuickTransition *transition)
: ObjectNodeInstance(transition)
{
}
QmlTransitionNodeInstance::Pointer QmlTransitionNodeInstance::create(QObject *object)
{
QQuickTransition *transition = qobject_cast<QQuickTransition*>(object);
Q_ASSERT(transition);
Pointer instance(new QmlTransitionNodeInstance(transition));
instance->populateResetHashes();
transition->setToState("invalidState");
transition->setFromState("invalidState");
return instance;
}
bool QmlTransitionNodeInstance::isTransition() const
{
return true;
}
void QmlTransitionNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)
{
if (name == "from" || name == "to")
return;
ObjectNodeInstance::setPropertyVariant(name, value);
}
QQuickTransition *QmlTransitionNodeInstance::qmlTransition() const
{
Q_ASSERT(qobject_cast<QQuickTransition*>(object()));
return static_cast<QQuickTransition*>(object());
}
}
}
@@ -0,0 +1,63 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef QMLTRANSITIONNODEINSTANCE_H
#define QMLTRANSITIONNODEINSTANCE_H
#include "objectnodeinstance.h"
QT_BEGIN_NAMESPACE
class QQuickTransition;
QT_END_NAMESPACE
namespace QmlDesigner {
namespace Internal {
class QmlTransitionNodeInstance : public ObjectNodeInstance
{
public:
typedef QSharedPointer<QmlTransitionNodeInstance> Pointer;
typedef QWeakPointer<QmlTransitionNodeInstance> WeakPointer;
static Pointer create(QObject *objectToBeWrapped);
void setPropertyVariant(const QString &name, const QVariant &value);
bool isTransition() const;
protected:
QQuickTransition *qmlTransition() const;
private:
QmlTransitionNodeInstance(QQuickTransition *transition);
};
}
}
#endif // QMLTRANSITIONNODEINSTANCE_H
@@ -30,7 +30,7 @@
#include "qt5informationnodeinstanceserver.h"
#include <QSGItem>
#include <QQuickItem>
#include "servernodeinstance.h"
#include "childrenchangeeventfilter.h"
@@ -59,6 +59,7 @@
#include "componentcompletedcommand.h"
#include "createscenecommand.h"
#include "tokencommand.h"
#include "removesharedmemorycommand.h"
#include "dummycontextobject.h"
@@ -95,8 +96,8 @@ void Qt5InformationNodeInstanceServer::collectItemChangesAndSendChangeCommands()
QVector<InstancePropertyPair> propertyChangedList;
bool adjustSceneRect = false;
if (sgView()) {
foreach (QSGItem *item, allItems()) {
if (quickView()) {
foreach (QQuickItem *item, allItems()) {
if (item && hasInstanceForObject(item)) {
ServerNodeInstance instance = instanceForObject(item);
@@ -31,8 +31,8 @@
#include "qt5nodeinstanceserver.h"
#include <QSGItem>
#include <QSGView>
#include <QQuickItem>
#include <QQuickView>
#include <designersupport.h>
#include <addimportcontainer.h>
@@ -49,40 +49,32 @@ Qt5NodeInstanceServer::Qt5NodeInstanceServer(NodeInstanceClientInterface *nodeIn
Qt5NodeInstanceServer::~Qt5NodeInstanceServer()
{
delete sgView();
delete quickView();
delete m_designerSupport;
m_designerSupport = 0;
}
QSGView *Qt5NodeInstanceServer::sgView() const
QQuickView *Qt5NodeInstanceServer::quickView() const
{
return m_sgView.data();
return m_quickView.data();
}
void Qt5NodeInstanceServer::initializeView(const QVector<AddImportContainer> &/*importVector*/)
{
Q_ASSERT(!sgView());
Q_ASSERT(!quickView());
m_sgView = new QSGView;
#ifndef Q_OS_MAC
sgView()->setAttribute(Qt::WA_DontShowOnScreen, true);
#endif
sgView()->show();
#ifdef Q_OS_MAC
sgView()->setAttribute(Qt::WA_DontShowOnScreen, true);
#endif
sgView()->setUpdatesEnabled(false);
m_quickView = new QQuickView;
}
QDeclarativeView *Qt5NodeInstanceServer::declarativeView() const
QQmlView *Qt5NodeInstanceServer::declarativeView() const
{
return 0;
}
QDeclarativeEngine *Qt5NodeInstanceServer::engine() const
QQmlEngine *Qt5NodeInstanceServer::engine() const
{
if (sgView())
return sgView()->engine();
if (quickView())
return quickView()->engine();
return 0;
}
@@ -93,7 +85,7 @@ void Qt5NodeInstanceServer::resizeCanvasSizeToRootItemSize()
void Qt5NodeInstanceServer::resetAllItems()
{
foreach (QSGItem *item, allItems())
foreach (QQuickItem *item, allItems())
DesignerSupport::resetDirty(item);
}
@@ -105,29 +97,29 @@ QList<ServerNodeInstance> Qt5NodeInstanceServer::setupScene(const CreateSceneCom
QList<ServerNodeInstance> instanceList = setupInstances(command);
sgView()->resize(rootNodeInstance().boundingRect().size().toSize());
quickView()->resize(rootNodeInstance().boundingRect().size().toSize());
return instanceList;
}
QList<QSGItem*> subItems(QSGItem *parentItem)
QList<QQuickItem*> subItems(QQuickItem *parentItem)
{
QList<QSGItem*> itemList;
QList<QQuickItem*> itemList;
itemList.append(parentItem->childItems());
foreach (QSGItem *childItem, parentItem->childItems())
foreach (QQuickItem *childItem, parentItem->childItems())
itemList.append(subItems(childItem));
return itemList;
}
QList<QSGItem*> Qt5NodeInstanceServer::allItems() const
QList<QQuickItem*> Qt5NodeInstanceServer::allItems() const
{
QList<QSGItem*> itemList;
QList<QQuickItem*> itemList;
if (sgView()) {
itemList.append(sgView()->rootItem());
itemList.append(subItems(sgView()->rootItem()));
if (quickView()) {
itemList.append(quickView()->rootItem());
itemList.append(subItems(quickView()->rootItem()));
}
return itemList;
@@ -36,7 +36,7 @@
#include "nodeinstanceserver.h"
QT_BEGIN_NAMESPACE
class QSGItem;
class QQuickItem;
class DesignerSupport;
QT_END_NAMESPACE
@@ -49,9 +49,9 @@ public:
Qt5NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient);
~Qt5NodeInstanceServer();
QSGView *sgView() const;
QDeclarativeView *declarativeView() const;
QDeclarativeEngine *engine() const;
QQuickView *quickView() const;
QQmlView *declarativeView() const;
QQmlEngine *engine() const;
void refreshBindings();
DesignerSupport *designerSupport() const;
@@ -64,10 +64,10 @@ protected:
void resizeCanvasSizeToRootItemSize();
void resetAllItems();
QList<ServerNodeInstance> setupScene(const CreateSceneCommand &command);
QList<QSGItem*> allItems() const;
QList<QQuickItem*> allItems() const;
private:
QWeakPointer<QSGView> m_sgView;
QWeakPointer<QQuickView> m_quickView;
DesignerSupport *m_designerSupport;
};
@@ -33,8 +33,9 @@
#include "nodeinstanceclientinterface.h"
#include "statepreviewimagechangedcommand.h"
#include "createscenecommand.h"
#include "removesharedmemorycommand.h"
#include <QSGItem>
#include <QQuickItem>
#include <designersupport.h>
namespace QmlDesigner {
@@ -68,11 +69,11 @@ void Qt5PreviewNodeInstanceServer::collectItemChangesAndSendChangeCommands()
if (!inFunction && nodeInstanceClient()->bytesToWrite() < 10000) {
inFunction = true;
QVector<ImageContainer> imageContainerVector;
imageContainerVector.append(ImageContainer(0, renderPreviewImage()));
imageContainerVector.append(ImageContainer(0, renderPreviewImage(), -1));
foreach (ServerNodeInstance instance, rootNodeInstance().stateInstances()) {
instance.activateState();
imageContainerVector.append(ImageContainer(instance.instanceId(), renderPreviewImage()));
imageContainerVector.append(ImageContainer(instance.instanceId(), renderPreviewImage(), instance.instanceId()));
instance.deactivateState();
}
@@ -88,9 +89,9 @@ void Qt5PreviewNodeInstanceServer::changeState(const ChangeStateCommand &/*comma
}
static void updateDirtyNodeRecursive(QSGItem *parentItem)
static void updateDirtyNodeRecursive(QQuickItem *parentItem)
{
foreach (QSGItem *childItem, parentItem->childItems())
foreach (QQuickItem *childItem, parentItem->childItems())
updateDirtyNodeRecursive(childItem);
DesignerSupport::updateDirtyNode(parentItem);
@@ -118,7 +119,7 @@ QImage Qt5PreviewNodeInstanceServer::renderPreviewImage()
void QmlDesigner::Qt5PreviewNodeInstanceServer::removeSharedMemory(const QmlDesigner::RemoveSharedMemoryCommand &command)
{
if (command.typeName() == "Image")
ImageContainer::removeSharedMemory(command.keyNumber());
ImageContainer::removeSharedMemorys(command.keyNumbers());
}
} // namespace QmlDesigner
@@ -30,7 +30,7 @@
#include "qt5rendernodeinstanceserver.h"
#include <QSGItem>
#include <QQuickItem>
#include "servernodeinstance.h"
#include "childrenchangeeventfilter.h"
@@ -59,7 +59,7 @@
#include "componentcompletedcommand.h"
#include "createscenecommand.h"
#include "sgitemnodeinstance.h"
#include "removesharedmemorycommand.h"
#include "dummycontextobject.h"
@@ -70,7 +70,7 @@ namespace QmlDesigner {
Qt5RenderNodeInstanceServer::Qt5RenderNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) :
Qt5NodeInstanceServer(nodeInstanceClient)
{
Internal::SGItemNodeInstance::createEffectItem(true);
Internal::QuickItemNodeInstance::createEffectItem(true);
}
void Qt5RenderNodeInstanceServer::collectItemChangesAndSendChangeCommands()
@@ -79,8 +79,8 @@ void Qt5RenderNodeInstanceServer::collectItemChangesAndSendChangeCommands()
if (!inFunction) {
inFunction = true;
if (sgView() && nodeInstanceClient()->bytesToWrite() < 10000) {
foreach (QSGItem *item, allItems()) {
if (quickView() && nodeInstanceClient()->bytesToWrite() < 10000) {
foreach (QQuickItem *item, allItems()) {
if (item && hasInstanceForObject(item)) {
ServerNodeInstance instance = instanceForObject(item);
if (DesignerSupport::isDirty(item, DesignerSupport::ContentUpdateMask))
@@ -148,7 +148,7 @@ void Qt5RenderNodeInstanceServer::completeComponent(const CompleteComponentComma
void QmlDesigner::Qt5RenderNodeInstanceServer::removeSharedMemory(const QmlDesigner::RemoveSharedMemoryCommand &command)
{
if (command.typeName() == "Image")
ImageContainer::removeSharedMemory(command.keyNumber());
ImageContainer::removeSharedMemorys(command.keyNumbers());
}
} // namespace QmlDesigner
@@ -0,0 +1,637 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#include "servernodeinstance.h"
#include "objectnodeinstance.h"
#include "dummynodeinstance.h"
#include "componentnodeinstance.h"
#include "qmltransitionnodeinstance.h"
#include "qmlpropertychangesnodeinstance.h"
#include "behaviornodeinstance.h"
#include "qmlstatenodeinstance.h"
#include "anchorchangesnodeinstance.h"
#if QT_VERSION >= 0x050000
#include "sgitemnodeinstance.h"
#else
#include "qmlgraphicsitemnodeinstance.h"
#include "positionernodeinstance.h"
#endif
#include "nodeinstanceserver.h"
#include "instancecontainer.h"
#include <QHash>
#include <QSet>
#include <QDebug>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QQuickItem>
#endif
#include <QQmlEngine>
/*!
\class QmlDesigner::NodeInstance
\ingroup CoreInstance
\brief NodeInstance is a common handle for the actual object representation of a ModelNode.
NodeInstance abstracts away the differences e.g. in terms of position and size
for QWidget, QGraphicsView, QLayout etc objects. Multiple NodeInstance objects can share
the pointer to the same instance object. The actual instance will be deleted when
the last NodeInstance object referencing to it is deleted. This can be disabled by
setDeleteHeldInstance().
\see QmlDesigner::NodeInstanceView
*/
namespace QmlDesigner {
/*!
\brief Constructor - creates a invalid NodeInstance
\see NodeInstanceView
*/
ServerNodeInstance::ServerNodeInstance()
{
}
/*!
\brief Destructor
*/
ServerNodeInstance::~ServerNodeInstance()
{
}
/*!
\brief Constructor - creates a valid NodeInstance
*/
ServerNodeInstance::ServerNodeInstance(const Internal::ObjectNodeInstance::Pointer &abstractInstance)
: m_nodeInstance(abstractInstance)
{
}
ServerNodeInstance::ServerNodeInstance(const ServerNodeInstance &other)
: m_nodeInstance(other.m_nodeInstance)
{
}
ServerNodeInstance &ServerNodeInstance::operator=(const ServerNodeInstance &other)
{
m_nodeInstance = other.m_nodeInstance;
return *this;
}
/*!
\brief Paints the NodeInstance with this painter.
\param painter used QPainter
*/
void ServerNodeInstance::paint(QPainter *painter)
{
m_nodeInstance->paint(painter);
}
QImage ServerNodeInstance::renderImage() const
{
return m_nodeInstance->renderImage();
}
bool ServerNodeInstance::isRootNodeInstance() const
{
return isValid() && m_nodeInstance->isRootNodeInstance();
}
bool ServerNodeInstance::isSubclassOf(QObject *object, const QByteArray &superTypeName)
{
if (object == 0)
return false;
const QMetaObject *metaObject = object->metaObject();
while (metaObject) {
QQmlType *qmlType = QQmlMetaType::qmlType(metaObject);
if (qmlType && qmlType->qmlTypeName() == superTypeName) // ignore version numbers
return true;
if (metaObject->className() == superTypeName)
return true;
metaObject = metaObject->superClass();
}
return false;
}
void ServerNodeInstance::setNodeSource(const QString &source)
{
m_nodeInstance->setNodeSource(source);
}
bool ServerNodeInstance::isSubclassOf(const QString &superTypeName) const
{
return isSubclassOf(internalObject(), superTypeName.toUtf8());
}
/*!
\brief Creates a new NodeInstace for this NodeMetaInfo
\param metaInfo MetaInfo for which a Instance should be created
\param context QQmlContext which should be used
\returns Internal Pointer of a NodeInstance
\see NodeMetaInfo
*/
Internal::ObjectNodeInstance::Pointer ServerNodeInstance::createInstance(QObject *objectToBeWrapped)
{
Internal::ObjectNodeInstance::Pointer instance;
if (objectToBeWrapped == 0)
instance = Internal::DummyNodeInstance::create();
#if QT_VERSION >= 0x050000
else if (isSubclassOf(objectToBeWrapped, "QQuickItem"))
instance = Internal::QuickItemNodeInstance::create(objectToBeWrapped);
#else
else if (isSubclassOf(objectToBeWrapped, "QQmlBasePositioner"))
instance = Internal::PositionerNodeInstance::create(objectToBeWrapped);
else if (isSubclassOf(objectToBeWrapped, "QQmlItem"))
instance = Internal::QmlGraphicsItemNodeInstance::create(objectToBeWrapped);
#endif
else if (isSubclassOf(objectToBeWrapped, "QQmlComponent"))
instance = Internal::ComponentNodeInstance::create(objectToBeWrapped);
else if (objectToBeWrapped->inherits("QQmlAnchorChanges"))
instance = Internal::AnchorChangesNodeInstance::create(objectToBeWrapped);
else if (isSubclassOf(objectToBeWrapped, "QQuickPropertyChanges"))
instance = Internal::QmlPropertyChangesNodeInstance::create(objectToBeWrapped);
else if (isSubclassOf(objectToBeWrapped, "QQuickState"))
instance = Internal::QmlStateNodeInstance::create(objectToBeWrapped);
else if (isSubclassOf(objectToBeWrapped, "QQuickTransition"))
instance = Internal::QmlTransitionNodeInstance::create(objectToBeWrapped);
else if (isSubclassOf(objectToBeWrapped, "QQuickBehavior"))
instance = Internal::BehaviorNodeInstance::create(objectToBeWrapped);
else if (isSubclassOf(objectToBeWrapped, "QObject"))
instance = Internal::ObjectNodeInstance::create(objectToBeWrapped);
else
instance = Internal::DummyNodeInstance::create();
return instance;
}
ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceServer, const InstanceContainer &instanceContainer, ComponentWrap componentWrap)
{
Q_ASSERT(instanceContainer.instanceId() != -1);
Q_ASSERT(nodeInstanceServer);
QObject *object = 0;
if (componentWrap == WrapAsComponent) {
object = Internal::ObjectNodeInstance::createComponentWrap(instanceContainer.nodeSource(), nodeInstanceServer->imports(), nodeInstanceServer->context());
} else if (!instanceContainer.nodeSource().isEmpty()) {
object = Internal::ObjectNodeInstance::createCustomParserObject(instanceContainer.nodeSource(), nodeInstanceServer->imports(), nodeInstanceServer->context());
} else if (!instanceContainer.componentPath().isEmpty()) {
object = Internal::ObjectNodeInstance::createComponent(instanceContainer.componentPath(), nodeInstanceServer->context());
} else {
object = Internal::ObjectNodeInstance::createPrimitive(instanceContainer.type(), instanceContainer.majorNumber(), instanceContainer.minorNumber(), nodeInstanceServer->context());
}
if ((object == 0) && (instanceContainer.metaType() == InstanceContainer::ItemMetaType)) //If we cannot instanciate the object but we know it has to be an Ttem, we create an Item instead.
#if QT_VERSION >= 0x050000
object = Internal::ObjectNodeInstance::createPrimitive("QQuickItem", 2, 0, nodeInstanceServer->context());
#else
object = Internal::ObjectNodeInstance::createPrimitive("QtQuick/Item", 1, 0, nodeInstanceServer->context());
#endif
ServerNodeInstance instance(createInstance(object));
instance.internalInstance()->setNodeInstanceServer(nodeInstanceServer);
instance.internalInstance()->setInstanceId(instanceContainer.instanceId());
instance.internalInstance()->initialize(instance.m_nodeInstance);
//QObject::connect(instance.internalObject(), SIGNAL(destroyed(QObject*)), nodeInstanceView, SLOT(removeIdFromContext(QObject*)));
return instance;
}
void ServerNodeInstance::reparent(const ServerNodeInstance &oldParentInstance, const QString &oldParentProperty, const ServerNodeInstance &newParentInstance, const QString &newParentProperty)
{
m_nodeInstance->reparent(oldParentInstance.m_nodeInstance, oldParentProperty, newParentInstance.m_nodeInstance, newParentProperty);
}
/*!
\brief Returns the parent NodeInstance of this NodeInstance.
If there is not parent than the parent is invalid.
\returns Parent NodeInstance.
*/
ServerNodeInstance ServerNodeInstance::parent() const
{
return m_nodeInstance->parentInstance();
}
bool ServerNodeInstance::hasParent() const
{
return m_nodeInstance->parent();
}
bool ServerNodeInstance::isValid() const
{
return m_nodeInstance && m_nodeInstance->isValid();
}
/*!
\brief Returns if the NodeInstance is a QGraphicsItem.
\returns true if this NodeInstance is a QGraphicsItem
*/
bool ServerNodeInstance::equalGraphicsItem(QGraphicsItem *item) const
{
return m_nodeInstance->equalGraphicsItem(item);
}
/*!
\brief Returns the bounding rect of the NodeInstance.
\returns QRectF of the NodeInstance
*/
QRectF ServerNodeInstance::boundingRect() const
{
QRectF boundingRect(m_nodeInstance->boundingRect());
//
// if (modelNode().isValid()) { // TODO implement recursiv stuff
// if (qFuzzyIsNull(boundingRect.width()))
// boundingRect.setWidth(nodeState().property("width").value().toDouble());
//
// if (qFuzzyIsNull(boundingRect.height()))
// boundingRect.setHeight(nodeState().property("height").value().toDouble());
// }
return boundingRect;
}
void ServerNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)
{
m_nodeInstance->setPropertyVariant(name, value);
}
void ServerNodeInstance::setPropertyDynamicVariant(const QString &name, const QString &typeName, const QVariant &value)
{
m_nodeInstance->createDynamicProperty(name, typeName);
m_nodeInstance->setPropertyVariant(name, value);
}
void ServerNodeInstance::setPropertyBinding(const QString &name, const QString &expression)
{
m_nodeInstance->setPropertyBinding(name, expression);
}
void ServerNodeInstance::setPropertyDynamicBinding(const QString &name, const QString &typeName, const QString &expression)
{
m_nodeInstance->createDynamicProperty(name, typeName);
m_nodeInstance->setPropertyBinding(name, expression);
}
void ServerNodeInstance::resetProperty(const QString &name)
{
m_nodeInstance->resetProperty(name);
}
void ServerNodeInstance::refreshProperty(const QString &name)
{
m_nodeInstance->refreshProperty(name);
}
void ServerNodeInstance::setId(const QString &id)
{
m_nodeInstance->setId(id);
}
/*!
\brief Returns the property value of the property of this NodeInstance.
\returns QVariant value
*/
QVariant ServerNodeInstance::property(const QString &name) const
{
return m_nodeInstance->property(name);
}
QStringList ServerNodeInstance::propertyNames() const
{
return m_nodeInstance->propertyNames();
}
bool ServerNodeInstance::hasBindingForProperty(const QString &name, bool *hasChanged) const
{
return m_nodeInstance->hasBindingForProperty(name, hasChanged);
}
/*!
\brief Returns the property default value of the property of this NodeInstance.
\returns QVariant default value which is the reset value to
*/
QVariant ServerNodeInstance::defaultValue(const QString &name) const
{
return m_nodeInstance->resetValue(name);
}
/*!
\brief Returns the type of the property of this NodeInstance.
*/
QString ServerNodeInstance::instanceType(const QString &name) const
{
return m_nodeInstance->instanceType(name);
}
void ServerNodeInstance::makeInvalid()
{
if (m_nodeInstance)
m_nodeInstance->destroy();
m_nodeInstance.clear();
}
bool ServerNodeInstance::hasContent() const
{
return m_nodeInstance->hasContent();
}
bool ServerNodeInstance::isResizable() const
{
return m_nodeInstance->isResizable();
}
bool ServerNodeInstance::isMovable() const
{
return m_nodeInstance->isMovable();
}
bool ServerNodeInstance::isInPositioner() const
{
return m_nodeInstance->isInPositioner();
}
bool ServerNodeInstance::hasAnchor(const QString &name) const
{
return m_nodeInstance->hasAnchor(name);
}
int ServerNodeInstance::penWidth() const
{
return m_nodeInstance->penWidth();
}
bool ServerNodeInstance::isAnchoredBySibling() const
{
return m_nodeInstance->isAnchoredBySibling();
}
bool ServerNodeInstance::isAnchoredByChildren() const
{
return m_nodeInstance->isAnchoredByChildren();
}
QPair<QString, ServerNodeInstance> ServerNodeInstance::anchor(const QString &name) const
{
return m_nodeInstance->anchor(name);
}
QDebug operator<<(QDebug debug, const ServerNodeInstance &instance)
{
if (instance.isValid()) {
debug.nospace() << "ServerNodeInstance("
<< instance.instanceId() << ", "
<< instance.internalObject() << ", "
<< instance.id() << ", "
<< instance.parent() << ')';
} else {
debug.nospace() << "ServerNodeInstance(invalid)";
}
return debug.space();
}
uint qHash(const ServerNodeInstance &instance)
{
return ::qHash(instance.instanceId());
}
bool operator==(const ServerNodeInstance &first, const ServerNodeInstance &second)
{
return first.instanceId() == second.instanceId();
}
bool ServerNodeInstance::isWrappingThisObject(QObject *object) const
{
return internalObject() && internalObject() == object;
}
/*!
\brief Returns the position in parent coordiantes.
\returns QPointF of the position of the instance.
*/
QPointF ServerNodeInstance::position() const
{
return m_nodeInstance->position();
}
/*!
\brief Returns the size in local coordiantes.
\returns QSizeF of the size of the instance.
*/
QSizeF ServerNodeInstance::size() const
{
QSizeF instanceSize = m_nodeInstance->size();
return instanceSize;
}
QTransform ServerNodeInstance::transform() const
{
return m_nodeInstance->transform();
}
/*!
\brief Returns the transform matrix of the instance.
\returns QTransform of the instance.
*/
QTransform ServerNodeInstance::customTransform() const
{
return m_nodeInstance->customTransform();
}
QTransform ServerNodeInstance::sceneTransform() const
{
return m_nodeInstance->sceneTransform();
}
double ServerNodeInstance::rotation() const
{
return m_nodeInstance->rotation();
}
double ServerNodeInstance::scale() const
{
return m_nodeInstance->scale();
}
QList<QGraphicsTransform *> ServerNodeInstance::transformations() const
{
return m_nodeInstance->transformations();
}
QPointF ServerNodeInstance::transformOriginPoint() const
{
return m_nodeInstance->transformOriginPoint();
}
double ServerNodeInstance::zValue() const
{
return m_nodeInstance->zValue();
}
/*!
\brief Returns the opacity of the instance.
\returns 0.0 mean transparent and 1.0 opaque.
*/
double ServerNodeInstance::opacity() const
{
return m_nodeInstance->opacity();
}
void ServerNodeInstance::setDeleteHeldInstance(bool deleteInstance)
{
m_nodeInstance->setDeleteHeldInstance(deleteInstance);
}
void ServerNodeInstance::paintUpdate()
{
m_nodeInstance->paintUpdate();
}
QObject *ServerNodeInstance::internalObject() const
{
if (m_nodeInstance.isNull())
return 0;
return m_nodeInstance->object();
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QQuickItem *ServerNodeInstance::internalSGItem() const
{
return qobject_cast<QQuickItem*>(internalObject());
}
#endif
void ServerNodeInstance::activateState()
{
m_nodeInstance->activateState();
}
void ServerNodeInstance::deactivateState()
{
m_nodeInstance->deactivateState();
}
bool ServerNodeInstance::updateStateVariant(const ServerNodeInstance &target, const QString &propertyName, const QVariant &value)
{
return m_nodeInstance->updateStateVariant(target.internalInstance(), propertyName, value);
}
bool ServerNodeInstance::updateStateBinding(const ServerNodeInstance &target, const QString &propertyName, const QString &expression)
{
return m_nodeInstance->updateStateBinding(target.internalInstance(), propertyName, expression);
}
QVariant ServerNodeInstance::resetVariant(const QString &propertyName) const
{
return m_nodeInstance->resetValue(propertyName);
}
bool ServerNodeInstance::resetStateProperty(const ServerNodeInstance &target, const QString &propertyName, const QVariant &resetValue)
{
return m_nodeInstance->resetStateProperty(target.internalInstance(), propertyName, resetValue);
}
/*!
Makes types used in node instances known to the Qml engine. To be called once at initialization time.
*/
void ServerNodeInstance::registerQmlTypes()
{
// qmlRegisterType<QmlDesigner::Internal::QmlPropertyChangesObject>();
}
void ServerNodeInstance::doComponentComplete()
{
m_nodeInstance->doComponentComplete();
}
QList<ServerNodeInstance> ServerNodeInstance::childItems() const
{
return m_nodeInstance->childItems();
}
QString ServerNodeInstance::id() const
{
return m_nodeInstance->id();
}
qint32 ServerNodeInstance::instanceId() const
{
if (isValid()) {
return m_nodeInstance->instanceId();
} else {
return -1;
}
}
QObject* ServerNodeInstance::testHandle() const
{
return internalObject();
}
QList<ServerNodeInstance> ServerNodeInstance::stateInstances() const
{
return m_nodeInstance->stateInstances();
}
Internal::ObjectNodeInstance::Pointer ServerNodeInstance::internalInstance() const
{
return m_nodeInstance;
}
} // namespace QmlDesigner
@@ -0,0 +1,217 @@
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**************************************************************************/
#ifndef SERVERNODEINSTANCE_H
#define SERVERNODEINSTANCE_H
#include <QSharedPointer>
#include <QHash>
#include <QRectF>
#include <nodeinstanceserverinterface.h>
#include <propertyvaluecontainer.h>
QT_BEGIN_NAMESPACE
class QPainter;
class QStyleOptionGraphicsItem;
class QQmlContext;
class QGraphicsItem;
class QGraphicsTransform;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
class QQuickItem;
#endif
QT_END_NAMESPACE
namespace QmlDesigner {
class NodeInstanceServer;
class Qt4NodeInstanceServer;
class Qt4PreviewNodeInstanceServer;
class Qt5NodeInstanceServer;
class Qt5PreviewNodeInstanceServer;
class InstanceContainer;
namespace Internal {
class ObjectNodeInstance;
class QmlGraphicsItemNodeInstance;
class QmlPropertyChangesNodeInstance;
class GraphicsObjectNodeInstance;
class QmlStateNodeInstance;
class QuickItemNodeInstance;
}
class ServerNodeInstance
{
friend class NodeInstanceServer;
friend class Qt4NodeInstanceServer;
friend class Qt4PreviewNodeInstanceServer;
friend class Qt5NodeInstanceServer;
friend class Qt5PreviewNodeInstanceServer;
friend class QHash<qint32, ServerNodeInstance>;
friend uint qHash(const ServerNodeInstance &instance);
friend bool operator==(const ServerNodeInstance &first, const ServerNodeInstance &second);
friend QDebug operator<<(QDebug debug, const ServerNodeInstance &instance);
friend class NodeMetaInfo;
friend class QmlDesigner::Internal::QmlGraphicsItemNodeInstance;
friend class QmlDesigner::Internal::QuickItemNodeInstance;
friend class QmlDesigner::Internal::GraphicsObjectNodeInstance;
friend class QmlDesigner::Internal::ObjectNodeInstance;
friend class QmlDesigner::Internal::QmlPropertyChangesNodeInstance;
friend class QmlDesigner::Internal::QmlStateNodeInstance;
public:
enum ComponentWrap {
WrapAsComponent,
DoNotWrapAsComponent
};
ServerNodeInstance();
~ServerNodeInstance();
ServerNodeInstance(const ServerNodeInstance &other);
ServerNodeInstance& operator=(const ServerNodeInstance &other);
void paint(QPainter *painter);
QImage renderImage() const;
ServerNodeInstance parent() const;
bool hasParent() const;
bool equalGraphicsItem(QGraphicsItem *item) const;
QRectF boundingRect() const;
QPointF position() const;
QSizeF size() const;
QTransform transform() const;
QTransform customTransform() const;
QTransform sceneTransform() const;
double rotation() const;
double scale() const;
QList<QGraphicsTransform *> transformations() const;
QPointF transformOriginPoint() const;
double zValue() const;
double opacity() const;
QVariant property(const QString &name) const;
QVariant defaultValue(const QString &name) const;
QString instanceType(const QString &name) const;
QStringList propertyNames() const;
bool hasBindingForProperty(const QString &name, bool *hasChanged = 0) const;
bool isValid() const;
void makeInvalid();
bool hasContent() const;
bool isResizable() const;
bool isMovable() const;
bool isInPositioner() const;
bool isSubclassOf(const QString &superTypeName) const;
bool isRootNodeInstance() const;
bool isWrappingThisObject(QObject *object) const;
QVariant resetVariant(const QString &name) const;
bool hasAnchor(const QString &name) const;
bool isAnchoredBySibling() const;
bool isAnchoredByChildren() const;
QPair<QString, ServerNodeInstance> anchor(const QString &name) const;
int penWidth() const;
static void registerQmlTypes();
void doComponentComplete();
QList<ServerNodeInstance> childItems() const;
QString id() const;
qint32 instanceId() const;
QObject* testHandle() const;
QSharedPointer<Internal::ObjectNodeInstance> internalInstance() const;
QList<ServerNodeInstance> stateInstances() const;
private: // functions
ServerNodeInstance(const QSharedPointer<Internal::ObjectNodeInstance> &abstractInstance);
void setPropertyVariant(const QString &name, const QVariant &value);
void setPropertyDynamicVariant(const QString &name, const QString &typeName, const QVariant &value);
void setPropertyBinding(const QString &name, const QString &expression);
void setPropertyDynamicBinding(const QString &name, const QString &typeName, const QString &expression);
void resetProperty(const QString &name);
void refreshProperty(const QString &name);
void activateState();
void deactivateState();
void refreshState();
bool updateStateVariant(const ServerNodeInstance &target, const QString &propertyName, const QVariant &value);
bool updateStateBinding(const ServerNodeInstance &target, const QString &propertyName, const QString &expression);
bool resetStateProperty(const ServerNodeInstance &target, const QString &propertyName, const QVariant &resetValue);
static ServerNodeInstance create(NodeInstanceServer *nodeInstanceServer, const InstanceContainer &instanceContainer, ComponentWrap componentWrap);
void setDeleteHeldInstance(bool deleteInstance);
void reparent(const ServerNodeInstance &oldParentInstance, const QString &oldParentProperty, const ServerNodeInstance &newParentInstance, const QString &newParentProperty);
void setId(const QString &id);
static QSharedPointer<Internal::ObjectNodeInstance> createInstance(QObject *objectToBeWrapped);
void paintUpdate();
static bool isSubclassOf(QObject *object, const QByteArray &superTypeName);
void setNodeSource(const QString &source);
QObject *internalObject() const; // should be not used outside of the nodeinstances!!!!
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QQuickItem *internalSGItem() const;
#endif
private: // variables
QSharedPointer<Internal::ObjectNodeInstance> m_nodeInstance;
};
uint qHash(const ServerNodeInstance &instance);
bool operator==(const ServerNodeInstance &first, const ServerNodeInstance &second);
QDebug operator<<(QDebug debug, const ServerNodeInstance &instance);
}
Q_DECLARE_METATYPE(QmlDesigner::ServerNodeInstance)
#endif // SERVERNODEINSTANCE_H
@@ -32,8 +32,8 @@
#include "qt5nodeinstanceserver.h"
#include <QDeclarativeExpression>
#include <QSGView>
#include <QQmlExpression>
#include <QQuickView>
#include <cmath>
#include <QHash>
@@ -43,9 +43,9 @@
namespace QmlDesigner {
namespace Internal {
bool SGItemNodeInstance::s_createEffectItem = false;
bool QuickItemNodeInstance::s_createEffectItem = false;
SGItemNodeInstance::SGItemNodeInstance(QSGItem *item)
QuickItemNodeInstance::QuickItemNodeInstance(QQuickItem *item)
: ObjectNodeInstance(item),
m_hasHeight(false),
m_hasWidth(false),
@@ -59,22 +59,22 @@ SGItemNodeInstance::SGItemNodeInstance(QSGItem *item)
{
}
SGItemNodeInstance::~SGItemNodeInstance()
QuickItemNodeInstance::~QuickItemNodeInstance()
{
if (sgItem())
designerSupport()->derefFromEffectItem(sgItem());
if (quickItem())
designerSupport()->derefFromEffectItem(quickItem());
}
bool SGItemNodeInstance::hasContent() const
bool QuickItemNodeInstance::hasContent() const
{
return m_hasContent;
}
QList<ServerNodeInstance> SGItemNodeInstance::childItems() const
QList<ServerNodeInstance> QuickItemNodeInstance::childItems() const
{
QList<ServerNodeInstance> instanceList;
foreach (QSGItem *childItem, sgItem()->childItems())
foreach (QQuickItem *childItem, quickItem()->childItems())
{
if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) {
instanceList.append(nodeInstanceServer()->instanceForObject(childItem));
@@ -90,12 +90,12 @@ QList<ServerNodeInstance> SGItemNodeInstance::childItems() const
return instanceList;
}
QList<ServerNodeInstance> SGItemNodeInstance::childItemsForChild(QSGItem *childItem) const
QList<ServerNodeInstance> QuickItemNodeInstance::childItemsForChild(QQuickItem *childItem) const
{
QList<ServerNodeInstance> instanceList;
if (childItem) {
foreach (QSGItem *childItem, childItem->childItems())
foreach (QQuickItem *childItem, childItem->childItems())
{
if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) {
instanceList.append(nodeInstanceServer()->instanceForObject(childItem));
@@ -107,18 +107,18 @@ QList<ServerNodeInstance> SGItemNodeInstance::childItemsForChild(QSGItem *childI
return instanceList;
}
void SGItemNodeInstance::setHasContent(bool hasContent)
void QuickItemNodeInstance::setHasContent(bool hasContent)
{
m_hasContent = hasContent;
}
bool anyItemHasContent(QSGItem *graphicsItem)
bool anyItemHasContent(QQuickItem *graphicsItem)
{
if (graphicsItem->flags().testFlag(QSGItem::ItemHasContents))
if (graphicsItem->flags().testFlag(QQuickItem::ItemHasContents))
return true;
foreach (QSGItem *childItem, graphicsItem->childItems()) {
foreach (QQuickItem *childItem, graphicsItem->childItems()) {
if (anyItemHasContent(childItem))
return true;
}
@@ -126,67 +126,68 @@ bool anyItemHasContent(QSGItem *graphicsItem)
return false;
}
QPointF SGItemNodeInstance::position() const
QPointF QuickItemNodeInstance::position() const
{
return sgItem()->pos();
return quickItem()->pos();
}
QTransform SGItemNodeInstance::transform() const
QTransform QuickItemNodeInstance::transform() const
{
return DesignerSupport::parentTransform(sgItem());
return DesignerSupport::parentTransform(quickItem());
}
QTransform SGItemNodeInstance::customTransform() const
QTransform QuickItemNodeInstance::customTransform() const
{
return QTransform();
}
QTransform SGItemNodeInstance::sceneTransform() const
QTransform QuickItemNodeInstance::sceneTransform() const
{
return DesignerSupport::canvasTransform(sgItem());
return QTransform();
// return DesignerSupport::canvasTransform(quickItem());
}
double SGItemNodeInstance::rotation() const
double QuickItemNodeInstance::rotation() const
{
return sgItem()->rotation();
return quickItem()->rotation();
}
double SGItemNodeInstance::scale() const
double QuickItemNodeInstance::scale() const
{
return sgItem()->scale();
return quickItem()->scale();
}
QPointF SGItemNodeInstance::transformOriginPoint() const
QPointF QuickItemNodeInstance::transformOriginPoint() const
{
return sgItem()->transformOriginPoint();
return quickItem()->transformOriginPoint();
}
double SGItemNodeInstance::zValue() const
double QuickItemNodeInstance::zValue() const
{
return sgItem()->z();
return quickItem()->z();
}
double SGItemNodeInstance::opacity() const
double QuickItemNodeInstance::opacity() const
{
return sgItem()->opacity();
return quickItem()->opacity();
}
QObject *SGItemNodeInstance::parent() const
QObject *QuickItemNodeInstance::parent() const
{
if (!sgItem() || !sgItem()->parentItem())
if (!quickItem() || !quickItem()->parentItem())
return 0;
return sgItem()->parentItem();
return quickItem()->parentItem();
}
bool SGItemNodeInstance::equalSGItem(QSGItem *item) const
bool QuickItemNodeInstance::equalQuickItem(QQuickItem *item) const
{
return item == sgItem();
return item == quickItem();
}
void SGItemNodeInstance::updateDirtyNodeRecursive(QSGItem *parentItem) const
void QuickItemNodeInstance::updateDirtyNodeRecursive(QQuickItem *parentItem) const
{
foreach (QSGItem *childItem, parentItem->childItems()) {
foreach (QQuickItem *childItem, parentItem->childItems()) {
if (!nodeInstanceServer()->hasInstanceForObject(childItem))
updateDirtyNodeRecursive(childItem);
}
@@ -194,86 +195,86 @@ void SGItemNodeInstance::updateDirtyNodeRecursive(QSGItem *parentItem) const
DesignerSupport::updateDirtyNode(parentItem);
}
QImage SGItemNodeInstance::renderImage() const
QImage QuickItemNodeInstance::renderImage() const
{
updateDirtyNodeRecursive(sgItem());
updateDirtyNodeRecursive(quickItem());
QRectF boundingRect = boundingRectWithStepChilds(sgItem());
QRectF boundingRect = boundingRectWithStepChilds(quickItem());
QImage renderImage = designerSupport()->renderImageForItem(sgItem(), boundingRect, boundingRect.size().toSize());
QImage renderImage = designerSupport()->renderImageForItem(quickItem(), boundingRect, boundingRect.size().toSize());
renderImage = renderImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);
return renderImage;
}
bool SGItemNodeInstance::isMovable() const
bool QuickItemNodeInstance::isMovable() const
{
if (isRootNodeInstance())
return false;
return m_isMovable && sgItem() && sgItem()->parentItem();
return m_isMovable && quickItem() && quickItem()->parentItem();
}
void SGItemNodeInstance::setMovable(bool movable)
void QuickItemNodeInstance::setMovable(bool movable)
{
m_isMovable = movable;
}
SGItemNodeInstance::Pointer SGItemNodeInstance::create(QObject *object)
QuickItemNodeInstance::Pointer QuickItemNodeInstance::create(QObject *object)
{
QSGItem *sgItem = qobject_cast<QSGItem*>(object);
QQuickItem *quickItem = qobject_cast<QQuickItem*>(object);
Q_ASSERT(sgItem);
Q_ASSERT(quickItem);
Pointer instance(new SGItemNodeInstance(sgItem));
Pointer instance(new QuickItemNodeInstance(quickItem));
instance->setHasContent(anyItemHasContent(sgItem));
sgItem->setFlag(QSGItem::ItemHasContents, true);
instance->setHasContent(anyItemHasContent(quickItem));
quickItem->setFlag(QQuickItem::ItemHasContents, true);
static_cast<QDeclarativeParserStatus*>(sgItem)->classBegin();
static_cast<QQmlParserStatus*>(quickItem)->classBegin();
instance->populateResetHashes();
return instance;
}
void SGItemNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance)
void QuickItemNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance)
{
if (instanceId() == 0) {
DesignerSupport::setRootItem(nodeInstanceServer()->sgView(), sgItem());
DesignerSupport::setRootItem(nodeInstanceServer()->quickView(), quickItem());
} else {
sgItem()->setParentItem(qobject_cast<QSGItem*>(nodeInstanceServer()->sgView()->rootObject()));
quickItem()->setParentItem(qobject_cast<QQuickItem*>(nodeInstanceServer()->quickView()->rootObject()));
}
if (s_createEffectItem || instanceId() == 0)
designerSupport()->refFromEffectItem(sgItem());
designerSupport()->refFromEffectItem(quickItem());
ObjectNodeInstance::initialize(objectNodeInstance);
sgItem()->update();
quickItem()->update();
}
bool SGItemNodeInstance::isSGItem() const
bool QuickItemNodeInstance::isQuickItem() const
{
return true;
}
QSizeF SGItemNodeInstance::size() const
QSizeF QuickItemNodeInstance::size() const
{
double width;
if (DesignerSupport::isValidWidth(sgItem())) {
width = sgItem()->width();
if (DesignerSupport::isValidWidth(quickItem())) {
width = quickItem()->width();
} else {
width = sgItem()->implicitWidth();
width = quickItem()->implicitWidth();
}
double height;
if (DesignerSupport::isValidHeight(sgItem())) {
height = sgItem()->height();
if (DesignerSupport::isValidHeight(quickItem())) {
height = quickItem()->height();
} else {
height = sgItem()->implicitHeight();
height = quickItem()->implicitHeight();
}
@@ -285,11 +286,11 @@ static inline bool isRectangleSane(const QRectF &rect)
return rect.isValid() && (rect.width() < 10000) && (rect.height() < 10000);
}
QRectF SGItemNodeInstance::boundingRectWithStepChilds(QSGItem *parentItem) const
QRectF QuickItemNodeInstance::boundingRectWithStepChilds(QQuickItem *parentItem) const
{
QRectF boundingRect = parentItem->boundingRect();
foreach (QSGItem *childItem, parentItem->childItems()) {
foreach (QQuickItem *childItem, parentItem->childItems()) {
if (!nodeInstanceServer()->hasInstanceForObject(childItem)) {
QRectF transformedRect = childItem->mapRectToItem(parentItem, boundingRectWithStepChilds(childItem));
if (isRectangleSane(transformedRect))
@@ -300,20 +301,20 @@ QRectF SGItemNodeInstance::boundingRectWithStepChilds(QSGItem *parentItem) const
return boundingRect;
}
QRectF SGItemNodeInstance::boundingRect() const
QRectF QuickItemNodeInstance::boundingRect() const
{
if (sgItem()) {
if (sgItem()->clip()) {
return sgItem()->boundingRect();
if (quickItem()) {
if (quickItem()->clip()) {
return quickItem()->boundingRect();
} else {
return boundingRectWithStepChilds(sgItem());
return boundingRectWithStepChilds(quickItem());
}
}
return QRectF();
}
void SGItemNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)
void QuickItemNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)
{
if (name == "state")
return; // states are only set by us
@@ -345,7 +346,7 @@ void SGItemNodeInstance::setPropertyVariant(const QString &name, const QVariant
refresh();
}
void SGItemNodeInstance::setPropertyBinding(const QString &name, const QString &expression)
void QuickItemNodeInstance::setPropertyBinding(const QString &name, const QString &expression)
{
if (name == "state")
return; // states are only set by us
@@ -353,37 +354,37 @@ void SGItemNodeInstance::setPropertyBinding(const QString &name, const QString &
ObjectNodeInstance::setPropertyBinding(name, expression);
}
QVariant SGItemNodeInstance::property(const QString &name) const
QVariant QuickItemNodeInstance::property(const QString &name) const
{
return ObjectNodeInstance::property(name);
}
void SGItemNodeInstance::resetHorizontal()
void QuickItemNodeInstance::resetHorizontal()
{
setPropertyVariant("x", m_x);
if (m_width > 0.0) {
setPropertyVariant("width", m_width);
} else {
setPropertyVariant("width", sgItem()->implicitWidth());
setPropertyVariant("width", quickItem()->implicitWidth());
}
}
void SGItemNodeInstance::resetVertical()
void QuickItemNodeInstance::resetVertical()
{
setPropertyVariant("y", m_y);
if (m_height > 0.0) {
setPropertyVariant("height", m_height);
} else {
setPropertyVariant("height", sgItem()->implicitWidth());
setPropertyVariant("height", quickItem()->implicitWidth());
}
}
static void repositioning(QSGItem *item)
static void repositioning(QQuickItem *item)
{
if (!item)
return;
// QDeclarativeBasePositioner *positioner = qobject_cast<QDeclarativeBasePositioner*>(item);
// QQmlBasePositioner *positioner = qobject_cast<QQmlBasePositioner*>(item);
// if (positioner)
// positioner->rePositioning();
@@ -391,41 +392,41 @@ static void repositioning(QSGItem *item)
repositioning(item->parentItem());
}
void SGItemNodeInstance::refresh()
void QuickItemNodeInstance::refresh()
{
repositioning(sgItem());
repositioning(quickItem());
}
void SGItemNodeInstance::doComponentComplete()
void QuickItemNodeInstance::doComponentComplete()
{
if (sgItem()) {
if (DesignerSupport::isComponentComplete(sgItem()))
if (quickItem()) {
if (DesignerSupport::isComponentComplete(quickItem()))
return;
static_cast<QDeclarativeParserStatus*>(sgItem())->componentComplete();
static_cast<QQmlParserStatus*>(quickItem())->componentComplete();
}
sgItem()->update();
quickItem()->update();
}
bool SGItemNodeInstance::isResizable() const
bool QuickItemNodeInstance::isResizable() const
{
if (isRootNodeInstance())
return false;
return m_isResizable && sgItem() && sgItem()->parentItem();
return m_isResizable && quickItem() && quickItem()->parentItem();
}
void SGItemNodeInstance::setResizable(bool resizeable)
void QuickItemNodeInstance::setResizable(bool resizeable)
{
m_isResizable = resizeable;
}
int SGItemNodeInstance::penWidth() const
int QuickItemNodeInstance::penWidth() const
{
return DesignerSupport::borderWidth(sgItem());
return DesignerSupport::borderWidth(quickItem());
}
void SGItemNodeInstance::resetProperty(const QString &name)
void QuickItemNodeInstance::resetProperty(const QString &name)
{
if (name == "height") {
m_hasHeight = false;
@@ -443,7 +444,7 @@ void SGItemNodeInstance::resetProperty(const QString &name)
if (name == "y")
m_y = 0.0;
DesignerSupport::resetAnchor(sgItem(), name);
DesignerSupport::resetAnchor(quickItem(), name);
if (name == "anchors.fill") {
resetHorizontal();
@@ -470,7 +471,7 @@ void SGItemNodeInstance::resetProperty(const QString &name)
ObjectNodeInstance::resetProperty(name);
}
void SGItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const QString &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const QString &newParentProperty)
void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const QString &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const QString &newParentProperty)
{
if (oldParentInstance && oldParentInstance->isPositioner()) {
setInPositioner(false);
@@ -493,7 +494,7 @@ void SGItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentIn
}
refresh();
DesignerSupport::updateDirtyNode(sgItem());
DesignerSupport::updateDirtyNode(quickItem());
}
static bool isValidAnchorName(const QString &name)
@@ -511,17 +512,17 @@ static bool isValidAnchorName(const QString &name)
return anchorNameList.contains(name);
}
bool SGItemNodeInstance::hasAnchor(const QString &name) const
bool QuickItemNodeInstance::hasAnchor(const QString &name) const
{
return DesignerSupport::hasAnchor(sgItem(), name);
return DesignerSupport::hasAnchor(quickItem(), name);
}
QPair<QString, ServerNodeInstance> SGItemNodeInstance::anchor(const QString &name) const
QPair<QString, ServerNodeInstance> QuickItemNodeInstance::anchor(const QString &name) const
{
if (!isValidAnchorName(name) || !DesignerSupport::hasAnchor(sgItem(), name))
if (!isValidAnchorName(name) || !DesignerSupport::hasAnchor(quickItem(), name))
return ObjectNodeInstance::anchor(name);
QPair<QString, QObject*> nameObjectPair = DesignerSupport::anchorLineTarget(sgItem(), name, context());
QPair<QString, QObject*> nameObjectPair = DesignerSupport::anchorLineTarget(quickItem(), name, context());
QObject *targetObject = nameObjectPair.second;
QString targetName = nameObjectPair.first;
@@ -533,10 +534,10 @@ QPair<QString, ServerNodeInstance> SGItemNodeInstance::anchor(const QString &nam
}
}
QList<ServerNodeInstance> SGItemNodeInstance::stateInstances() const
QList<ServerNodeInstance> QuickItemNodeInstance::stateInstances() const
{
QList<ServerNodeInstance> instanceList;
QList<QObject*> stateList = DesignerSupport::statesForItem(sgItem());
QList<QObject*> stateList = DesignerSupport::statesForItem(quickItem());
foreach (QObject *state, stateList)
{
if (state && nodeInstanceServer()->hasInstanceForObject(state))
@@ -546,12 +547,12 @@ QList<ServerNodeInstance> SGItemNodeInstance::stateInstances() const
return instanceList;
}
bool SGItemNodeInstance::isAnchoredBySibling() const
bool QuickItemNodeInstance::isAnchoredBySibling() const
{
if (sgItem()->parentItem()) {
foreach (QSGItem *siblingItem, sgItem()->parentItem()->childItems()) { // search in siblings for a anchor to this item
if (quickItem()->parentItem()) {
foreach (QQuickItem *siblingItem, quickItem()->parentItem()->childItems()) { // search in siblings for a anchor to this item
if (siblingItem) {
if (DesignerSupport::isAnchoredTo(siblingItem, sgItem()))
if (DesignerSupport::isAnchoredTo(siblingItem, quickItem()))
return true;
}
}
@@ -560,34 +561,34 @@ bool SGItemNodeInstance::isAnchoredBySibling() const
return false;
}
bool SGItemNodeInstance::isAnchoredByChildren() const
bool QuickItemNodeInstance::isAnchoredByChildren() const
{
if (DesignerSupport::areChildrenAnchoredTo(sgItem(), sgItem())) // search in children for a anchor to this item
if (DesignerSupport::areChildrenAnchoredTo(quickItem(), quickItem())) // search in children for a anchor to this item
return true;
return false;
}
QSGItem *SGItemNodeInstance::sgItem() const
QQuickItem *QuickItemNodeInstance::quickItem() const
{
if (object() == 0)
return 0;
Q_ASSERT(qobject_cast<QSGItem*>(object()));
return static_cast<QSGItem*>(object());
Q_ASSERT(qobject_cast<QQuickItem*>(object()));
return static_cast<QQuickItem*>(object());
}
DesignerSupport *SGItemNodeInstance::designerSupport() const
DesignerSupport *QuickItemNodeInstance::designerSupport() const
{
return qt5NodeInstanceServer()->designerSupport();
}
Qt5NodeInstanceServer *SGItemNodeInstance::qt5NodeInstanceServer() const
Qt5NodeInstanceServer *QuickItemNodeInstance::qt5NodeInstanceServer() const
{
return qobject_cast<Qt5NodeInstanceServer*>(nodeInstanceServer());
}
void SGItemNodeInstance::createEffectItem(bool createEffectItem)
void QuickItemNodeInstance::createEffectItem(bool createEffectItem)
{
s_createEffectItem = createEffectItem;
}
@@ -28,31 +28,31 @@
**
**************************************************************************/
#ifndef SGITEMNODEINSTANCE_H
#define SGITEMNODEINSTANCE_H
#ifndef QuickITEMNODEINSTANCE_H
#define QuickITEMNODEINSTANCE_H
#include <QtGlobal>
#include "objectnodeinstance.h"
#include <QSGItem>
#include <QQuickItem>
#include <designersupport.h>
namespace QmlDesigner {
namespace Internal {
class SGItemNodeInstance : public ObjectNodeInstance
class QuickItemNodeInstance : public ObjectNodeInstance
{
public:
typedef QSharedPointer<SGItemNodeInstance> Pointer;
typedef QWeakPointer<SGItemNodeInstance> WeakPointer;
typedef QSharedPointer<QuickItemNodeInstance> Pointer;
typedef QWeakPointer<QuickItemNodeInstance> WeakPointer;
~SGItemNodeInstance();
~QuickItemNodeInstance();
static Pointer create(QObject *objectToBeWrapped);
void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance);
bool isSGItem() const;
bool isQuickItem() const;
QRectF boundingRect() const;
QPointF position() const;
@@ -69,12 +69,12 @@ public:
QPointF transformOriginPoint() const;
double zValue() const;
bool equalSGItem(QSGItem *item) const;
bool equalQuickItem(QQuickItem *item) const;
bool hasContent() const;
QList<ServerNodeInstance> childItems() const;
QList<ServerNodeInstance> childItemsForChild(QSGItem *childItem) const;
QList<ServerNodeInstance> childItemsForChild(QQuickItem *childItem) const;
bool isMovable() const;
void setMovable(bool movable);
@@ -110,13 +110,13 @@ public:
static void createEffectItem(bool createEffectItem);
protected:
SGItemNodeInstance(QSGItem*);
QSGItem *sgItem() const;
QuickItemNodeInstance(QQuickItem*);
QQuickItem *quickItem() const;
void resetHorizontal();
void resetVertical();
void refresh();
QRectF boundingRectWithStepChilds(QSGItem *parentItem) const;
void updateDirtyNodeRecursive(QSGItem *parentItem) const;
QRectF boundingRectWithStepChilds(QQuickItem *parentItem) const;
void updateDirtyNodeRecursive(QQuickItem *parentItem) const;
private: //variables
bool m_hasHeight;
@@ -134,5 +134,5 @@ private: //variables
} // namespace Internal
} // namespace QmlDesigner
#endif // SGITEMNODEINSTANCE_H
#endif // QuickITEMNODEINSTANCE_H
@@ -2,22 +2,20 @@ TARGET = qml2puppet
TEMPLATE = app
QT += core gui declarative network
QT += core gui qml quick network v8
contains (QT_CONFIG, webkit) {
QT += webkit
}
QT += core-private declarative-private gui-private script-private v8-private
QT += core-private qml-private quick-private gui-private script-private v8-private
DEFINES += QWEAKPOINTER_ENABLE_ARROW
include(../../../../qtcreator.pri)
include(../../../../../qtcreator.pri)
DESTDIR = $$[QT_INSTALL_BINS]
include(../../../rpath.pri)
include(../../../../../src/rpath.pri)
include (instances/instances.pri)
include (../instances/instances.pri)
include (../commands/commands.pri)
include (../container/container.pri)
include (../interfaces/interfaces.pri)