kmail
isubject.cpp00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004
00005 #include "isubject.h"
00006 #include "interfaces/observer.h"
00007
00008 #include <qtl.h>
00009
00010 #include <kdebug.h>
00011
00012 namespace KMail {
00013
00014 ISubject::~ISubject()
00015 {
00016 mObserverList.clear();
00017 }
00018
00019 void ISubject::attach( Interface::Observer * pObserver )
00020 {
00021 if ( qFind( mObserverList.begin(), mObserverList.end(), pObserver ) == mObserverList.end() )
00022 mObserverList.push_back( pObserver );
00023 }
00024
00025 void ISubject::detach( Interface::Observer * pObserver ) {
00026 QValueVector<Interface::Observer*>::iterator it = qFind( mObserverList.begin(), mObserverList.end(), pObserver );
00027 if ( it != mObserverList.end() )
00028 mObserverList.erase( it );
00029 }
00030
00031 void ISubject::notify()
00032 {
00033 kdDebug(5006) << "ISubject::notify " << mObserverList.size() << endl;
00034 for ( QValueVector<Interface::Observer*>::iterator it = mObserverList.begin() ; it != mObserverList.end() ; ++it )
00035 (*it)->update( this );
00036 }
00037
00038 }
00039
|