source: trunk/src/declarative/qml/qdeclarativebinding_p.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 6.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 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** 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 qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QDECLARATIVEBINDING_P_H
43#define QDECLARATIVEBINDING_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 "qdeclarative.h"
57#include "qdeclarativepropertyvaluesource.h"
58#include "qdeclarativeexpression.h"
59#include "qdeclarativeproperty.h"
60#include "private/qdeclarativeproperty_p.h"
61
62#include <QtCore/QObject>
63#include <QtCore/QMetaProperty>
64
65QT_BEGIN_NAMESPACE
66
67class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAbstractBinding
68{
69public:
70 typedef QWeakPointer<QDeclarativeAbstractBinding> Pointer;
71
72 QDeclarativeAbstractBinding();
73
74 virtual void destroy();
75
76 virtual QString expression() const;
77
78 enum Type { PropertyBinding, ValueTypeProxy };
79 virtual Type bindingType() const { return PropertyBinding; }
80
81 QObject *object() const;
82 int propertyIndex() const;
83
84 void setEnabled(bool e) { setEnabled(e, QDeclarativePropertyPrivate::DontRemoveBinding); }
85 virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags) = 0;
86
87 void update() { update(QDeclarativePropertyPrivate::DontRemoveBinding); }
88 virtual void update(QDeclarativePropertyPrivate::WriteFlags) = 0;
89
90 void addToObject(QObject *, int);
91 void removeFromObject();
92
93 static Pointer getPointer(QDeclarativeAbstractBinding *p) { return p ? p->weakPointer() : Pointer(); }
94
95protected:
96 virtual ~QDeclarativeAbstractBinding();
97 void clear();
98
99private:
100 Pointer weakPointer();
101
102 friend class QDeclarativeData;
103 friend class QDeclarativeComponentPrivate;
104 friend class QDeclarativeValueTypeProxyBinding;
105 friend class QDeclarativePropertyPrivate;
106 friend class QDeclarativeVME;
107 friend class QtSharedPointer::ExternalRefCount<QDeclarativeAbstractBinding>;
108
109 QObject *m_object;
110 int m_propertyIndex;
111 QDeclarativeAbstractBinding **m_mePtr;
112 QDeclarativeAbstractBinding **m_prevBinding;
113 QDeclarativeAbstractBinding *m_nextBinding;
114 QSharedPointer<QDeclarativeAbstractBinding> m_selfPointer;
115};
116
117class QDeclarativeValueTypeProxyBinding : public QDeclarativeAbstractBinding
118{
119public:
120 QDeclarativeValueTypeProxyBinding(QObject *o, int coreIndex);
121
122 virtual Type bindingType() const { return ValueTypeProxy; }
123
124 virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags);
125 virtual void update(QDeclarativePropertyPrivate::WriteFlags);
126
127 QDeclarativeAbstractBinding *binding(int propertyIndex);
128
129 void removeBindings(quint32 mask);
130
131protected:
132 ~QDeclarativeValueTypeProxyBinding();
133
134private:
135 void recursiveEnable(QDeclarativeAbstractBinding *, QDeclarativePropertyPrivate::WriteFlags);
136 void recursiveDisable(QDeclarativeAbstractBinding *);
137
138 friend class QDeclarativeAbstractBinding;
139 QObject *m_object;
140 int m_index;
141 QDeclarativeAbstractBinding *m_bindings;
142};
143
144class QDeclarativeContext;
145class QDeclarativeBindingPrivate;
146class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeBinding : public QDeclarativeExpression, public QDeclarativeAbstractBinding
147{
148Q_OBJECT
149public:
150 QDeclarativeBinding(const QString &, QObject *, QDeclarativeContext *, QObject *parent=0);
151 QDeclarativeBinding(const QString &, QObject *, QDeclarativeContextData *, QObject *parent=0);
152 QDeclarativeBinding(void *, QDeclarativeRefCount *, QObject *, QDeclarativeContextData *,
153 const QString &, int, QObject *parent);
154
155 void setTarget(const QDeclarativeProperty &);
156 QDeclarativeProperty property() const;
157
158 bool enabled() const;
159
160 // Inherited from QDeclarativeAbstractBinding
161 virtual void setEnabled(bool, QDeclarativePropertyPrivate::WriteFlags flags);
162 virtual void update(QDeclarativePropertyPrivate::WriteFlags flags);
163 virtual QString expression() const;
164
165public Q_SLOTS:
166 void update() { update(QDeclarativePropertyPrivate::DontRemoveBinding); }
167
168protected:
169 ~QDeclarativeBinding();
170 void emitValueChanged();
171
172private:
173 Q_DECLARE_PRIVATE(QDeclarativeBinding)
174};
175
176QT_END_NAMESPACE
177
178Q_DECLARE_METATYPE(QDeclarativeBinding*)
179
180#endif // QDECLARATIVEBINDING_P_H
Note: See TracBrowser for help on using the repository browser.