1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtQml module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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