1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtQml module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "qqmlvaluetypeproxybinding_p.h"
46 // Used in qqmlabstractbinding.cpp
47 QQmlAbstractBinding::VTable QQmlValueTypeProxyBinding_vtable = {
48 QQmlAbstractBinding::default_destroy<QQmlValueTypeProxyBinding>,
49 QQmlAbstractBinding::default_expression,
50 QQmlValueTypeProxyBinding::propertyIndex,
51 QQmlValueTypeProxyBinding::object,
52 QQmlValueTypeProxyBinding::setEnabled,
53 QQmlValueTypeProxyBinding::update,
54 QQmlAbstractBinding::default_retargetBinding
57 QQmlValueTypeProxyBinding::QQmlValueTypeProxyBinding(QObject *o, int index)
58 : QQmlAbstractBinding(ValueTypeProxy), m_object(o), m_index(index), m_bindings(0)
62 QQmlValueTypeProxyBinding::~QQmlValueTypeProxyBinding()
64 QQmlAbstractBinding *binding = m_bindings;
65 // This must be identical to the logic in QQmlData::destroyed()
67 QQmlAbstractBinding *next = binding->nextBinding();
68 binding->setAddedToObject(false);
69 binding->setNextBinding(0);
75 void QQmlValueTypeProxyBinding::setEnabled(QQmlAbstractBinding *_This,
76 bool e, QQmlPropertyPrivate::WriteFlags flags)
78 QQmlValueTypeProxyBinding *This = static_cast<QQmlValueTypeProxyBinding *>(_This);
81 QQmlAbstractBinding *bindings = This->m_bindings;
82 This->recursiveEnable(bindings, flags);
84 QQmlAbstractBinding *bindings = This->m_bindings;
85 This->recursiveDisable(bindings);
89 void QQmlValueTypeProxyBinding::recursiveEnable(QQmlAbstractBinding *b, QQmlPropertyPrivate::WriteFlags flags)
94 recursiveEnable(b->nextBinding(), flags);
97 b->setEnabled(true, flags);
100 void QQmlValueTypeProxyBinding::recursiveDisable(QQmlAbstractBinding *b)
105 recursiveDisable(b->nextBinding());
108 b->setEnabled(false, 0);
111 void QQmlValueTypeProxyBinding::update(QQmlAbstractBinding *, QQmlPropertyPrivate::WriteFlags)
115 QQmlAbstractBinding *QQmlValueTypeProxyBinding::binding(int propertyIndex)
117 QQmlAbstractBinding *binding = m_bindings;
119 while (binding && binding->propertyIndex() != propertyIndex)
120 binding = binding->nextBinding();
126 Removes a collection of bindings, corresponding to the set bits in \a mask.
128 void QQmlValueTypeProxyBinding::removeBindings(quint32 mask)
130 QQmlAbstractBinding *binding = m_bindings;
131 QQmlAbstractBinding *lastBinding = 0;
134 if (mask & (1 << (binding->propertyIndex() >> 24))) {
135 QQmlAbstractBinding *remove = binding;
136 binding = remove->nextBinding();
138 if (lastBinding == 0)
139 m_bindings = remove->nextBinding();
141 lastBinding->setNextBinding(remove->nextBinding());
143 remove->setAddedToObject(false);
144 remove->setNextBinding(0);
147 lastBinding = binding;
148 binding = binding->nextBinding();
153 int QQmlValueTypeProxyBinding::propertyIndex(const QQmlAbstractBinding *This)
155 return static_cast<const QQmlValueTypeProxyBinding *>(This)->m_index;
158 QObject *QQmlValueTypeProxyBinding::object(const QQmlAbstractBinding *This)
160 return static_cast<const QQmlValueTypeProxyBinding *>(This)->m_object;
163 int QQmlValueTypeProxyBinding::propertyIndex() const
168 QObject *QQmlValueTypeProxyBinding::object() const