Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
// Qt-Security score:significant
4
5
#
ifndef
QQMLABSTRACTBINDING_P_H
6
#
define
QQMLABSTRACTBINDING_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtCore
/
qsharedpointer
.
h
>
20
#
include
<
QtCore
/
qshareddata
.
h
>
21
#
include
<
private
/
qtqmlglobal_p
.
h
>
22
#
include
<
private
/
qqmlproperty_p
.
h
>
23
24
QT_BEGIN_NAMESPACE
25
26
class
QQmlObjectCreator;
27
class
QQmlAnyBinding;
28
29
class
Q_QML_EXPORT
QQmlAbstractBinding
30
{
31
friend
class
QQmlAnyBinding;
32
protected
:
33
QQmlAbstractBinding();
34
public
:
35
enum
Kind {
36
ValueTypeProxy,
37
QmlBinding,
38
PropertyToPropertyBinding,
39
};
40
41
virtual
~QQmlAbstractBinding();
42
43
typedef
QExplicitlySharedDataPointer<QQmlAbstractBinding> Ptr;
44
45
virtual
QString expression()
const
;
46
47
virtual
Kind kind()
const
= 0;
48
49
// Should return the encoded property index for the binding. Should return this value
50
// even if the binding is not enabled or added to an object.
51
// Encoding is: coreIndex | (valueTypeIndex << 16)
52
QQmlPropertyIndex targetPropertyIndex()
const
{
return
m_targetIndex; }
53
54
void
remapTargetPropertyIndex(QQmlPropertyIndex index) { m_targetIndex = index; }
55
56
// Should return the object for the binding. Should return this object even if the
57
// binding is not enabled or added to the object.
58
QObject *targetObject()
const
{
return
m_target.data(); }
59
60
void
setTarget(
const
QQmlProperty &);
61
bool
setTarget(QObject *,
const
QQmlPropertyData &,
const
QQmlPropertyData *valueType);
62
bool
setTarget(QObject *,
int
coreIndex,
bool
coreIsAlias,
int
valueTypeIndex);
63
64
virtual
void
setEnabled(
bool
e, QQmlPropertyData::WriteFlags f = QQmlPropertyData::DontRemoveBinding) = 0;
65
66
void
addToObject();
67
void
removeFromObject();
68
69
virtual
void
printBindingLoopError(
const
QQmlProperty &prop);
70
71
inline
QQmlAbstractBinding *nextBinding()
const
;
72
73
inline
bool
canUseAccessor()
const
74
{
return
m_target.tag().testFlag(CanUseAccessor); }
75
void
setCanUseAccessor(
bool
canUseAccessor)
76
{ m_target.setTag(m_target.tag().setFlag(CanUseAccessor, canUseAccessor)); }
77
78
bool
isSticky()
const
{
return
m_target.tag().testFlag(IsSticky); }
79
void
setSticky(
bool
isSticky) { m_target.setTag(m_target.tag().setFlag(IsSticky, isSticky)); }
80
81
struct
RefCount {
82
RefCount() {}
83
int
refCount = 0;
84
void
ref() { ++refCount; }
85
int
deref() {
return
--refCount; }
86
operator
int
()
const
{
return
refCount; }
87
};
88
RefCount ref;
89
90
// A binding can only be enabled if it's added to an object,
91
// and it can only be updating if it's enabled.
92
enum
State {
93
Disabled = 0,
94
AddedToObject = 1,
95
BindingEnabled = 2,
96
UpdatingBinding = 3,
97
};
98
99
enum
TargetTag {
100
NoTargetTag = 0x0,
101
CanUseAccessor = 0x1,
102
IsSticky = 0x2,
103
};
104
Q_DECLARE_FLAGS(TargetTags, TargetTag)
105
106
protected
:
107
friend
class
QQmlData;
108
friend
class
QQmlValueTypeProxyBinding;
109
friend
class
QQmlObjectCreator;
110
111
inline
void
setAddedToObject(
bool
v);
112
inline
bool
isAddedToObject()
const
;
113
114
inline
void
setNextBinding(QQmlAbstractBinding *);
115
116
void
getPropertyData(
117
const
QQmlPropertyData **propertyData, QQmlPropertyData *valueTypeData)
const
;
118
119
inline
bool
updatingFlag()
const
;
120
inline
void
setUpdatingFlag(
bool
);
121
inline
bool
enabledFlag()
const
;
122
inline
void
setEnabledFlag(
bool
);
123
void
updateCanUseAccessor();
124
125
QQmlPropertyIndex m_targetIndex;
126
127
// Pointer is the target object to which the binding binds
128
QTaggedPointer<QObject, TargetTags> m_target;
129
130
// Pointer to the next binding in the linked list of bindings.
131
QTaggedPointer<QQmlAbstractBinding, State> m_nextBinding;
132
133
private
:
134
void
setState(State state,
bool
enabled)
135
{
136
if
(enabled) {
137
m_nextBinding.setTag(std::max(m_nextBinding.tag(), state));
138
return
;
139
}
140
141
Q_ASSERT(state > 0);
142
m_nextBinding.setTag(std::min(m_nextBinding.tag(), State(state - 1)));
143
}
144
145
bool
hasState(State state)
const
146
{
147
return
m_nextBinding.tag() >= state;
148
}
149
};
150
151
Q_DECLARE_OPERATORS_FOR_FLAGS(QQmlAbstractBinding::TargetTags)
152
153
void
QQmlAbstractBinding::setAddedToObject(
bool
v)
154
{
155
setState(AddedToObject, v);
156
}
157
158
bool
QQmlAbstractBinding::isAddedToObject()
const
159
{
160
return
hasState(AddedToObject);
161
}
162
163
QQmlAbstractBinding *QQmlAbstractBinding::nextBinding()
const
164
{
165
return
m_nextBinding.data();
166
}
167
168
void
QQmlAbstractBinding::setNextBinding(QQmlAbstractBinding *b)
169
{
170
if
(b)
171
b->ref.ref();
172
if
(m_nextBinding.data() && !m_nextBinding->ref.deref())
173
delete
m_nextBinding.data();
174
m_nextBinding = b;
175
}
176
177
bool
QQmlAbstractBinding::updatingFlag()
const
178
{
179
return
hasState(UpdatingBinding);
180
}
181
182
void
QQmlAbstractBinding::setUpdatingFlag(
bool
v)
183
{
184
setState(UpdatingBinding, v);
185
}
186
187
bool
QQmlAbstractBinding::enabledFlag()
const
188
{
189
return
hasState(BindingEnabled);
190
}
191
192
void
QQmlAbstractBinding::setEnabledFlag(
bool
v)
193
{
194
setState(BindingEnabled, v);
195
}
196
197
QT_END_NAMESPACE
198
199
#
endif
// QQMLABSTRACTBINDING_P_H
QQmlAbstractBinding
\inmodule QtQml
Definition
qqmlabstractbinding_p.h:30
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
getObjectPropertyData
static const QQmlPropertyData * getObjectPropertyData(QObject *object, int coreIndex)
Definition
qqmlabstractbinding.cpp:215
qtdeclarative
src
qml
qml
qqmlabstractbinding_p.h
Generated on
for Qt by
1.18.0