| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtDeclarative module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 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 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 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/qobject_p.h>
|
|---|
| 59 | #include <private/qdeclarativeglobal_p.h>
|
|---|
| 60 | #include <private/qdeclarativepropertycache_p.h>
|
|---|
| 61 | #include <private/qdeclarativeguard_p.h>
|
|---|
| 62 |
|
|---|
| 63 | QT_BEGIN_NAMESPACE
|
|---|
| 64 |
|
|---|
| 65 | class QDeclarativeContext;
|
|---|
| 66 | class QDeclarativeEnginePrivate;
|
|---|
| 67 | class QDeclarativeExpression;
|
|---|
| 68 | class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativePropertyPrivate
|
|---|
| 69 | {
|
|---|
| 70 | public:
|
|---|
| 71 | enum WriteFlag { BypassInterceptor = 0x01, DontRemoveBinding = 0x02, RemoveBindingOnAliasWrite = 0x04 };
|
|---|
| 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 void findAliasTarget(QObject *, int, QObject **, int *);
|
|---|
| 112 | static QDeclarativeAbstractBinding *setBinding(QObject *, int coreIndex, int valueTypeIndex /* -1 */,
|
|---|
| 113 | QDeclarativeAbstractBinding *,
|
|---|
| 114 | WriteFlags flags = DontRemoveBinding);
|
|---|
| 115 | static QDeclarativeAbstractBinding *setBindingNoEnable(QObject *, int coreIndex, int valueTypeIndex /* -1 */,
|
|---|
| 116 | QDeclarativeAbstractBinding *);
|
|---|
| 117 | static QDeclarativeAbstractBinding *binding(QObject *, int coreIndex, int valueTypeIndex /* -1 */);
|
|---|
| 118 |
|
|---|
| 119 | static QByteArray saveValueType(const QMetaObject *, int,
|
|---|
| 120 | const QMetaObject *, int);
|
|---|
| 121 | static QByteArray saveProperty(const QMetaObject *, int);
|
|---|
| 122 | static QDeclarativeProperty restore(const QByteArray &, QObject *, QDeclarativeContextData *);
|
|---|
| 123 |
|
|---|
| 124 | static bool equal(const QMetaObject *, const QMetaObject *);
|
|---|
| 125 | static bool canConvert(const QMetaObject *from, const QMetaObject *to);
|
|---|
| 126 |
|
|---|
| 127 | // "Public" (to QML) methods
|
|---|
| 128 | static QDeclarativeAbstractBinding *binding(const QDeclarativeProperty &that);
|
|---|
| 129 | static QDeclarativeAbstractBinding *setBinding(const QDeclarativeProperty &that,
|
|---|
| 130 | QDeclarativeAbstractBinding *,
|
|---|
| 131 | WriteFlags flags = DontRemoveBinding);
|
|---|
| 132 | static QDeclarativeExpression *signalExpression(const QDeclarativeProperty &that);
|
|---|
| 133 | static QDeclarativeExpression *setSignalExpression(const QDeclarativeProperty &that,
|
|---|
| 134 | QDeclarativeExpression *) ;
|
|---|
| 135 | static bool write(const QDeclarativeProperty &that, const QVariant &, WriteFlags);
|
|---|
| 136 | static int valueTypeCoreIndex(const QDeclarativeProperty &that);
|
|---|
| 137 | static int bindingIndex(const QDeclarativeProperty &that);
|
|---|
| 138 | static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &);
|
|---|
| 139 | static bool connect(const QObject *sender, int signal_index,
|
|---|
| 140 | const QObject *receiver, int method_index,
|
|---|
| 141 | int type = 0, int *types = 0);
|
|---|
| 142 | static const QMetaObject *metaObjectForProperty(const QMetaObject *, int);
|
|---|
| 143 | };
|
|---|
| 144 |
|
|---|
| 145 | Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyPrivate::WriteFlags)
|
|---|
| 146 |
|
|---|
| 147 | QT_END_NAMESPACE
|
|---|
| 148 |
|
|---|
| 149 | #endif // QDECLARATIVEPROPERTY_P_H
|
|---|