aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlbinding.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2012-03-08 14:25:50 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-13 05:13:50 +0100
commit5013d53d9400f61699f8edb1dc20f06e19a26a3d (patch)
tree6f6e9284f8843aaa89f2d38aca066170192172bb /src/qml/qml/qqmlbinding.cpp
parent648c80c4c0759efb6e35fac7acc8daad5aab13e2 (diff)
Move binding and expression classes to separate files
Change-Id: Ia9c6996a606e140f31681ecd26d93b1b0fdedf02 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlbinding.cpp')
-rw-r--r--src/qml/qml/qqmlbinding.cpp235
1 files changed, 0 insertions, 235 deletions
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index bb6eb3b723..23f5abf5fd 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -55,149 +55,6 @@
QT_BEGIN_NAMESPACE
-QQmlAbstractBinding::QQmlAbstractBinding()
-: m_prevBinding(0), m_nextBinding(0)
-{
-}
-
-QQmlAbstractBinding::~QQmlAbstractBinding()
-{
- Q_ASSERT(m_prevBinding == 0);
- Q_ASSERT(*m_mePtr == 0);
-}
-
-/*!
-Destroy the binding. Use this instead of calling delete.
-
-Bindings are free to implement their own memory management, so the delete operator is not
-necessarily safe. The default implementation clears the binding, removes it from the object
-and calls delete.
-*/
-void QQmlAbstractBinding::destroy()
-{
- removeFromObject();
- clear();
-
- delete this;
-}
-
-/*!
-Add this binding to \a object.
-
-This transfers ownership of the binding to the object, marks the object's property as
-being bound.
-
-However, it does not enable the binding itself or call update() on it.
-*/
-void QQmlAbstractBinding::addToObject()
-{
- Q_ASSERT(!m_prevBinding);
-
- QObject *obj = object();
- Q_ASSERT(obj);
-
- int index = propertyIndex();
-
- QQmlData *data = QQmlData::get(obj, true);
-
- if (index & 0xFF000000) {
- // Value type
-
- int coreIndex = index & 0xFFFFFF;
-
- // Find the value type proxy (if there is one)
- QQmlValueTypeProxyBinding *proxy = 0;
- if (data->hasBindingBit(coreIndex)) {
- QQmlAbstractBinding *b = data->bindings;
- while (b && b->propertyIndex() != coreIndex)
- b = b->m_nextBinding;
- Q_ASSERT(b && b->bindingType() == QQmlAbstractBinding::ValueTypeProxy);
- proxy = static_cast<QQmlValueTypeProxyBinding *>(b);
- }
-
- if (!proxy) {
- proxy = new QQmlValueTypeProxyBinding(obj, coreIndex);
-
- Q_ASSERT(proxy->propertyIndex() == coreIndex);
- Q_ASSERT(proxy->object() == obj);
-
- proxy->addToObject();
- }
-
- m_nextBinding = proxy->m_bindings;
- if (m_nextBinding) m_nextBinding->m_prevBinding = &m_nextBinding;
- m_prevBinding = &proxy->m_bindings;
- proxy->m_bindings = this;
-
- } else {
- m_nextBinding = data->bindings;
- if (m_nextBinding) m_nextBinding->m_prevBinding = &m_nextBinding;
- m_prevBinding = &data->bindings;
- data->bindings = this;
-
- data->setBindingBit(obj, index);
- }
-}
-
-/*!
-Remove the binding from the object.
-*/
-void QQmlAbstractBinding::removeFromObject()
-{
- if (m_prevBinding) {
- int index = propertyIndex();
-
- *m_prevBinding = m_nextBinding;
- if (m_nextBinding) m_nextBinding->m_prevBinding = m_prevBinding;
- m_prevBinding = 0;
- m_nextBinding = 0;
-
- if (index & 0xFF000000) {
- // Value type - we don't remove the proxy from the object. It will sit their happily
- // doing nothing until it is removed by a write, a binding change or it is reused
- // to hold more sub-bindings.
- } else if (QObject *obj = object()) {
- QQmlData *data = QQmlData::get(obj, false);
- if (data) data->clearBindingBit(index);
- }
- }
-}
-
-static void bindingDummyDeleter(QQmlAbstractBinding *)
-{
-}
-
-QQmlAbstractBinding::Pointer QQmlAbstractBinding::weakPointer()
-{
- if (m_mePtr.value().isNull())
- m_mePtr.value() = QSharedPointer<QQmlAbstractBinding>(this, bindingDummyDeleter);
-
- return m_mePtr.value().toWeakRef();
-}
-
-void QQmlAbstractBinding::clear()
-{
- if (!m_mePtr.isNull()) {
- **m_mePtr = 0;
- m_mePtr = 0;
- }
-}
-
-void QQmlAbstractBinding::retargetBinding(QObject *, int)
-{
- qFatal("QQmlAbstractBinding::retargetBinding() called on illegal binding.");
-}
-
-QString QQmlAbstractBinding::expression() const
-{
- return QLatin1String("<Unknown>");
-}
-
-void QQmlAbstractBinding::setEnabled(bool enabled, QQmlPropertyPrivate::WriteFlags flags)
-{
- if (enabled) update(flags);
-}
-
QQmlBinding::Identifier QQmlBinding::Invalid = -1;
void QQmlBindingPrivate::refresh()
@@ -457,96 +314,4 @@ void QQmlBinding::retargetBinding(QObject *t, int i)
d->targetProperty = i;
}
-QQmlValueTypeProxyBinding::QQmlValueTypeProxyBinding(QObject *o, int index)
-: m_object(o), m_index(index), m_bindings(0)
-{
-}
-
-QQmlValueTypeProxyBinding::~QQmlValueTypeProxyBinding()
-{
- while (m_bindings) {
- QQmlAbstractBinding *binding = m_bindings;
- binding->setEnabled(false, 0);
- binding->destroy();
- }
-}
-
-void QQmlValueTypeProxyBinding::setEnabled(bool e, QQmlPropertyPrivate::WriteFlags flags)
-{
- if (e) {
- QQmlAbstractBinding *bindings = m_bindings;
- recursiveEnable(bindings, flags);
- } else {
- QQmlAbstractBinding *bindings = m_bindings;
- recursiveDisable(bindings);
- }
-}
-
-void QQmlValueTypeProxyBinding::recursiveEnable(QQmlAbstractBinding *b, QQmlPropertyPrivate::WriteFlags flags)
-{
- if (!b)
- return;
-
- recursiveEnable(b->m_nextBinding, flags);
-
- if (b)
- b->setEnabled(true, flags);
-}
-
-void QQmlValueTypeProxyBinding::recursiveDisable(QQmlAbstractBinding *b)
-{
- if (!b)
- return;
-
- recursiveDisable(b->m_nextBinding);
-
- if (b)
- b->setEnabled(false, 0);
-}
-
-void QQmlValueTypeProxyBinding::update(QQmlPropertyPrivate::WriteFlags)
-{
-}
-
-QQmlAbstractBinding *QQmlValueTypeProxyBinding::binding(int propertyIndex)
-{
- QQmlAbstractBinding *binding = m_bindings;
-
- while (binding && binding->propertyIndex() != propertyIndex)
- binding = binding->m_nextBinding;
-
- return binding;
-}
-
-/*!
-Removes a collection of bindings, corresponding to the set bits in \a mask.
-*/
-void QQmlValueTypeProxyBinding::removeBindings(quint32 mask)
-{
- QQmlAbstractBinding *binding = m_bindings;
- while (binding) {
- if (mask & (1 << (binding->propertyIndex() >> 24))) {
- QQmlAbstractBinding *remove = binding;
- binding = remove->m_nextBinding;
- *remove->m_prevBinding = remove->m_nextBinding;
- if (remove->m_nextBinding) remove->m_nextBinding->m_prevBinding = remove->m_prevBinding;
- remove->m_prevBinding = 0;
- remove->m_nextBinding = 0;
- remove->destroy();
- } else {
- binding = binding->m_nextBinding;
- }
- }
-}
-
-int QQmlValueTypeProxyBinding::propertyIndex() const
-{
- return m_index;
-}
-
-QObject *QQmlValueTypeProxyBinding::object() const
-{
- return m_object;
-}
-
QT_END_NAMESPACE