[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Newbie Developer to KDE
From:       Kevin Krammer <kevin.krammer () gmx ! at>
Date:       2001-04-22 15:57:05
[Download RAW message or body]

How about this?

class NotifySource : public QObject
{
//other stuff
  public signal:
    void notify(QString id, QObject* sender);
};

NotifySource::NotifySource(...)
{
  NotifyCenter* center = NotifyCenter;
  connect (this, SIGNAL(notify(QString, QObject*), center, 
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*);
}; 

class NotifyListener
{
  public slots:
    slotProcessNotification(Notification*);
}

NotifyListener::NotifyListener()
{
  NotifyCenter* center = ....
  center->registerListener("AnEventID", this);
}

NotifyCenter keeps a mapping of IDs to lists of NotifyListeners and on 
receiving an event connects to the slotProcessNotification(Notification*) 
slot of the appropirate listeners, emits the notification(Notification*) and 
signal and disconnects afterwards.

Hope this helps,
Kevin

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kevin Krammer <kevin.krammer@gmx.at>
Developer at the Kmud Project http://www.kmud.de/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic