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 | #include "qqmlvaluetypeproxybinding_p.h" |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | QQmlValueTypeProxyBinding::QQmlValueTypeProxyBinding(QObject *o, QQmlPropertyIndex index) |
9 | : QQmlAbstractBinding(), |
10 | m_bindings(nullptr) |
11 | { |
12 | m_target = o; |
13 | m_targetIndex = index; |
14 | } |
15 | |
16 | QQmlValueTypeProxyBinding::~QQmlValueTypeProxyBinding() |
17 | { |
18 | QQmlAbstractBinding *binding = m_bindings.data(); |
19 | while (binding) { |
20 | binding->setAddedToObject(false); |
21 | binding = binding->nextBinding(); |
22 | } |
23 | } |
24 | |
25 | void QQmlValueTypeProxyBinding::setEnabled(bool e, QQmlPropertyData::WriteFlags flags) |
26 | { |
27 | QQmlAbstractBinding *b = m_bindings.data(); |
28 | while (b) { |
29 | b->setEnabled(e, f: flags); |
30 | b = b->nextBinding(); |
31 | } |
32 | } |
33 | |
34 | QQmlAbstractBinding *QQmlValueTypeProxyBinding::subBindings() const |
35 | { |
36 | return m_bindings.data(); |
37 | } |
38 | |
39 | QQmlAbstractBinding *QQmlValueTypeProxyBinding::binding(QQmlPropertyIndex propertyIndex) const |
40 | { |
41 | QQmlAbstractBinding *binding = m_bindings.data(); |
42 | |
43 | while (binding && binding->targetPropertyIndex() != propertyIndex) |
44 | binding = binding->nextBinding(); |
45 | |
46 | return binding; |
47 | } |
48 | |
49 | /*! |
50 | Removes a collection of bindings, corresponding to the set bits in \a mask. |
51 | */ |
52 | void QQmlValueTypeProxyBinding::removeBindings(quint32 mask) |
53 | { |
54 | QQmlAbstractBinding *binding = m_bindings.data(); |
55 | QQmlAbstractBinding *lastBinding = nullptr; |
56 | |
57 | while (binding) { |
58 | const int valueTypeIndex = binding->targetPropertyIndex().valueTypeIndex(); |
59 | if (valueTypeIndex != -1 && (mask & (1 << valueTypeIndex))) { |
60 | QQmlAbstractBinding *remove = binding; |
61 | remove->setAddedToObject(false); |
62 | binding = remove->nextBinding(); |
63 | |
64 | if (lastBinding == nullptr) |
65 | m_bindings = remove->nextBinding(); |
66 | else |
67 | lastBinding->setNextBinding(remove->nextBinding()); |
68 | } else { |
69 | lastBinding = binding; |
70 | binding = binding->nextBinding(); |
71 | } |
72 | } |
73 | } |
74 | |
75 | QT_END_NAMESPACE |
76 |