|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtDeclarative module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QDECLARATIVEPROPERTY_P_H |
|
43 #define QDECLARATIVEPROPERTY_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 "qdeclarativeproperty.h" |
|
57 |
|
58 #include "private/qdeclarativepropertycache_p.h" |
|
59 #include "private/qdeclarativeguard_p.h" |
|
60 |
|
61 #include <private/qobject_p.h> |
|
62 |
|
63 QT_BEGIN_NAMESPACE |
|
64 |
|
65 class QDeclarativeContext; |
|
66 class QDeclarativeEnginePrivate; |
|
67 class QDeclarativeExpression; |
|
68 class Q_DECLARATIVE_EXPORT QDeclarativePropertyPrivate |
|
69 { |
|
70 public: |
|
71 enum WriteFlag { BypassInterceptor = 0x01, DontRemoveBinding = 0x02 }; |
|
72 Q_DECLARE_FLAGS(WriteFlags, WriteFlag) |
|
73 |
|
74 QDeclarativePropertyPrivate() |
|
75 : q(0), context(0), engine(0), object(0), isNameCached(false) {} |
|
76 |
|
77 |
|
78 QDeclarativePropertyPrivate(const QDeclarativePropertyPrivate &other) |
|
79 : q(0), context(other.context), engine(other.engine), object(other.object), |
|
80 isNameCached(other.isNameCached), |
|
81 core(other.core), nameCache(other.nameCache), |
|
82 valueType(other.valueType) {} |
|
83 |
|
84 QDeclarativeProperty *q; |
|
85 QDeclarativeContextData *context; |
|
86 QDeclarativeEngine *engine; |
|
87 QDeclarativeGuard<QObject> object; |
|
88 |
|
89 bool isNameCached:1; |
|
90 QDeclarativePropertyCache::Data core; |
|
91 QString nameCache; |
|
92 |
|
93 // Describes the "virtual" value-type sub-property. |
|
94 QDeclarativePropertyCache::ValueTypeData valueType; |
|
95 |
|
96 void initProperty(QObject *obj, const QString &name); |
|
97 void initDefault(QObject *obj); |
|
98 |
|
99 bool isValueType() const; |
|
100 int propertyType() const; |
|
101 QDeclarativeProperty::PropertyTypeCategory propertyTypeCategory() const; |
|
102 |
|
103 QVariant readValueProperty(); |
|
104 bool writeValueProperty(const QVariant &, WriteFlags); |
|
105 |
|
106 static const QMetaObject *rawMetaObjectForType(QDeclarativeEnginePrivate *, int); |
|
107 static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object, |
|
108 const QVariant &value, int flags); |
|
109 static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, |
|
110 QDeclarativeContextData *, WriteFlags flags = 0); |
|
111 static QDeclarativeAbstractBinding *setBinding(QObject *, int coreIndex, int valueTypeIndex /* -1 */, |
|
112 QDeclarativeAbstractBinding *, |
|
113 WriteFlags flags = DontRemoveBinding); |
|
114 |
|
115 static QByteArray saveValueType(const QMetaObject *, int, |
|
116 const QMetaObject *, int); |
|
117 static QByteArray saveProperty(const QMetaObject *, int); |
|
118 static QDeclarativeProperty restore(const QByteArray &, QObject *, QDeclarativeContextData *); |
|
119 |
|
120 static bool equal(const QMetaObject *, const QMetaObject *); |
|
121 static bool canConvert(const QMetaObject *from, const QMetaObject *to); |
|
122 |
|
123 |
|
124 // "Public" (to QML) methods |
|
125 static QDeclarativeAbstractBinding *binding(const QDeclarativeProperty &that); |
|
126 static QDeclarativeAbstractBinding *setBinding(const QDeclarativeProperty &that, |
|
127 QDeclarativeAbstractBinding *, |
|
128 WriteFlags flags = DontRemoveBinding); |
|
129 static QDeclarativeExpression *signalExpression(const QDeclarativeProperty &that); |
|
130 static QDeclarativeExpression *setSignalExpression(const QDeclarativeProperty &that, |
|
131 QDeclarativeExpression *) ; |
|
132 static bool write(const QDeclarativeProperty &that, const QVariant &, WriteFlags); |
|
133 static int valueTypeCoreIndex(const QDeclarativeProperty &that); |
|
134 static int bindingIndex(const QDeclarativeProperty &that); |
|
135 static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &); |
|
136 }; |
|
137 |
|
138 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyPrivate::WriteFlags) |
|
139 |
|
140 QT_END_NAMESPACE |
|
141 |
|
142 #endif // QDECLARATIVEPROPERTY_P_H |