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*)) : m_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  { m_fp(e); }
37 
38  protected:
39  ~CustomEventRelayer() override = default;
40 
41  private:
42  void (*m_fp)(QEvent*) {nullptr};
43 };
44 
45 #endif // CUSTOMEVENTRELAYER_H
46 
47 /* vim: set expandtab tabstop=4 shiftwidth=4: */
e
QDomElement e
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1420
CustomEventRelayer
Definition: CustomEventRelayer.h:15
MythObservable::addListener
void addListener(QObject *listener)
Add a listener to the observable.
Definition: mythobservable.cpp:38
CustomEventRelayer::deleteLater
virtual void deleteLater(void)
Definition: CustomEventRelayer.h:29
CustomEventRelayer::CustomEventRelayer
CustomEventRelayer()
Definition: CustomEventRelayer.h:24
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:60
CustomEventRelayer::m_fp
void(* m_fp)(QEvent *)
Definition: CustomEventRelayer.h:42
CustomEventRelayer::customEvent
void customEvent(QEvent *e) override
Definition: CustomEventRelayer.h:35
CustomEventRelayer::CustomEventRelayer
CustomEventRelayer(void(*fp_in)(QEvent *))
Definition: CustomEventRelayer.h:19
mythcorecontext.h
CustomEventRelayer::~CustomEventRelayer
~CustomEventRelayer() override=default
MythObservable::removeListener
void removeListener(QObject *listener)
Remove a listener to the observable.
Definition: mythobservable.cpp:55