From kde-devel Sun Apr 22 15:57:05 2001 From: Kevin Krammer Date: Sun, 22 Apr 2001 15:57:05 +0000 To: kde-devel Subject: Re: Newbie Developer to KDE X-MARC-Message: https://marc.info/?l=kde-devel&m=98795522729683 How about this? class NotifySource : public QObject { //other stuff public signal: void notify(QString id, QObject* sender); }; NotifySource::NotifySource(...) { NotifyCenter* center =3D NotifyCenter; connect (this, SIGNAL(notify(QString, QObject*), center,=20 SLOT(slotNotify(QString, QObject*))); } whenever NotifySource wants to dispatch a notification it just does: emit notfy("AnEventName", this); class NotifyCenter : QObject { public: registerListener(QString eventID, NotifyListener* listener); public slots: void slotNotify(QString, QObject*); };=20 class NotifyListener { public slots: slotProcessNotification(Notification*); } NotifyListener::NotifyListener() { NotifyCenter* center =3D .... center->registerListener("AnEventID", this); } NotifyCenter keeps a mapping of IDs to lists of NotifyListeners and on=20 receiving an event connects to the slotProcessNotification(Notification*)= =20 slot of the appropirate listeners, emits the notification(Notification*) = and=20 signal and disconnects afterwards. Hope this helps, Kevin --=20 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Kevin Krammer Developer at the Kmud Project http://www.kmud.de/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<