Qt 4.8
Public Types | Public Functions | Static Public Functions | Protected Functions | Private Functions | Properties | Friends | List of all members
QDeclarativeAbstractBinding Class Referenceabstract

#include <qdeclarativebinding_p.h>

Inheritance diagram for QDeclarativeAbstractBinding:
QDeclarativeBinding QDeclarativeCompiledBindingsPrivate::Binding QDeclarativeValueTypeProxyBinding

Public Types

enum  DestroyMode { DisconnectBinding, KeepBindingConnected }
 
enum  DisconnectMode { DisconnectOne, DisconnectAll }
 
typedef QWeakPointer< QDeclarativeAbstractBindingPointer
 
enum  Type { PropertyBinding, ValueTypeProxy }
 

Public Functions

void addToObject (QObject *, int)
 Add this binding to object. More...
 
virtual Type bindingType () const
 
virtual void destroy (DestroyMode mode=DisconnectBinding)
 Destroy the binding. More...
 
virtual void disconnect (DisconnectMode disconnectMode)=0
 
virtual QString expression () const
 
QObjectobject () const
 
int propertyIndex () const
 
 QDeclarativeAbstractBinding ()
 
void removeFromObject ()
 Remove the binding from the object. More...
 
void setEnabled (bool e)
 
virtual void setEnabled (bool, QDeclarativePropertyPrivate::WriteFlags)=0
 
void update ()
 
virtual void update (QDeclarativePropertyPrivate::WriteFlags)=0
 

Static Public Functions

static Pointer getPointer (QDeclarativeAbstractBinding *p)
 

Protected Functions

void clear ()
 
virtual ~QDeclarativeAbstractBinding ()
 

Private Functions

Pointer weakPointer ()
 

Properties

QDeclarativeAbstractBinding ** m_mePtr
 
QDeclarativeAbstractBindingm_nextBinding
 
QObjectm_object
 
QDeclarativeAbstractBinding ** m_prevBinding
 
int m_propertyIndex
 
QSharedPointer< QDeclarativeAbstractBindingm_selfPointer
 

Friends

class QDeclarativeComponentPrivate
 
class QDeclarativeData
 
class QDeclarativePropertyPrivate
 
class QDeclarativeValueTypeProxyBinding
 
class QDeclarativeVME
 
class QtSharedPointer::ExternalRefCount< QDeclarativeAbstractBinding >
 

Detailed Description

Definition at line 67 of file qdeclarativebinding_p.h.

Typedefs

◆ Pointer

Definition at line 70 of file qdeclarativebinding_p.h.

Enumerations

◆ DestroyMode

Enumerator
DisconnectBinding 
KeepBindingConnected 

Definition at line 74 of file qdeclarativebinding_p.h.

74  {
75  // The binding should disconnect itself upon destroy
77 
78  // The binding doesn't need to disconnect itself, but it can if it wants to.
79  //
80  // This is used in QDeclarativeData::destroyed() - at the point at which the bindings are
81  // destroyed, the notifiers are already disconnected, so no need to disconnect each
82  // binding again.
83  //
84  // Bindings can use this flag to speed up destruction, especially for compiled bindings
85  // disconnecting a single binding might be slow.
87  };

◆ DisconnectMode

Enumerator
DisconnectOne 
DisconnectAll 

Definition at line 93 of file qdeclarativebinding_p.h.

93  {
94 
95  // Just this single binding is getting disconnected, other bindings remain connected and
96  // should not be changed.
98 
99  // All bindings of the same object are getting disconnected. As an optimization, it is
100  // therefore valid to disconnect all bindings in one go.
102  };

◆ Type

Constructors and Destructors

◆ QDeclarativeAbstractBinding()

QDeclarativeAbstractBinding::QDeclarativeAbstractBinding ( )

Definition at line 60 of file qdeclarativebinding.cpp.

62 {
63 }
QDeclarativeAbstractBinding * m_nextBinding
QDeclarativeAbstractBinding ** m_prevBinding
QDeclarativeAbstractBinding ** m_mePtr

◆ ~QDeclarativeAbstractBinding()

QDeclarativeAbstractBinding::~QDeclarativeAbstractBinding ( )
protectedvirtual

Definition at line 65 of file qdeclarativebinding.cpp.

