Qt 4.8
Classes | Public Functions | Public Variables | Private Types | Private Functions | Properties | Friends | List of all members
QDeclarativeNotifierEndpoint Class Reference

#include <qdeclarativenotifier_p.h>

Classes

struct  Notifier
 
struct  Signal
 

Public Functions

void connect (QObject *source, int sourceSignal)
 
void connect (QDeclarativeNotifier *)
 
void copyAndClear (QDeclarativeNotifierEndpoint &other)
 
void deref ()
 
void disconnect ()
 
bool isConnected ()
 
bool isConnected (QObject *source, int sourceSignal)
 
bool isConnected (QDeclarativeNotifier *)
 
 QDeclarativeNotifierEndpoint ()
 
 QDeclarativeNotifierEndpoint (QObject *t, int m)
 
 ~QDeclarativeNotifierEndpoint ()
 

Public Variables

QObjecttarget
 
int targetMethod
 
Notifier notifier
 
qint64 q_for_alignment_1
 
double q_for_alignment_2
 
Signalsignal
 
struct {
   union {
      qint64   q_for_alignment_1
 
      double   q_for_alignment_2
 
      char   signalData [sizeof(Signal)]
 
   } 
 
   Signal *   signal
 
signal
 

Private Types

enum  { InvalidType, SignalType, NotifierType }
 

Private Functions

NotifierasNotifier ()
 
SignalasSignal ()
 
NotifiertoNotifier ()
 
SignaltoSignal ()
 

Properties

union {
   Notifier   notifier
 
   struct {
      union {
         qint64   q_for_alignment_1
 
         double   q_for_alignment_2
 
         char   signalData [sizeof(Signal)]
 
      } 
 
