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