Commit 770ab68c authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner.Instances: Refactor the qml2 puppet



Change-Id: Iaa7a744ecf13e011addc573a381ea523d2d50a55
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 51f84724
......@@ -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 {
......
/**************************************************************************
**
** 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
/**************************************************************************
**
** 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
/**************************************************************************
**
** 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
/**************************************************************************
**
** 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
/**************************************************************************
**
** 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
/**************************************************************************
**
** 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
/**************************************************************************
**
** 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.