MythTV  master
CustomEventRelayer.h
Go to the documentation of this file.
1 #ifndef _CUSTOMEVENTRELAYER_H_
2 #define _CUSTOMEVENTRELAYER_H_
3 
4 #include <QObject>
5 
6 #include "mythcorecontext.h"
7 
8 /* This is a simple class that relays a QT custom event to an ordinary function
9  * pointer. Useful when you have a relativly small app like mythcommflag that
10  * you don't want to wrap inside a class.
11  */
12 
13 class QEvent;
14 class CustomEventRelayer : public QObject
15 {
16  Q_OBJECT
17 
18  public:
19  explicit CustomEventRelayer(void (*fp_in)(QEvent*)) : fp(fp_in)
20  {
22  }
23 
25  {
27  }
28 
29  virtual void deleteLater(void)
30  {
32  QObject::deleteLater();
33  }
34 
35  void customEvent(QEvent *e) override //QObject
36  { fp(e); }
37 
38  protected:
39  virtual ~CustomEventRelayer() = default;
40 
41  private:
42  void (*fp)(QEvent*);
43 };
44 
45 #endif
46 
47 
48 /* vim: set expandtab tabstop=4 shiftwidth=4: */
void removeListener(QObject *listener)
Remove a listener to the observable.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
void addListener(QObject *listener)
Add a listener to the observable.
void customEvent(QEvent *e) override
void(* fp)(QEvent *)
virtual ~CustomEventRelayer()=default
CustomEventRelayer(void(*fp_in)(QEvent *))
virtual void deleteLater(void)