      Signal *   signal
 
   }   signal
 
}; 
 
quint16 refCount
 
enum QDeclarativeNotifierEndpoint:: { ... }  type
 

Friends

class QDeclarativeNotifier
 

Detailed Description

Definition at line 65 of file qdeclarativenotifier_p.h.

Enumerations

◆ anonymous enum

anonymous enum
private

Constructors and Destructors

◆ QDeclarativeNotifierEndpoint() [1/2]

QDeclarativeNotifierEndpoint::QDeclarativeNotifierEndpoint ( )
inline

◆ QDeclarativeNotifierEndpoint() [2/2]

QDeclarativeNotifierEndpoint::QDeclarativeNotifierEndpoint ( QObject t,
int  m 
)
inline

◆ ~QDeclarativeNotifierEndpoint()

QDeclarativeNotifierEndpoint::~QDeclarativeNotifierEndpoint ( )
inline

Definition at line 163 of file qdeclarativenotifier_p.h.

164 {
165  disconnect();
166  if (SignalType == type) {
167  Signal *s = asSignal();
168  s->~Signal();
169  }
170 }
enum QDeclarativeNotifierEndpoint::@137 type

Functions

◆ asNotifier()

QDeclarativeNotifierEndpoint::Notifier * QDeclarativeNotifierEndpoint::asNotifier ( )
inlineprivate

◆ asSignal()

QDeclarativeNotifierEndpoint::Signal * QDeclarativeNotifierEndpoint::asSignal ( )
inlineprivate

Definition at line 283 of file qdeclarativenotifier_p.h.

Referenced by disconnect(), isConnected(), toNotifier(), toSignal(), and ~QDeclarativeNotifierEndpoint().

284 {
286  return signal.signal;
287 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
enum QDeclarativeNotifierEndpoint::@137 type

◆ connect() [1/2]

void QDeclarativeNotifierEndpoint::connect ( QObject source,
int  sourceSignal 
)

Definition at line 70 of file qdeclarativenotifier.cpp.

Referenced by QDeclarativeItemPrivate::parentProperty(), QObject_objectName(), QDeclarativeCompiledBindingsPrivate::subscribe(), QDeclarativeCompiledBindingsPrivate::subscribeId(), and QDeclarativeQtScriptExpression::updateGuards().

71 {
72  Signal *s = toSignal();
73 
74  if (s->source == source && s->sourceSignal == sourceSignal) {
75  refCount++;
76  return;
77  }
78 
79  disconnect();
80 
82 
83  s->source = source;
84  s->sourceSignal = sourceSignal;
85  refCount++;
86 }
static bool connect(QObject *sender, int signal_index, const QObject *receiver, int method_index, int type=0, int *types=0)
Connect sender signal_index to receiver method_index with the specified type and types.

◆ connect() [2/2]

void QDeclarativeNotifierEndpoint::connect ( QDeclarativeNotifier notifier)
inline

Definition at line 193 of file qdeclarativenotifier_p.h.

194 {
195  Notifier *n = toNotifier();
196 
197  if (n->notifier == notifier) {
198  refCount++;
199  return;
200  }
201 
202  disconnect();
203 
204  n->next = notifier->endpoints;
205  if (n->next) { n->next->asNotifier()->prev = &n->next; }
206  notifier->endpoints = this;
207  n->prev = &notifier->endpoints;
208  n->notifier = notifier;
209  refCount++;
210 }
QDeclarativeNotifierEndpoint ** prev
QDeclarativeNotifierEndpoint * endpoints

◆ copyAndClear()

void QDeclarativeNotifierEndpoint::copyAndClear ( QDeclarativeNotifierEndpoint other)

Definition at line 88 of file qdeclarativenotifier.cpp.

89 {
90  other.disconnect();
91 
92  other.target = target;
93  other.targetMethod = targetMethod;
94 
95  if (!isConnected())
96  return;
97 
98  if (SignalType == type) {
99  Signal *other_s = other.toSignal();
100  Signal *s = asSignal();
101 
102  other_s->source = s->source;
103  other_s->sourceSignal = s->sourceSignal;
104  s->source = 0;
105  } else if(NotifierType == type) {
106  Notifier *other_n = other.toNotifier();
107  Notifier *n = asNotifier();
108 
109  other_n->notifier = n->notifier;
110  other_n->disconnected = n->disconnected;
111  if (other_n->disconnected) *other_n->disconnected = &other;
112 
113  if (n->next) {
114  other_n->next = n->next;
115  n->next->asNotifier()->prev = &other_n->next;
116  }
117  other_n->prev = n->prev;
118  *other_n->prev = &other;
119 
120  n->prev = 0;
121  n->next = 0;
122  n->disconnected = 0;
123  n->notifier = 0;
124  }
125 }
enum QDeclarativeNotifierEndpoint::@137 type
QDeclarativeNotifierEndpoint ** prev

◆ deref()

void QDeclarativeNotifierEndpoint::deref ( )
inline

◆ disconnect()

void QDeclarativeNotifierEndpoint::disconnect ( )
inline

Definition at line 212 of file qdeclarativenotifier_p.h.

Referenced by connect(), copyAndClear(), deref(), QDeclarativeCompiledBindingsPrivate::disconnectAll(), QDeclarativeCompiledBindingsPrivate::subscribe(), QDeclarativeCompiledBindingsPrivate::subscribeId(), toNotifier(), toSignal(), QDeclarativeQtScriptExpression::updateGuards(), and ~QDeclarativeNotifierEndpoint().

213 {
214  if (type == SignalType) {
215  Signal *s = asSignal();
216  if (s->source) {
217  QMetaObject::disconnectOne(s->source, s->sourceSignal, target, targetMethod);
218  QObjectPrivate * const priv = QObjectPrivate::get(s->source);
219  const QMetaMethod signal = s->source->metaObject()->method(s->sourceSignal);
220  QVarLengthArray<char> signalSignature;
221  QObjectPrivate::signalSignature(signal, &signalSignature);
222  priv->disconnectNotify(signalSignature.constData());
223  s->source = 0;
224  }
225  } else if (type == NotifierType) {
226  Notifier *n = asNotifier();
227 
228  if (n->next) n->next->asNotifier()->prev = n->prev;
229  if (n->prev) *n->prev = n->next;
230  if (n->disconnected) *n->disconnected = 0;
231  n->next = 0;
232  n->prev = 0;
233  n->disconnected = 0;
234  n->notifier = 0;
235  }
236  refCount = 0;
237 }
const T * constData() const
static void signalSignature(const QMetaMethod &signal, QVarLengthArray< char > *result)
Definition: qobject_p.h:255
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
enum QDeclarativeNotifierEndpoint::@137 type
static const QMetaObjectPrivate * priv(const uint *data)
static bool disconnectOne(const QObject *sender, int signal_index, const QObject *receiver, int method_index)
Definition: qobject.cpp:3290
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
void disconnectNotify(const char *signal)
Definition: qobject_p.h:250
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ isConnected() [1/3]

bool QDeclarativeNotifierEndpoint::isConnected ( )
inline

◆ isConnected() [2/3]

bool QDeclarativeNotifierEndpoint::isConnected ( QObject source,
int  sourceSignal 
)
inline

Definition at line 183 of file qdeclarativenotifier_p.h.

◆ isConnected() [3/3]

bool QDeclarativeNotifierEndpoint::isConnected ( QDeclarativeNotifier notifier)
inline

◆ toNotifier()

QDeclarativeNotifierEndpoint::Notifier * QDeclarativeNotifierEndpoint::toNotifier ( )
inlineprivate

Definition at line 246 of file qdeclarativenotifier_p.h.

Referenced by connect(), and copyAndClear().

247 {
248  if (NotifierType == type)
249  return asNotifier();
250 
251  if (SignalType == type) {
252  disconnect();
253  Signal *s = asSignal();
254  s->~Signal();
255  }
256 
257  type = NotifierType;
258  Notifier *n = asNotifier();
259  n->next = 0;
260  n->prev = 0;
261  n->disconnected = 0;
262  n->notifier = 0;
263  return n;
264 }
enum QDeclarativeNotifierEndpoint::@137 type

◆ toSignal()

QDeclarativeNotifierEndpoint::Signal * QDeclarativeNotifierEndpoint::toSignal ( )
inlineprivate

Definition at line 272 of file qdeclarativenotifier_p.h.

Referenced by copyAndClear().

273 {
274  if (SignalType == type)
275  return asSignal();
276 
277  disconnect();
278  signal.signal = new (&signal.signalData) Signal;
279  type = SignalType;
280  return signal.signal;
281 }
enum QDeclarativeNotifierEndpoint::@137 type

Friends and Related Functions

◆ QDeclarativeNotifier

friend class QDeclarativeNotifier
friend

Definition at line 91 of file qdeclarativenotifier_p.h.

Properties

◆ @139

union { ... }

◆ notifier

Notifier QDeclarativeNotifierEndpoint::notifier

Definition at line 116 of file qdeclarativenotifier_p.h.

Referenced by asNotifier(), connect(), and isConnected().

◆ q_for_alignment_1

qint64 QDeclarativeNotifierEndpoint::q_for_alignment_1

Definition at line 112 of file qdeclarativenotifier_p.h.

◆ q_for_alignment_2

double QDeclarativeNotifierEndpoint::q_for_alignment_2

Definition at line 113 of file qdeclarativenotifier_p.h.

◆ refCount

quint16 QDeclarativeNotifierEndpoint::refCount
private

Definition at line 119 of file qdeclarativenotifier_p.h.

Referenced by connect(), deref(), and disconnect().

◆ signal [1/2]

Signal* QDeclarativeNotifierEndpoint::signal

Definition at line 109 of file qdeclarativenotifier_p.h.

Referenced by asSignal(), disconnect(), and toSignal().

◆ signal [2/2]

struct { ... } QDeclarativeNotifierEndpoint::signal

◆ signalData

char QDeclarativeNotifierEndpoint::signalData[sizeof(Signal)]

Definition at line 111 of file qdeclarativenotifier_p.h.

◆ target

QObject* QDeclarativeNotifierEndpoint::target

◆ targetMethod

int QDeclarativeNotifierEndpoint::targetMethod

◆ type

enum { ... } QDeclarativeNotifierEndpoint::type

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