MythTV  0.27pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
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 <QHash>
7 
8 #include "mythbaseexp.h"
9 
16 class MBASE_PUBLIC MythEvent : public QEvent
17 {
18  public:
19  MythEvent(int t) : QEvent((QEvent::Type)t)
20  { }
21 
22  // lmessage is passed by value for thread safety reasons per DanielK
23  MythEvent(int t, const QString lmessage) : QEvent((QEvent::Type)t),
24  m_message(lmessage), m_extradata("empty")
25  {
26  }
27 
28  // lmessage is passed by value for thread safety reasons per DanielK
29  MythEvent(int t, const QString lmessage, const QStringList &lextradata)
30  : QEvent((QEvent::Type)t),
31  m_message(lmessage), m_extradata(lextradata)
32  {
33  }
34 
35  // lmessage is passed by value for thread safety reasons per DanielK
36  MythEvent(const QString lmessage) : QEvent(MythEventMessage),
37  m_message(lmessage), m_extradata("empty")
38  {
39  }
40 
41  // lmessage is passed by value for thread safety reasons per DanielK
42  MythEvent(const QString lmessage, const QStringList &lextradata)
43  : QEvent((QEvent::Type)MythEventMessage),
44  m_message(lmessage), m_extradata(lextradata)
45  {
46  }
47 
48  // lmessage is passed by value for thread safety reasons per DanielK
49  MythEvent(const QString lmessage, const QString lextradata)
50  : QEvent((QEvent::Type)MythEventMessage),
51  m_message(lmessage), m_extradata(lextradata)
52  {
53  }
54 
55 
56  virtual ~MythEvent() {}
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;
80 
81  private:
82  QString m_message;
83  QStringList m_extradata;
84 };
85 
86 class MBASE_PUBLIC ExternalKeycodeEvent : public QEvent
87 {
88  public:
89  ExternalKeycodeEvent(const int key) :
90  QEvent(kEventType), m_keycode(key) {}
91 
92  int getKeycode() { return m_keycode; }
93 
94  static Type kEventType;
95 
96  private:
97  int m_keycode;
98 };
99 
100 class MBASE_PUBLIC UpdateBrowseInfoEvent : public QEvent
101 {
102  public:
103  UpdateBrowseInfoEvent(const QHash<QString,QString> &infoMap) :
104  QEvent(MythEvent::kUpdateBrowseInfoEventType), im(infoMap) {}
105  QHash<QString,QString> im;
106 };
107 
108 // TODO combine with UpdateBrowseInfoEvent above
109 class MBASE_PUBLIC MythInfoMapEvent : public MythEvent
110 {
111  public:
112  MythInfoMapEvent(const QString &lmessage,
113  const QHash<QString,QString> &linfoMap)
114  : MythEvent(lmessage), m_infoMap(linfoMap) { }
115 
116  virtual MythInfoMapEvent *clone() const
117  { return new MythInfoMapEvent(Message(), m_infoMap); }
118  const QHash<QString,QString>* InfoMap(void) { return &m_infoMap; }
119 
120  private:
121  QHash<QString,QString> m_infoMap;
122 };
123 
124 #endif /* MYTHEVENT_H */