MythTV
master
mythtv
programs
mythcommflag
CustomEventRelayer.h
Go to the documentation of this file.
1
#ifndef CUSTOMEVENTRELAYER_H
2
#define CUSTOMEVENTRELAYER_H
3
4
#include <QObject>
5
6
#include "
libmythbase/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
{
21
gCoreContext
->
addListener
(
this
);
22
}
23
24
CustomEventRelayer
()
25
{
26
gCoreContext
->
addListener
(
this
);
27
}
28
29
virtual
void
deleteLater
(
void
)
30
{
31
gCoreContext
->
removeListener
(
this
);
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: */
CustomEventRelayer
Definition:
CustomEventRelayer.h:14
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:55
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
Generated on Sun Jan 5 2025 03:16:28 for MythTV by
1.8.17