Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmlabstractbinding_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLABSTRACTBINDING_P_H
5#define QQMLABSTRACTBINDING_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qsharedpointer.h>
19#include <QtCore/qshareddata.h>
20#include <private/qtqmlglobal_p.h>
21#include <private/qqmlproperty_p.h>
22
24
26class QQmlAnyBinding;
27
28class Q_QML_EXPORT QQmlAbstractBinding
29{
30 friend class QQmlAnyBinding;
31protected:
33public:
39
40 virtual ~QQmlAbstractBinding();
41
42 typedef QExplicitlySharedDataPointer<QQmlAbstractBinding> Ptr;
43
44 virtual QString expression() const;
45
46 virtual Kind kind() const = 0;
47
48 // Should return the encoded property index for the binding. Should return this value
49 // even if the binding is not enabled or added to an object.
50 // Encoding is: coreIndex | (valueTypeIndex << 16)
51 QQmlPropertyIndex targetPropertyIndex() const { return m_targetIndex; }
52
53 // Should return the object for the binding. Should return this object even if the
54 // binding is not enabled or added to the object.
55 QObject *targetObject() const { return m_target.data(); }
56
57 void setTarget(const QQmlProperty &);
58 bool setTarget(QObject *, const QQmlPropertyData &, const QQmlPropertyData *valueType);
59 bool setTarget(QObject *, int coreIndex, bool coreIsAlias, int valueTypeIndex);
60
61 virtual void setEnabled(bool e, QQmlPropertyData::WriteFlags f = QQmlPropertyData::DontRemoveBinding) = 0;
62
63 void addToObject();
64 void removeFromObject();
65
66 static void printBindingLoopError(const QQmlProperty &prop);
67
68 inline QQmlAbstractBinding *nextBinding() const;
69
70 inline bool canUseAccessor() const
71 { return m_nextBinding.tag().testFlag(CanUseAccessor); }
72 void setCanUseAccessor(bool canUseAccessor)
73 { m_nextBinding.setTag(m_nextBinding.tag().setFlag(CanUseAccessor, canUseAccessor)); }
74
75 struct RefCount {
77 int refCount = 0;
78 void ref() { ++refCount; }
79 int deref() { return --refCount; }
80 operator int() const { return refCount; }
81 };
83
84 enum TargetTag {
85 NoTargetTag = 0x0,
86 UpdatingBinding = 0x1,
87 BindingEnabled = 0x2
88 };
89 Q_DECLARE_FLAGS(TargetTags, TargetTag)
90
92 NoBindingTag = 0x0,
93 AddedToObject = 0x1,
94 CanUseAccessor = 0x2
95 };
96 Q_DECLARE_FLAGS(NextBindingTags, NextBindingTag)
97
98protected:
99 friend class QQmlData;
101 friend class QQmlObjectCreator;
102
103 inline void setAddedToObject(bool v);
104 inline bool isAddedToObject() const;
105
106 inline void setNextBinding(QQmlAbstractBinding *);
107
108 void getPropertyData(
109 const QQmlPropertyData **propertyData, QQmlPropertyData *valueTypeData) const;
110
111 inline bool updatingFlag() const;
112 inline void setUpdatingFlag(bool);
113 inline bool enabledFlag() const;
114 inline void setEnabledFlag(bool);
115 void updateCanUseAccessor();
116
118
119 // Pointer is the target object to which the binding binds
120 QTaggedPointer<QObject, TargetTags> m_target;
121
122 // Pointer to the next binding in the linked list of bindings.
123 QTaggedPointer<QQmlAbstractBinding, NextBindingTags> m_nextBinding;
124};
125
126Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlAbstractBinding::TargetTags)
127Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlAbstractBinding::NextBindingTags)
128
129void QQmlAbstractBinding::setAddedToObject(bool v)
130{
131 m_nextBinding.setTag(m_nextBinding.tag().setFlag(AddedToObject, v));
132}
133
135{
136 return m_nextBinding.tag().testFlag(AddedToObject);
137}
138
143
152
154{
155 return m_target.tag().testFlag(UpdatingBinding);
156}
157
162
164{
165 return m_target.tag().testFlag(BindingEnabled);
166}
167
172
174
175#endif // QQMLABSTRACTBINDING_P_H
\inmodule QtCore
Definition qobject.h:103
QQmlPropertyIndex targetPropertyIndex() const
QExplicitlySharedDataPointer< QQmlAbstractBinding > Ptr
QTaggedPointer< QQmlAbstractBinding, NextBindingTags > m_nextBinding
void setCanUseAccessor(bool canUseAccessor)
QQmlPropertyIndex m_targetIndex
void setNextBinding(QQmlAbstractBinding *)
QQmlAbstractBinding * nextBinding() const
QTaggedPointer< QObject, TargetTags > m_target
QObject * targetObject() const
virtual void setEnabled(bool e, QQmlPropertyData::WriteFlags f=QQmlPropertyData::DontRemoveBinding)=0
virtual Kind kind() const =0
QQmlAnyBinding is an abstraction over the various bindings in QML.
The QQmlProperty class abstracts accessing properties on objects created from QML.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
T * data() const noexcept
void setTag(Tag tag)
Tag tag() const noexcept
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLfloat GLfloat f