00001 #ifndef _SLOTRELAYER_H_ 00002 #define _SLOTRELAYER_H_ 00003 00004 #include "qobject.h" 00005 #include "qstring.h" 00006 00007 /* This is a simple class that relays a QT slot to a function pointer. 00008 * Useful when you have a relativly small app like mythcommflag that you 00009 * don't want to wrap inside a QObject enheriting class. 00010 * 00011 * Unfortunattely QT does not allow this class to be templatized for all 00012 * possible parameter types, so manual labor is in order if you need types other 00013 * than the ones I made here 00014 */ 00015 00016 class SlotRelayer : public QObject 00017 { 00018 Q_OBJECT 00019 public: 00020 SlotRelayer(void (*fp_in)(const QString&)) : fp_qstring(fp_in), fp_void(0) {}; 00021 SlotRelayer(void (*fp_in)()) : fp_qstring(0), fp_void(fp_in) {}; 00022 ~SlotRelayer() {} 00023 00024 public slots: 00025 void relay(const QString& arg) {if (fp_qstring) fp_qstring(arg);} 00026 void relay() {if (fp_void) fp_void();} 00027 00028 private: 00029 void (*fp_qstring)(const QString&); 00030 void (*fp_void)(); 00031 }; 00032 00033 #endif 00034 00035 00036 /* vim: set expandtab tabstop=4 shiftwidth=4: */
1.5.5