MythTV
master
mythtv
programs
mythcommflag
SlotRelayer.h
Go to the documentation of this file.
1
#ifndef SLOTRELAYER_H
2
#define SLOTRELAYER_H
3
4
#include <QObject>
5
class
QString;
6
7
/* This is a simple class that relays a QT slot to a function pointer.
8
* Useful when you have a relativly small app like mythcommflag that you
9
* don't want to wrap inside a QObject enheriting class.
10
*
11
* Unfortunattely QT does not allow this class to be templatized for all
12
* possible parameter types, so manual labor is in order if you need types other
13
* than the ones I made here
14
*/
15
16
class
SlotRelayer
:
public
QObject
17
{
18
Q_OBJECT
19
20
public
:
21
explicit
SlotRelayer
(
void
(*fp_in)(
const
QString&)) :
m_fpQstring
(fp_in) {}
22
explicit
SlotRelayer
(
void
(*fp_in)()) :
m_fpVoid
(fp_in) {};
23
24
public
slots:
25
void
relay
(
const
QString& arg) {
if
(
m_fpQstring
)
m_fpQstring
(arg);}
26
void
relay
() {
if
(
m_fpVoid
)
m_fpVoid
();}
27
28
private
:
29
~SlotRelayer
()
override
=
default
;
30
void (*
m_fpQstring
)(
const
QString&) {
nullptr
};
31
void (*
m_fpVoid
)() {
nullptr
};
32
};
33
34
#endif // SLOTRELAYER_H
35
36
/* vim: set expandtab tabstop=4 shiftwidth=4: */
SlotRelayer::SlotRelayer
SlotRelayer(void(*fp_in)(const QString &))
Definition:
SlotRelayer.h:21
SlotRelayer::m_fpVoid
void(* m_fpVoid)()
Definition:
SlotRelayer.h:31
SlotRelayer::relay
void relay(const QString &arg)
Definition:
SlotRelayer.h:25
SlotRelayer::m_fpQstring
void(* m_fpQstring)(const QString &)
Definition:
SlotRelayer.h:30
SlotRelayer
Definition:
SlotRelayer.h:16
SlotRelayer::relay
void relay()
Definition:
SlotRelayer.h:26
SlotRelayer::SlotRelayer
SlotRelayer(void(*fp_in)())
Definition:
SlotRelayer.h:22
SlotRelayer::~SlotRelayer
~SlotRelayer() override=default
Generated on Mon Nov 25 2024 03:16:17 for MythTV by
1.8.17