66 {
67  Q_ASSERT(m_prevBinding == 0);
68  Q_ASSERT(m_mePtr == 0);
69 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QDeclarativeAbstractBinding ** m_prevBinding
QDeclarativeAbstractBinding ** m_mePtr

Functions

◆ addToObject()

void QDeclarativeAbstractBinding::addToObject ( QObject object,
int  index 
)

Add this binding to 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.

Definition at line 97 of file qdeclarativebinding.cpp.

Referenced by addToObject(), QDeclarativePropertyPrivate::setBinding(), and QDeclarativePropertyPrivate::setBindingNoEnable().

98 {
99  Q_ASSERT(object);
100 
101  if (m_object == object && m_propertyIndex == index)
102  return;
103 
105 
107 
108  m_object = object;
110 
112 
113  if (index & 0xFF000000) {
114  // Value type
115 
116  int coreIndex = index & 0xFFFFFF;
117 
118  // Find the value type proxy (if there is one)
120  if (data->hasBindingBit(coreIndex)) {
122  while (b && b->propertyIndex() != coreIndex)
123  b = b->m_nextBinding;
125  proxy = static_cast<QDeclarativeValueTypeProxyBinding *>(b);
126  }
127 
128  if (!proxy) {
129  proxy = new QDeclarativeValueTypeProxyBinding(object, coreIndex);
130  proxy->addToObject(object, coreIndex);
131  }
132 
133  m_nextBinding = proxy->m_bindings;
135  m_prevBinding = &proxy->m_bindings;
136  proxy->m_bindings = this;
137 
138  } else {
139  m_nextBinding = data->bindings;
141  m_prevBinding = &data->bindings;
142  data->bindings = this;
143 
144  data->setBindingBit(m_object, index);
145  }
146 }
void setBindingBit(QObject *obj, int)
static QDeclarativeData * get(const QObject *object, bool create=false)
void addToObject(QObject *, int)
Add this binding to object.
QDeclarativeAbstractBinding * bindings
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool hasBindingBit(int) const
static const char * data(const QByteArray &arr)
QDeclarativeAbstractBinding * m_nextBinding
void removeFromObject()
Remove the binding from the object.
QDeclarativeAbstractBinding * m_bindings
quint16 index
QDeclarativeAbstractBinding ** m_prevBinding

◆ bindingType()

virtual Type QDeclarativeAbstractBinding::bindingType ( ) const
inlinevirtual

◆ clear()

void QDeclarativeAbstractBinding::clear ( )
protected

Definition at line 187 of file qdeclarativebinding.cpp.

Referenced by destroy().

188 {
189  if (m_mePtr) {
190  *m_mePtr = 0;
191  m_mePtr = 0;
192  }
193 }
QDeclarativeAbstractBinding ** m_mePtr

◆ destroy()

void QDeclarativeAbstractBinding::destroy ( DestroyMode  mode = DisconnectBinding)
virtual

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.

Reimplemented in QDeclarativeCompiledBindingsPrivate::Binding.

Definition at line 78 of file qdeclarativebinding.cpp.

Referenced by QDeclarativeState::apply(), QDeclarativeTransitionManager::cancel(), QDeclarativeState::changeBindingInRevertList(), QDeclarativePropertyChanges::changeExpression(), QDeclarativePropertyChanges::changeValue(), QDeclarativeData::destroyed(), QDeclarativeAnchorChanges::execute(), QDeclarativeVMEMetaObject::metaCall(), QDeclarativeState::removeAllEntriesFromRevertList(), removeBindingOnProperty(), QDeclarativeValueTypeProxyBinding::removeBindings(), QDeclarativeState::removeEntryFromRevertList(), QDeclarativeEngineDebugService::resetBinding(), QDeclarativeEngineDebugService::setBinding(), QDeclarativePropertyPrivate::setBinding(), QDeclarativePropertyPrivate::setBindingNoEnable(), QDeclarativeValueTypeScriptClass::setProperty(), QDeclarativeObjectScriptClass::setProperty(), QDeclarativePropertyPrivate::writeValueProperty(), and QDeclarativeValueTypeProxyBinding::~QDeclarativeValueTypeProxyBinding().

◆ disconnect()

virtual void QDeclarativeAbstractBinding::disconnect ( DisconnectMode  disconnectMode)
pure virtual

◆ expression()

QString QDeclarativeAbstractBinding::expression ( ) const
virtual

Reimplemented in QDeclarativeBinding.

Definition at line 195 of file qdeclarativebinding.cpp.

Referenced by QDeclarativeEngineDebugService::propertyData().

196 {
197  return QLatin1String("<Unknown>");
198 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ getPointer()

static Pointer QDeclarativeAbstractBinding::getPointer ( QDeclarativeAbstractBinding p)
inlinestatic

◆ object()

QObject * QDeclarativeAbstractBinding::object ( ) const

Definition at line 200 of file qdeclarativebinding.cpp.

Referenced by addToObject().

201 {
202  return m_object;
203 }

◆ propertyIndex()

int QDeclarativeAbstractBinding::propertyIndex ( ) const

◆ removeFromObject()

void QDeclarativeAbstractBinding::removeFromObject ( )

Remove the binding from the object.

Definition at line 151 of file qdeclarativebinding.cpp.

Referenced by addToObject(), destroy(), QDeclarativePropertyPrivate::setBinding(), and QDeclarativePropertyPrivate::setBindingNoEnable().

152 {
153  if (m_prevBinding) {
154  int index = propertyIndex();
155 
158  m_prevBinding = 0;
159  m_nextBinding = 0;
160 
161  if (index & 0xFF000000) {
162  // Value type - we don't remove the proxy from the object. It will sit their happily
163  // doing nothing until it is removed by a write, a binding change or it is reused
164  // to hold more sub-bindings.
165  } else if (m_object) {
167  if (data) data->clearBindingBit(index);
168  }
169 
170  m_object = 0;
171  m_propertyIndex = -1;
172  }
173 }
static QDeclarativeData * get(const QObject *object, bool create=false)
static const char * data(const QByteArray &arr)
QDeclarativeAbstractBinding * m_nextBinding
quint16 index
QDeclarativeAbstractBinding ** m_prevBinding

◆ setEnabled() [1/2]

void QDeclarativeAbstractBinding::setEnabled ( bool  e)
inline

◆ setEnabled() [2/2]

void QDeclarativeAbstractBinding::setEnabled ( bool  enabled,
QDeclarativePropertyPrivate::WriteFlags  flags 
)
pure virtual

◆ update() [1/2]

void QDeclarativeAbstractBinding::update ( )
inline

◆ update() [2/2]

virtual void QDeclarativeAbstractBinding::update ( QDeclarativePropertyPrivate::WriteFlags  )
pure virtual

◆ weakPointer()

QDeclarativeAbstractBinding::Pointer QDeclarativeAbstractBinding::weakPointer ( )
private

Definition at line 179 of file qdeclarativebinding.cpp.

Referenced by getPointer().

180 {
181  if (m_selfPointer.isNull())
183 
184  return m_selfPointer.toWeakRef();
185 }
QWeakPointer< T > toWeakRef() const
Returns a weak reference object that shares the pointer referenced by this object.
static void bindingDummyDeleter(QDeclarativeAbstractBinding *)
QSharedPointer< QDeclarativeAbstractBinding > m_selfPointer
bool isNull() const
Returns true if this object is holding a reference to a null pointer.

Friends and Related Functions

◆ QDeclarativeComponentPrivate

Definition at line 132 of file qdeclarativebinding_p.h.

◆ QDeclarativeData

friend class QDeclarativeData
friend

Definition at line 131 of file qdeclarativebinding_p.h.

◆ QDeclarativePropertyPrivate

Definition at line 134 of file qdeclarativebinding_p.h.

◆ QDeclarativeValueTypeProxyBinding

Definition at line 133 of file qdeclarativebinding_p.h.

Referenced by addToObject().

◆ QDeclarativeVME

friend class QDeclarativeVME
friend

Definition at line 135 of file qdeclarativebinding_p.h.

◆ QtSharedPointer::ExternalRefCount< QDeclarativeAbstractBinding >

friend class QtSharedPointer::ExternalRefCount< QDeclarativeAbstractBinding >
friend

Definition at line 136 of file qdeclarativebinding_p.h.

Properties

◆ m_mePtr

QDeclarativeAbstractBinding** QDeclarativeAbstractBinding::m_mePtr
private

◆ m_nextBinding

QDeclarativeAbstractBinding* QDeclarativeAbstractBinding::m_nextBinding
private

◆ m_object

QObject* QDeclarativeAbstractBinding::m_object
private

Definition at line 138 of file qdeclarativebinding_p.h.

Referenced by addToObject(), object(), and removeFromObject().

◆ m_prevBinding

QDeclarativeAbstractBinding** QDeclarativeAbstractBinding::m_prevBinding
private

◆ m_propertyIndex

int QDeclarativeAbstractBinding::m_propertyIndex
private

Definition at line 139 of file qdeclarativebinding_p.h.

Referenced by addToObject(), propertyIndex(), and removeFromObject().

◆ m_selfPointer

QSharedPointer<QDeclarativeAbstractBinding> QDeclarativeAbstractBinding::m_selfPointer
private

Definition at line 143 of file qdeclarativebinding_p.h.

Referenced by weakPointer().


The documentation for this class was generated from the following files: