1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef QMLPROPERTYCHANGESNODEINSTANCE_H
34 #define QMLPROPERTYCHANGESNODEINSTANCE_H
36 #include "objectnodeinstance.h"
37 #include <private/qdeclarativestateoperations_p.h>
38 #include <private/qdeclarativepropertychanges_p.h>
41 #include <QWeakPointer>
44 class QDeclarativeProperty;
47 namespace QmlDesigner {
51 class QmlPropertyChangesNodeInstance;
53 // Original QmlPropertyChanges class requires a custom parser
54 // work around this by writing a replacement class
55 //class QmlPropertyChangesObject : public QDeclarativeStateOperation
58 // Q_PROPERTY(QObject *target READ targetObject WRITE setTargetObject)
59 // Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues)
60 // Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit)
62 // typedef QPair<QString, QWeakPointer<QDeclarativeBinding> > ExpressionPair;
64 // ~QmlPropertyChangesObject();
65 // QObject *targetObject() const;
66 // void setTargetObject(QObject *object);
68 // bool restoreEntryValues() const;
69 // void setRestoreEntryValues(bool restore);
71 // bool isExplicit() const;
72 // void setIsExplicit(bool isExplicit);
74 // virtual ActionList actions();
76 // void setVariantValue(const QString &name, const QVariant & value);
77 // void setExpression(const QString &name, const QString &expression);
78 // void removeVariantValue(const QString &name);
79 // void removeExpression(const QString &name);
81 // void resetProperty(const QString &name);
83 // QVariant variantValue(const QString &name) const;
84 // QString expression(const QString &name) const;
86 // bool hasVariantValue(const QString &name) const;
87 // bool hasExpression(const QString &name) const;
89 // QmlPropertyChangesObject();
91 // bool updateStateVariant(const QString &propertyName, const QVariant &value);
92 // bool updateStateBinding(const QString &propertyName, const QString &expression);
93 // bool resetStateProperty(const QString &propertyName, const QVariant &resetValue);
95 // QDeclarativeState *state() const;
96 // void updateRevertValueAndBinding(const QString &name);
98 // void removeFromStateRevertList();
99 // void addToStateRevertList();
101 //private: // functions
102 // bool isActive() const;
104 // QDeclarativeStatePrivate *statePrivate() const;
106 // QDeclarativeStateGroup *stateGroup() const;
107 // QDeclarativeProperty createMetaProperty(const QString &property);
109 // QDeclarativeAction &qmlActionForProperty(const QString &propertyName) const;
110 // bool hasActionForProperty(const QString &propertyName) const;
111 // void removeActionForProperty(const QString &propertyName);
113 // QDeclarativeAction createQDeclarativeAction(const QString &propertyName);
115 //private: // variables
116 // QWeakPointer<QObject> m_targetObject;
117 // bool m_restoreEntryValues;
118 // bool m_isExplicit;
120 // mutable ActionList m_qmlActionList;
121 // QHash<QString, ExpressionPair> m_expressionHash;
124 class QmlPropertyChangesNodeInstance : public ObjectNodeInstance
127 typedef QSharedPointer<QmlPropertyChangesNodeInstance> Pointer;
128 typedef QWeakPointer<QmlPropertyChangesNodeInstance> WeakPointer;
130 static Pointer create(QObject *objectToBeWrapped);
132 virtual void setPropertyVariant(const QString &name, const QVariant &value);
133 virtual void setPropertyBinding(const QString &name, const QString &expression);
134 virtual QVariant property(const QString &name) const;
135 virtual void resetProperty(const QString &name);
137 void reparent(const ServerNodeInstance &oldParentInstance, const QString &oldParentProperty, const ServerNodeInstance &newParentInstance, const QString &newParentProperty);
140 QmlPropertyChangesNodeInstance(QDeclarativePropertyChanges *object);
141 QDeclarativePropertyChanges *changesObject() const;
144 } // namespace Internal
145 } // namespace QmlDesigner
147 //QML_DECLARE_TYPE(QmlDesigner::Internal::QmlPropertyChangesObject)
149 #endif // QMLPROPERTYCHANGESNODEINSTANCE_H