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