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