Add missing QT_{BEGIN,END}_NAMESPACE
[profile/ivi/qtdeclarative.git] / src / qml / qml / qqmlproperty_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtQml module of the Qt Toolkit.
7 **
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.
16 **
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.
20 **
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.
28 **
29 ** Other Usage
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.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QQMLPROPERTY_P_H
43 #define QQMLPROPERTY_P_H
44
45 //
46 //  W A R N I N G
47 //  -------------
48 //
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.
52 //
53 // We mean it.
54 //
55
56 #include "qqmlproperty.h"
57 #include "qqmlengine.h"
58
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>
64
65 QT_BEGIN_NAMESPACE
66
67 class QQmlContext;
68 class QQmlEnginePrivate;
69 class QQmlJavaScriptExpression;
70 class Q_QML_PRIVATE_EXPORT QQmlPropertyPrivate : public QQmlRefCount
71 {
72 public:
73     enum WriteFlag {
74         BypassInterceptor = 0x01,
75         DontRemoveBinding = 0x02,
76         RemoveBindingOnAliasWrite = 0x04
77     };
78     Q_DECLARE_FLAGS(WriteFlags, WriteFlag)
79
80     QQmlContextData *context;
81     QQmlGuard<QQmlEngine> engine;
82     QQmlGuard<QObject> object;
83
84     QQmlPropertyData core;
85
86     bool isNameCached:1;
87     QString nameCache;
88
89     QQmlPropertyPrivate();
90
91     inline QQmlContextData *effectiveContext() const;
92
93     void initProperty(QObject *obj, const QString &name);
94     void initDefault(QObject *obj);
95
96     bool isValueType() const;
97     int propertyType() const;
98     QQmlProperty::Type type() const;
99     QQmlProperty::PropertyTypeCategory propertyTypeCategory() const;
100
101     QVariant readValueProperty();
102     bool writeValueProperty(const QVariant &, WriteFlags);
103
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 *);
114
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 */);
126
127     static QQmlPropertyData saveValueType(const QQmlPropertyData &,
128                                           const QMetaObject *, int,
129                                           QQmlEngine *);
130     static QQmlProperty restore(QObject *,
131                                         const QQmlPropertyData &,
132                                         QQmlContextData *);
133
134     int signalIndex() const;
135
136     static inline QQmlPropertyPrivate *get(const QQmlProperty &p) {
137         return p.d;
138     }
139
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,
155                              WriteFlags flags);
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);
164 };
165
166 Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlPropertyPrivate::WriteFlags)
167
168 QT_END_NAMESPACE
169
170 #endif // QQMLPROPERTY_P_H