00001 #ifndef _SLOTRELAYER_H_ 00002 #define _SLOTRELAYER_H_ 00003 00004 #include <QObject> 00005 class QString; 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 00020 public: 00021 SlotRelayer(void (*fp_in)(const QString&)) : 00022 fp_qstring(fp_in), fp_void(0) {} 00023 SlotRelayer(void (*fp_in)()) : fp_qstring(0), fp_void(fp_in) {}; 00024 00025 public slots: 00026 void relay(const QString& arg) {if (fp_qstring) fp_qstring(arg);} 00027 void relay() {if (fp_void) fp_void();} 00028 00029 private: 00030 virtual ~SlotRelayer() {} 00031 void (*fp_qstring)(const QString&); 00032 void (*fp_void)(); 00033 }; 00034 00035 #endif 00036 00037 00038 /* vim: set expandtab tabstop=4 shiftwidth=4: */
1.6.3