00001 #ifndef _CUSTOMEVENTRELAYER_H_ 00002 #define _CUSTOMEVENTRELAYER_H_ 00003 00004 #include <QObject> 00005 00006 #include "mythcorecontext.h" 00007 00008 /* This is a simple class that relays a QT custom event to an ordinary function 00009 * pointer. Useful when you have a relativly small app like mythcommflag that 00010 * you don't want to wrap inside a class. 00011 */ 00012 00013 class QEvent; 00014 class CustomEventRelayer : public QObject 00015 { 00016 Q_OBJECT 00017 00018 public: 00019 CustomEventRelayer(void (*fp_in)(QEvent*)) : fp(fp_in) 00020 { 00021 gCoreContext->addListener(this); 00022 } 00023 00024 CustomEventRelayer() 00025 { 00026 gCoreContext->addListener(this); 00027 } 00028 00029 virtual void deleteLater(void) 00030 { 00031 gCoreContext->removeListener(this); 00032 QObject::deleteLater(); 00033 } 00034 00035 void customEvent(QEvent *e) { fp(e); } 00036 00037 protected: 00038 virtual ~CustomEventRelayer() {} 00039 00040 private: 00041 void (*fp)(QEvent*); 00042 }; 00043 00044 #endif 00045 00046 00047 /* vim: set expandtab tabstop=4 shiftwidth=4: */
1.6.3