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 
16 class 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(MythEventMessage),
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(MythEventMessage),
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(MythEventMessage),
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 
70 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
71  virtual MythEvent *clone() const
72  { return new MythEvent(m_message, m_extradata); }
73 #else
74  MythEvent *clone() const override
75  { return new MythEvent(type(), m_message, m_extradata); }
76 #endif
77 
78  static Type MythEventMessage;
79  static Type MythUserMessage;
90 
91  // No implicit copying.
92  protected:
93  MythEvent(const MythEvent &other) = default;
94  MythEvent &operator=(const MythEvent &other) = default;
95  public:
96  MythEvent(MythEvent &&) = delete;
97  MythEvent &operator=(MythEvent &&) = delete;
98 
99  protected:
100  QString m_message;
101  QStringList m_extradata;
102 };
103 
104 class MBASE_PUBLIC ExternalKeycodeEvent : public QEvent
105 {
106  public:
107  explicit ExternalKeycodeEvent(const int key) :
108  QEvent(kEventType), m_keycode(key) {}
109 
110  int getKeycode() const { return m_keycode; }
111 
112  static Type kEventType;
113 
114  private:
116 };
117 
118 class MBASE_PUBLIC UpdateBrowseInfoEvent : public QEvent
119 {
120  public:
121  explicit UpdateBrowseInfoEvent(InfoMap infoMap) :
122  QEvent(MythEvent::kUpdateBrowseInfoEventType), m_im(std::move(infoMap)) {}
124 };
125 
126 // TODO combine with UpdateBrowseInfoEvent above
128 {
129  public:
130  MythInfoMapEvent(const QString &lmessage,
131  InfoMap linfoMap)
132  : MythEvent(lmessage), m_infoMap(std::move(linfoMap)) { }
133 
134  MythInfoMapEvent *clone() const override // MythEvent
135  { return new MythInfoMapEvent(Message(), m_infoMap); }
136  const InfoMap* GetInfoMap(void) { return &m_infoMap; }
137 
138  private:
140 };
141 #endif /* MYTHEVENT_H */
MythEvent::kLockInputDevicesEventType
static Type kLockInputDevicesEventType
Definition: mythevent.h:85
MythEvent::MythEventMessage
static Type MythEventMessage
Definition: mythevent.h:78
MythEvent::MythEvent
MythEvent(int type, QString lmessage, QStringList lextradata)
Definition: mythevent.h:31
MythEvent::kPushDisableDrawingEventType
static Type kPushDisableDrawingEventType
Definition: mythevent.h:83
mythbaseexp.h
ExternalKeycodeEvent::m_keycode
int m_keycode
Definition: mythevent.h:115
MythEvent::kPopDisableDrawingEventType
static Type kPopDisableDrawingEventType
Definition: mythevent.h:84
MythEvent
This class is used as a container for messages.
Definition: mythevent.h:16
MythEvent::ExtraDataCount
int ExtraDataCount() const
Definition: mythevent.h:68
MythEvent::m_extradata
QStringList m_extradata
Definition: mythevent.h:101
MythEvent::MythEvent
MythEvent(int type, QString lmessage)
Definition: mythevent.h:23
MythEvent::MythEvent
MythEvent(QString lmessage, QStringList lextradata)
Definition: mythevent.h:47
MythEvent::Message
const QString & Message() const
Definition: mythevent.h:65
MythEvent::MythUserMessage
static Type MythUserMessage
Definition: mythevent.h:79
MythEvent::kExitToMainMenuEventType
static Type kExitToMainMenuEventType
Definition: mythevent.h:81
MythEvent::kUpdateBrowseInfoEventType
static Type kUpdateBrowseInfoEventType
Definition: mythevent.h:87
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
UpdateBrowseInfoEvent::UpdateBrowseInfoEvent
UpdateBrowseInfoEvent(InfoMap infoMap)
Definition: mythevent.h:121
ExternalKeycodeEvent
Definition: mythevent.h:104
MBASE_PUBLIC
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
MythEvent::ExtraData
const QString & ExtraData(int idx=0) const
Definition: mythevent.h:66
MythEvent::MythEvent
MythEvent(QString lmessage)
Definition: mythevent.h:39
ExternalKeycodeEvent::ExternalKeycodeEvent
ExternalKeycodeEvent(const int key)
Definition: mythevent.h:107
MythInfoMapEvent::clone
MythInfoMapEvent * clone() const override
Definition: mythevent.h:134
mythtypes.h
MythEvent::kUpdateTvProgressEventType
static Type kUpdateTvProgressEventType
Definition: mythevent.h:80
MythInfoMapEvent::MythInfoMapEvent
MythInfoMapEvent(const QString &lmessage, InfoMap linfoMap)
Definition: mythevent.h:130
UpdateBrowseInfoEvent
Definition: mythevent.h:118
MythEvent::kDisableUDPListenerEventType
static Type kDisableUDPListenerEventType
Definition: mythevent.h:88
MythInfoMapEvent::GetInfoMap
const InfoMap * GetInfoMap(void)
Definition: mythevent.h:136
MythEvent::ExtraDataList
const QStringList & ExtraDataList() const
Definition: mythevent.h:67
MythEvent::MythEvent
MythEvent(int type)
Definition: mythevent.h:19
MythInfoMapEvent
Definition: mythevent.h:127
MythEvent::kUnlockInputDevicesEventType
static Type kUnlockInputDevicesEventType
Definition: mythevent.h:86
MythEvent::clone
MythEvent * clone() const override
Definition: mythevent.h:74
std
Definition: mythchrono.h:23
MythEvent::kMythPostShowEventType
static Type kMythPostShowEventType
Definition: mythevent.h:82
ExternalKeycodeEvent::kEventType
static Type kEventType
Definition: mythevent.h:112
UpdateBrowseInfoEvent::m_im
InfoMap m_im
Definition: mythevent.h:123
MythEvent::MythEvent
MythEvent(QString lmessage, const QString &lextradata)
Definition: mythevent.h:55
MythEvent::m_message
QString m_message
Definition: mythevent.h:100
ExternalKeycodeEvent::getKeycode
int getKeycode() const
Definition: mythevent.h:110
MythInfoMapEvent::m_infoMap
InfoMap m_infoMap
Definition: mythevent.h:139
MythEvent::kEnableUDPListenerEventType
static Type kEnableUDPListenerEventType
Definition: mythevent.h:89