1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtQml module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QQMLPROPERTY_P_H
43 #define QQMLPROPERTY_P_H
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
56 #include "qqmlproperty.h"
57 #include "qqmlengine.h"
59 #include <private/qobject_p.h>
60 #include <private/qtqmlglobal_p.h>
61 #include <private/qqmlpropertycache_p.h>
62 #include <private/qqmlguard_p.h>
63 #include <private/qqmlboundsignalexpressionpointer_p.h>
68 class QQmlEnginePrivate;
69 class QQmlJavaScriptExpression;
70 class Q_QML_PRIVATE_EXPORT QQmlPropertyPrivate : public QQmlRefCount
74 BypassInterceptor = 0x01,
75 DontRemoveBinding = 0x02,
76 RemoveBindingOnAliasWrite = 0x04
78 Q_DECLARE_FLAGS(WriteFlags, WriteFlag)
80 QQmlContextData *context;
81 QQmlGuard<QQmlEngine> engine;
82 QQmlGuard<QObject> object;
84 QQmlPropertyData core;
89 QQmlPropertyPrivate();
91 inline QQmlContextData *effectiveContext() const;
93 void initProperty(QObject *obj, const QString &name);
94 void initDefault(QObject *obj);
96 bool isValueType() const;
97 int propertyType() const;
98 QQmlProperty::Type type() const;
99 QQmlProperty::PropertyTypeCategory propertyTypeCategory() const;
101 QVariant readValueProperty();
102 bool writeValueProperty(const QVariant &, WriteFlags);
104 static QQmlMetaObject rawMetaObjectForType(QQmlEnginePrivate *, int);
105 static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object,
106 const QVariant &value, int flags);
107 static bool writeValueProperty(QObject *,
108 const QQmlPropertyData &,
109 const QVariant &, QQmlContextData *,
110 WriteFlags flags = 0);
111 static bool write(QObject *, const QQmlPropertyData &, const QVariant &,
112 QQmlContextData *, WriteFlags flags = 0);
113 static void findAliasTarget(QObject *, int, QObject **, int *);
115 static QQmlAbstractBinding *setBinding(QObject *, int coreIndex,
116 int valueTypeIndex /* -1 */,
117 QQmlAbstractBinding *,
118 WriteFlags flags = DontRemoveBinding);
119 static QQmlAbstractBinding *setBindingNoEnable(QObject *, int coreIndex,
120 int valueTypeIndex /* -1 */,
121 QQmlAbstractBinding *);
122 static QQmlAbstractBinding *activateSharedBinding(QQmlContextData *context,
123 int sharedIdx, WriteFlags flags);
124 static QQmlAbstractBinding *binding(QObject *, int coreIndex,
125 int valueTypeIndex /* -1 */);
127 static QQmlPropertyData saveValueType(const QQmlPropertyData &,
128 const QMetaObject *, int,
130 static QQmlProperty restore(QObject *,
131 const QQmlPropertyData &,
134 int signalIndex() const;
136 static inline QQmlPropertyPrivate *get(const QQmlProperty &p) {
140 // "Public" (to QML) methods
141 static QQmlAbstractBinding *binding(const QQmlProperty &that);
142 static QQmlAbstractBinding *setBinding(const QQmlProperty &that,
143 QQmlAbstractBinding *,
144 WriteFlags flags = DontRemoveBinding);
145 static QQmlBoundSignalExpression *signalExpression(const QQmlProperty &that);
146 static QQmlBoundSignalExpressionPointer setSignalExpression(const QQmlProperty &that,
147 QQmlBoundSignalExpression *);
148 static QQmlBoundSignalExpressionPointer takeSignalExpression(const QQmlProperty &that,
149 QQmlBoundSignalExpression *);
150 static bool write(const QQmlProperty &that, const QVariant &, WriteFlags);
151 static bool writeBinding(QObject *, const QQmlPropertyData &,
152 QQmlContextData *context,
153 QQmlJavaScriptExpression *expression,
154 v8::Handle<v8::Value> result, bool isUndefined,
156 static int valueTypeCoreIndex(const QQmlProperty &that);
157 static int bindingIndex(const QQmlProperty &that);
158 static int bindingIndex(const QQmlPropertyData &that);
159 static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &);
160 static bool connect(const QObject *sender, int signal_index,
161 const QObject *receiver, int method_index,
162 int type = 0, int *types = 0);
163 static void flushSignal(const QObject *sender, int signal_index);
166 Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlPropertyPrivate::WriteFlags)
170 #endif // QQMLPROPERTY_P_H