MythTV master
mythevent.h
Go to the documentation of this file.
1#ifndef MYTHEVENT_H_
2#define MYTHEVENT_H_
3
4#include <QStringList>
5#include <QEvent>
6#include <utility>
7#include "mythtypes.h"
8#include "mythbaseexp.h"
9
16class MBASE_PUBLIC MythEvent : public QEvent
17{
18 public:
19 explicit MythEvent(int type) : QEvent((QEvent::Type)type)
20 { }
21
22 // lmessage is passed by value for thread safety reasons per DanielK
23 MythEvent(int type, QString lmessage)
24 : QEvent((QEvent::Type)type),
25 m_message(::std::move(lmessage)),
26 m_extradata("empty")
27 {
28 }
29
30 // lmessage is passed by value for thread safety reasons per DanielK
31 MythEvent(int type, QString lmessage, QStringList lextradata)
32 : QEvent((QEvent::Type)type),
33 m_message(::std::move(lmessage)),
34 m_extradata(std::move(lextradata))
35 {
36 }
37
38 // lmessage is passed by value for thread safety reasons per DanielK
39 explicit MythEvent(QString lmessage)
40 : QEvent(kMythEventMessage),
41 m_message(::std::move(lmessage)),
42 m_extradata("empty")
43 {
44 }
45
46 // lmessage is passed by value for thread safety reasons per DanielK
47 MythEvent(QString lmessage, QStringList lextradata)
48 : QEvent(kMythEventMessage),
49 m_message(::std::move(lmessage)),
50 m_extradata(std::move(lextradata))
51 {
52 }
53
54 // lmessage is passed by value for thread safety reasons per DanielK
55 MythEvent(QString lmessage, const QString& lextradata)
56 : QEvent(kMythEventMessage),
57 m_message(::std::move(lmessage)),
58 m_extradata(lextradata)
59 {
60 }
61
62
63 ~MythEvent() override;
64
65 const QString& Message() const { return m_message; }
66 const QString& ExtraData(int idx = 0) const { return m_extradata[idx]; }
67 const QStringList& ExtraDataList() const { return m_extradata; }
68 int ExtraDataCount() const { return m_extradata.size(); }
69 void log(const QString& prefix);
70
71#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
72 virtual MythEvent *clone() const
73 { return new MythEvent(m_message, m_extradata); }
74#else
75 MythEvent *clone() const override
76 { return new MythEvent(type(), m_message, m_extradata); }
77#endif
78
79 static const Type kMythEventMessage;
80 static const Type kMythUserMessage;
81 static const Type kUpdateTvProgressEventType;
82 static const Type kExitToMainMenuEventType;
83 static const Type kMythPostShowEventType;
85 static const Type kPopDisableDrawingEventType;
86 static const Type kLockInputDevicesEventType;
88 static const Type kUpdateBrowseInfoEventType;
90 static const Type kEnableUDPListenerEventType;
91
92 // No implicit copying.
93 protected:
94 MythEvent(const MythEvent &other) = default;
95 MythEvent &operator=(const MythEvent &other) = default;
96 public:
97 MythEvent(MythEvent &&) = delete;
99
100 protected:
101 QString m_message;
102 QStringList m_extradata;
103};
104
106{
107 public:
108 explicit ExternalKeycodeEvent(const int key) :
109 QEvent(kEventType), m_keycode(key) {}
110
111 int getKeycode() const { return m_keycode; }
112
113 static const Type kEventType;
114
115 private:
117};
118
120{
121 public:
122 explicit UpdateBrowseInfoEvent(InfoMap infoMap) :
123 QEvent(MythEvent::kUpdateBrowseInfoEventType), m_im(std::move(infoMap)) {}
125};
126
127// TODO combine with UpdateBrowseInfoEvent above
129{
130 public:
131 MythInfoMapEvent(const QString &lmessage,
132 InfoMap linfoMap)
133 : MythEvent(lmessage), m_infoMap(std::move(linfoMap)) { }
134
135 MythInfoMapEvent *clone() const override // MythEvent
136 { return new MythInfoMapEvent(Message(), m_infoMap); }
137 const InfoMap* GetInfoMap(void) { return &m_infoMap; }
138
139 private:
141};
142#endif /* MYTHEVENT_H */
static const Type kEventType
Definition: mythevent.h:113
ExternalKeycodeEvent(const int key)
Definition: mythevent.h:108
int getKeycode() const
Definition: mythevent.h:111
This class is used as a container for messages.
Definition: mythevent.h:17
static const Type kExitToMainMenuEventType
Definition: mythevent.h:82
static const Type kPushDisableDrawingEventType
Definition: mythevent.h:84
static const Type kDisableUDPListenerEventType
Definition: mythevent.h:89
QString m_message
Definition: mythevent.h:101
int ExtraDataCount() const
Definition: mythevent.h:68
MythEvent(QString lmessage, QStringList lextradata)
Definition: mythevent.h:47
const QString & Message() const
Definition: mythevent.h:65
MythEvent(int type, QString lmessage, QStringList lextradata)
Definition: mythevent.h:31
MythEvent(QString lmessage)
Definition: mythevent.h:39
static const Type kUnlockInputDevicesEventType
Definition: mythevent.h:87
MythEvent(int type)
Definition: mythevent.h:19
static const Type kPopDisableDrawingEventType
Definition: mythevent.h:85
const QString & ExtraData(int idx=0) const
Definition: mythevent.h:66
static const Type kUpdateTvProgressEventType
Definition: mythevent.h:81
MythEvent & operator=(const MythEvent &other)=default
MythEvent(QString lmessage, const QString &lextradata)
Definition: mythevent.h:55
static const Type kEnableUDPListenerEventType
Definition: mythevent.h:90
MythEvent(const MythEvent &other)=default
const QStringList & ExtraDataList() const
Definition: mythevent.h:67
static const Type kUpdateBrowseInfoEventType
Definition: mythevent.h:88
QStringList m_extradata
Definition: mythevent.h:102
MythEvent(int type, QString lmessage)
Definition: mythevent.h:23
static const Type kMythPostShowEventType
Definition: mythevent.h:83
static const Type kMythEventMessage
Definition: mythevent.h:79
MythEvent(MythEvent &&)=delete
static const Type kMythUserMessage
Definition: mythevent.h:80
static const Type kLockInputDevicesEventType
Definition: mythevent.h:86
MythEvent * clone() const override
Definition: mythevent.h:75
MythEvent & operator=(MythEvent &&)=delete
InfoMap m_infoMap
Definition: mythevent.h:140
MythInfoMapEvent * clone() const override
Definition: mythevent.h:135
MythInfoMapEvent(const QString &lmessage, InfoMap linfoMap)
Definition: mythevent.h:131
const InfoMap * GetInfoMap(void)
Definition: mythevent.h:137
UpdateBrowseInfoEvent(InfoMap infoMap)
Definition: mythevent.h:122
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
STL namespace.
None log(str msg, int level=LOGDEBUG)
Definition: xbmc.py:9