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"
58 #include <private/qobject_p.h>
59 #include <private/qtqmlglobal_p.h>
60 #include <private/qqmlpropertycache_p.h>
61 #include <private/qqmlguard_p.h>
67 class QQmlEnginePrivate;
68 class QQmlJavaScriptExpression;
69 class Q_QML_PRIVATE_EXPORT QQmlPropertyPrivate : public QQmlRefCount
73 BypassInterceptor = 0x01,
74 DontRemoveBinding = 0x02,
75 RemoveBindingOnAliasWrite = 0x04
77 Q_DECLARE_FLAGS(WriteFlags, WriteFlag)
79 QQmlContextData *context;
81 QQmlGuard<QObject> object;
83 QQmlPropertyData core;
88 QQmlPropertyPrivate();
90 inline QQmlContextData *effectiveContext() const;
92 void initProperty(QObject *obj, const QString &name);
93 void initDefault(QObject *obj);
95 bool isValueType() const;
96 int propertyType() const;
97 QQmlProperty::Type type() const;
98 QQmlProperty::PropertyTypeCategory propertyTypeCategory() const;
100 QVariant readValueProperty();
101 bool writeValueProperty(const QVariant &, WriteFlags);
103 static const QMetaObject *rawMetaObjectForType(QQmlEnginePrivate *, int);
104 static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object,
105 const QVariant &value, int flags);
106 static bool writeValueProperty(QObject *, QQmlEngine *,
107 const QQmlPropertyData &,
108 const QVariant &, QQmlContextData *,
109 WriteFlags flags = 0);
110 static bool write(QObject *, const QQmlPropertyData &, const QVariant &,
111 QQmlContextData *, WriteFlags flags = 0);
112 static void findAliasTarget(QObject *, int, QObject **, int *);
114 static QQmlAbstractBinding *setBinding(QObject *, int coreIndex,
115 int valueTypeIndex /* -1 */,
116 QQmlAbstractBinding *,
117 WriteFlags flags = DontRemoveBinding);
118 static QQmlAbstractBinding *setBindingNoEnable(QObject *, int coreIndex,
119 int valueTypeIndex /* -1 */,
120 QQmlAbstractBinding *);
121 static QQmlAbstractBinding *binding(QObject *, int coreIndex,
122 int valueTypeIndex /* -1 */);
124 static QQmlPropertyData saveValueType(const QMetaObject *, int,
125 const QMetaObject *, int,
127 static QQmlProperty restore(QObject *,
128 const QQmlPropertyData &,
131 static bool equal(const QMetaObject *, const QMetaObject *);
132 static bool canConvert(const QMetaObject *from, const QMetaObject *to);
133 static inline QQmlPropertyPrivate *get(const QQmlProperty &p) {
137 // "Public" (to QML) methods
138 static QQmlAbstractBinding *binding(const QQmlProperty &that);
139 static QQmlAbstractBinding *setBinding(const QQmlProperty &that,
140 QQmlAbstractBinding *,
141 WriteFlags flags = DontRemoveBinding);
142 static QQmlExpression *signalExpression(const QQmlProperty &that);
143 static QQmlExpression *setSignalExpression(const QQmlProperty &that,
145 static bool write(const QQmlProperty &that, const QVariant &, WriteFlags);
146 static bool writeBinding(const QQmlProperty &that,
147 QQmlContextData *context,
148 QQmlJavaScriptExpression *expression,
149 v8::Handle<v8::Value> result, bool isUndefined,
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 const QMetaObject *metaObjectForProperty(const QMetaObject *, int);
164 static void flushSignal(const QObject *sender, int signal_index);
167 Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlPropertyPrivate::WriteFlags)
171 #endif // QQMLPROPERTY_P_H