Qt 4.8
Public Functions | Protected Functions | List of all members
QDBusAbstractAdaptor Class Reference

The QDBusAbstractAdaptor class is the base class of D-Bus adaptor classes. More...

#include <qdbusabstractadaptor.h>

Inheritance diagram for QDBusAbstractAdaptor:
QObject

Public Functions

 ~QDBusAbstractAdaptor ()
 Destroys the adaptor. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Protected Functions

bool autoRelaySignals () const
 Returns true if automatic signal relaying from the real object (see object()) is enabled, otherwiser returns false. More...
 
 QDBusAbstractAdaptor (QObject *parent)
 Constructs a QDBusAbstractAdaptor with obj as the parent object. More...
 
void setAutoRelaySignals (bool enable)
 Toggles automatic signal relaying from the real object (see object()). More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QDBusAbstractAdaptor class is the base class of D-Bus adaptor classes.

Attention
Module: QtDBus
Since
4.2

The QDBusAbstractAdaptor class is the starting point for all objects intending to provide interfaces to the external world using D-Bus. This is accomplished by attaching a one or more classes derived from QDBusAbstractAdaptor to a normal QObject and then registering that QObject with QDBusConnection::registerObject. QDBusAbstractAdaptor objects are intended to be light-weight wrappers, mostly just relaying calls into the real object (its parent) and the signals from it.

Each QDBusAbstractAdaptor-derived class should define the D-Bus interface it is implementing using the Q_CLASSINFO macro in the class definition. Note that only one interface can be exposed in this way.

QDBusAbstractAdaptor uses the standard QObject mechanism of signals, slots and properties to determine what signals, methods and properties to export to the bus. Any signal emitted by QDBusAbstractAdaptor-derived classes will be automatically be relayed through any D-Bus connections the object is registered on.

Classes derived from QDBusAbstractAdaptor must be created on the heap using the new operator and must not be deleted by the user (they will be deleted automatically when the object they are connected to is also deleted).

See also
{usingadaptors.html}{Using adaptors}, QDBusConnection

Definition at line 57 of file qdbusabstractadaptor.h.

Constructors and Destructors

◆ QDBusAbstractAdaptor()

QDBusAbstractAdaptor::QDBusAbstractAdaptor ( QObject parent)
protected

Constructs a QDBusAbstractAdaptor with obj as the parent object.

Definition at line 137 of file qdbusabstractadaptor.cpp.

139 {
141 
142  connector->waitingForPolish = true;
143  QMetaObject::invokeMethod(connector, "polish", Qt::QueuedConnection);
144 }
QDBusAdaptorConnector * qDBusCreateAdaptorConnector(QObject *obj)
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753
static bool invokeMethod(QObject *obj, const char *member, Qt::ConnectionType, QGenericReturnArgument ret, QGenericArgument val0=QGenericArgument(0), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument(), QGenericArgument val4=QGenericArgument(), QGenericArgument val5=QGenericArgument(), QGenericArgument val6=QGenericArgument(), QGenericArgument val7=QGenericArgument(), QGenericArgument val8=QGenericArgument(), QGenericArgument val9=QGenericArgument())
Invokes the member (a signal or a slot name) on the object obj.

◆ ~QDBusAbstractAdaptor()

QDBusAbstractAdaptor::~QDBusAbstractAdaptor ( )

Destroys the adaptor.

Warning
Adaptors are destroyed automatically when the real object they refer to is destroyed. Do not delete the adaptors yourself.

Definition at line 152 of file qdbusabstractadaptor.cpp.

153 {
154 }

Functions

◆ autoRelaySignals()

bool QDBusAbstractAdaptor::autoRelaySignals ( ) const
protected

Returns true if automatic signal relaying from the real object (see object()) is enabled, otherwiser returns false.

See also
setAutoRelaySignals()

Definition at line 193 of file qdbusabstractadaptor.cpp.

194 {
195  return d_func()->autoRelaySignals;
196 }

◆ setAutoRelaySignals()

void QDBusAbstractAdaptor::setAutoRelaySignals ( bool  enable)
protected

Toggles automatic signal relaying from the real object (see object()).

Automatic signal relaying consists of signal-to-signal connection of the signals on the parent that have the exact same method signatue in both classes.

If enable is set to true, connect the signals; if set to false, disconnect all signals.

Definition at line 164 of file qdbusabstractadaptor.cpp.

165 {
166  const QMetaObject *us = metaObject();
167  const QMetaObject *them = parent()->metaObject();
168  bool connected = false;
169  for (int idx = staticMetaObject.methodCount(); idx < us->methodCount(); ++idx) {
170  QMetaMethod mm = us->method(idx);
171 
172  if (mm.methodType() != QMetaMethod::Signal)
173  continue;
174 
175  // try to connect/disconnect to a signal on the parent that has the same method signature
177  if (them->indexOfSignal(sig) == -1)
178  continue;
179  sig.prepend(QSIGNAL_CODE + '0');
180  parent()->disconnect(sig, this, sig);
181  if (enable)
182  connected = connect(parent(), sig, sig) || connected;
183  }
184  d_func()->autoRelaySignals = connected;
185 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
QByteArray & prepend(char c)
Prepends the character ch to this byte array.
static QIntfbScreen * connected
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
int indexOfSignal(const char *signal) const
Finds signal and returns its index; otherwise returns -1.
MethodType methodType() const
Returns the type of this method (signal, slot, or method).
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
#define QSIGNAL_CODE
Definition: qobjectdefs.h:244
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
int methodCount() const
Returns the number of methods known to the meta-object system in this class, including the number of ...
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.

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