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 "mythtypes.h"
7 #include "mythbaseexp.h"
8 
15 class MBASE_PUBLIC MythEvent : public QEvent
16 {
17  public:
18  explicit MythEvent(int type) : QEvent((QEvent::Type)type)
19  { }
20 
21  // lmessage is passed by value for thread safety reasons per DanielK
22  MythEvent(int type, const QString lmessage) : QEvent((QEvent::Type)type),
23  m_message(lmessage), m_extradata("empty")
24  {
25  }
26 
27  // lmessage is passed by value for thread safety reasons per DanielK
28  MythEvent(int type, const QString lmessage, const QStringList &lextradata)
29  : QEvent((QEvent::Type)type),
30  m_message(lmessage), m_extradata(lextradata)
31  {
32  }
33 
34  // lmessage is passed by value for thread safety reasons per DanielK
35  explicit MythEvent(const QString lmessage) : QEvent(MythEventMessage),
36  m_message(lmessage), m_extradata("empty")
37  {
38  }
39 
40  // lmessage is passed by value for thread safety reasons per DanielK
41  MythEvent(const QString lmessage, const QStringList &lextradata)
42  : QEvent(MythEventMessage),
43  m_message(lmessage), m_extradata(lextradata)
44  {
45  }
46 
47  // lmessage is passed by value for thread safety reasons per DanielK
48  MythEvent(const QString lmessage, const QString lextradata)
49  : QEvent(MythEventMessage),
50  m_message(lmessage), m_extradata(lextradata)
51  {
52  }
53 
54 
55  virtual ~MythEvent() = default;
56 
57  const QString& Message() const { return m_message; }
58  const QString& ExtraData(int idx = 0) const { return m_extradata[idx]; }
59  const QStringList& ExtraDataList() const { return m_extradata; }
60  int ExtraDataCount() const { return m_extradata.size(); }
61 
62  virtual MythEvent *clone() const
63  { return new MythEvent(m_message, m_extradata); }
64 
65  static Type MythEventMessage;
66  static Type MythUserMessage;
77 
78  protected:
79  QString m_message;
80  QStringList m_extradata;
81 };
82 
83 class MBASE_PUBLIC ExternalKeycodeEvent : public QEvent
84 {
85  public:
86  explicit ExternalKeycodeEvent(const int key) :
87  QEvent(kEventType), m_keycode(key) {}
88 
89  int getKeycode() { return m_keycode; }
90 
91  static Type kEventType;
92 
93  private:
94  int m_keycode;
95 };
96 
97 class MBASE_PUBLIC UpdateBrowseInfoEvent : public QEvent
98 {
99  public:
100  explicit UpdateBrowseInfoEvent(const InfoMap &infoMap) :
101  QEvent(MythEvent::kUpdateBrowseInfoEventType), im(infoMap) {}
103 };
104 
105 // TODO combine with UpdateBrowseInfoEvent above
107 {
108  public:
109  MythInfoMapEvent(const QString &lmessage,
110  const InfoMap &linfoMap)
111  : MythEvent(lmessage), m_infoMap(linfoMap) { }
112 
113  MythInfoMapEvent *clone() const override // MythEvent
114  { return new MythInfoMapEvent(Message(), m_infoMap); }
115  const InfoMap* GetInfoMap(void) { return &m_infoMap; }
116 
117  private:
119 };
120 
121 #endif /* MYTHEVENT_H */
UpdateBrowseInfoEvent(const InfoMap &infoMap)
Definition: mythevent.h:100
static Type MythEventMessage
Definition: mythevent.h:65
MythEvent(const QString lmessage, const QString lextradata)
Definition: mythevent.h:48
MythEvent(int type)
Definition: mythevent.h:18
MythEvent(const QString lmessage, const QStringList &lextradata)
Definition: mythevent.h:41
MythInfoMapEvent * clone() const override
Definition: mythevent.h:113
static Type kEventType
Definition: mythevent.h:91
static Type kPushDisableDrawingEventType
Definition: mythevent.h:70
static Type kPopDisableDrawingEventType
Definition: mythevent.h:71
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
This class is used as a container for messages.
Definition: mythevent.h:15
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
static Type kLockInputDevicesEventType
Definition: mythevent.h:72
const InfoMap * GetInfoMap(void)
Definition: mythevent.h:115
ExternalKeycodeEvent(const int key)
Definition: mythevent.h:86
MythEvent(int type, const QString lmessage)
Definition: mythevent.h:22
static Type MythUserMessage
Definition: mythevent.h:66
MythEvent(int type, const QString lmessage, const QStringList &lextradata)
Definition: mythevent.h:28
virtual MythEvent * clone() const
Definition: mythevent.h:62
InfoMap m_infoMap
Definition: mythevent.h:118
QString m_message
Definition: mythevent.h:79
static Type kEnableUDPListenerEventType
Definition: mythevent.h:76
static Type kDisableUDPListenerEventType
Definition: mythevent.h:75
static Type kExitToMainMenuEventType
Definition: mythevent.h:68
static Type kUpdateTvProgressEventType
Definition: mythevent.h:67
const QString & ExtraData(int idx=0) const
Definition: mythevent.h:58
MythInfoMapEvent(const QString &lmessage, const InfoMap &linfoMap)
Definition: mythevent.h:109
MythEvent(const QString lmessage)
Definition: mythevent.h:35
QStringList m_extradata
Definition: mythevent.h:80
int ExtraDataCount() const
Definition: mythevent.h:60
const QString & Message() const
Definition: mythevent.h:57
static Type kUpdateBrowseInfoEventType
Definition: mythevent.h:74
static Type kUnlockInputDevicesEventType
Definition: mythevent.h:73
static Type kMythPostShowEventType
Definition: mythevent.h:69
const QStringList & ExtraDataList() const
Definition: mythevent.h:59