1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
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
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #ifndef QDECLARATIVEPROPERTY_P_H
43 #define QDECLARATIVEPROPERTY_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 "qdeclarativeproperty.h"
58 #include <private/qobject_p.h>
59 #include <private/qdeclarativeglobal_p.h>
60 #include <private/qdeclarativepropertycache_p.h>
61 #include <private/qdeclarativeguard_p.h>
65 class QDeclarativeContext;
66 class QDeclarativeEnginePrivate;
67 class QDeclarativeExpression;
68 class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativePropertyPrivate : public QDeclarativeRefCount
71 enum WriteFlag { BypassInterceptor = 0x01, DontRemoveBinding = 0x02, RemoveBindingOnAliasWrite = 0x04 };
72 Q_DECLARE_FLAGS(WriteFlags, WriteFlag)
74 QDeclarativePropertyPrivate()
75 : context(0), engine(0), object(0), isNameCached(false) {}
77 QDeclarativeContextData *context;
78 QDeclarativeEngine *engine;
79 QDeclarativeGuard<QObject> object;
82 QDeclarativePropertyCache::Data core;
85 // Describes the "virtual" value-type sub-property.
86 QDeclarativePropertyCache::ValueTypeData valueType;
88 void initProperty(QObject *obj, const QString &name);
89 void initDefault(QObject *obj);
91 bool isValueType() const;
92 int propertyType() const;
93 QDeclarativeProperty::Type type() const;
94 QDeclarativeProperty::PropertyTypeCategory propertyTypeCategory() const;
96 QVariant readValueProperty();
97 bool writeValueProperty(const QVariant &, WriteFlags);
99 static const QMetaObject *rawMetaObjectForType(QDeclarativeEnginePrivate *, int);
100 static bool writeEnumProperty(const QMetaProperty &prop, int idx, QObject *object,
101 const QVariant &value, int flags);
102 static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &,
103 QDeclarativeContextData *, WriteFlags flags = 0);
104 static void findAliasTarget(QObject *, int, QObject **, int *);
105 static QDeclarativeAbstractBinding *setBinding(QObject *, int coreIndex, int valueTypeIndex /* -1 */,
106 QDeclarativeAbstractBinding *,
107 WriteFlags flags = DontRemoveBinding);
108 static QDeclarativeAbstractBinding *setBindingNoEnable(QObject *, int coreIndex, int valueTypeIndex /* -1 */,
109 QDeclarativeAbstractBinding *);
110 static QDeclarativeAbstractBinding *binding(QObject *, int coreIndex, int valueTypeIndex /* -1 */);
112 static QByteArray saveValueType(const QMetaObject *, int,
113 const QMetaObject *, int);
114 static QByteArray saveProperty(const QMetaObject *, int);
116 static QDeclarativeProperty restore(const QByteArray &, QObject *, QDeclarativeContextData *);
117 static QDeclarativeProperty restore(const QDeclarativePropertyCache::Data &,
118 const QDeclarativePropertyCache::ValueTypeData &,
120 QDeclarativeContextData *);
122 static bool equal(const QMetaObject *, const QMetaObject *);
123 static bool canConvert(const QMetaObject *from, const QMetaObject *to);
125 // "Public" (to QML) methods
126 static QDeclarativeAbstractBinding *binding(const QDeclarativeProperty &that);
127 static QDeclarativeAbstractBinding *setBinding(const QDeclarativeProperty &that,
128 QDeclarativeAbstractBinding *,
129 WriteFlags flags = DontRemoveBinding);
130 static QDeclarativeExpression *signalExpression(const QDeclarativeProperty &that);
131 static QDeclarativeExpression *setSignalExpression(const QDeclarativeProperty &that,
132 QDeclarativeExpression *) ;
133 static bool write(const QDeclarativeProperty &that, const QVariant &, WriteFlags);
134 static int valueTypeCoreIndex(const QDeclarativeProperty &that);
135 static int bindingIndex(const QDeclarativeProperty &that);
136 static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &);
137 static bool connect(const QObject *sender, int signal_index,
138 const QObject *receiver, int method_index,
139 int type = 0, int *types = 0);
140 static const QMetaObject *metaObjectForProperty(const QMetaObject *, int);
143 Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyPrivate::WriteFlags)
147 #endif // QDECLARATIVEPROPERTY_P_H