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