-class SignalProxy::SignalRelay : public QObject
-{
-/* Q_OBJECT is not necessary or even allowed, because we implement
- qt_metacall ourselves (and don't use any other features of the meta
- object system)
-*/
-public:
- SignalRelay(SignalProxy *parent) : QObject(parent), _proxy(parent) {}
- inline SignalProxy *proxy() const { return _proxy; }
-
- int qt_metacall(QMetaObject::Call _c, int _id, void **_a);
-
- void attachSignal(QObject *sender, int signalId, const QByteArray &funcName);
- void detachSignal(QObject *sender, int signalId = -1);
-
-private:
- struct Signal {
- QObject *sender;
- int signalId;
- QByteArray signature;
- Signal(QObject *sender, int sigId, const QByteArray &signature) : sender(sender), signalId(sigId), signature(signature) {}
- Signal() : sender(0), signalId(-1) {}
- };
-
- SignalProxy *_proxy;
- QHash<int, Signal> _slots;
-};
-
-
-void SignalProxy::SignalRelay::attachSignal(QObject *sender, int signalId, const QByteArray &funcName)
-{
- // we ride without safetybelts here... all checking for valid method etc pp has to be done by the caller
- // all connected methodIds are offset by the standard methodCount of QObject
- int slotId;
- for (int i = 0;; i++) {
- if (!_slots.contains(i)) {
- slotId = i;
- break;
- }
- }
-
- QByteArray fn;
- if (!funcName.isEmpty()) {
- fn = QMetaObject::normalizedSignature(funcName);
- }
- else {
- fn = SIGNAL(fakeMethodSignature());
- fn = fn.replace("fakeMethodSignature()", sender->metaObject()->method(signalId).signature());
- }
-
- _slots[slotId] = Signal(sender, signalId, fn);
-
- QMetaObject::connect(sender, signalId, this, QObject::staticMetaObject.methodCount() + slotId);
-}