libqutim  0.3.1.0
event.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** qutIM - instant messenger
4 **
5 ** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru>
6 **
7 *****************************************************************************
8 **
9 ** $QUTIM_BEGIN_LICENSE$
10 ** This program is free software: you can redistribute it and/or modify
11 ** it under the terms of the GNU General Public License as published by
12 ** the Free Software Foundation, either version 3 of the License, or
13 ** (at your option) any later version.
14 **
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 ** See the GNU General Public License for more details.
19 **
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program. If not, see http://www.gnu.org/licenses/.
22 ** $QUTIM_END_LICENSE$
23 **
24 ****************************************************************************/
25 
26 #ifndef EVENT_H
27 #define EVENT_H
28 
29 #include "libqutim_global.h"
30 #include <QtCore/QVariant>
31 #include <QtCore/QVarLengthArray>
32 #include <QtCore/QObject>
33 #include <QtCore/QEvent>
34 
35 namespace qutim_sdk_0_3
36 {
37 class LIBQUTIM_EXPORT Event : public QEvent
38 {
39 public:
40  inline Event(const char *id = 0, const QVariant &arg0 = QVariant(),
41  const QVariant &arg1 = QVariant(), const QVariant &arg2 = QVariant(),
42  const QVariant &arg3 = QVariant(), const QVariant &arg4 = QVariant());
43 
44  inline Event(quint16 id, const QVariant &arg0 = QVariant(),
45  const QVariant &arg1 = QVariant(), const QVariant &arg2 = QVariant(),
46  const QVariant &arg3 = QVariant(), const QVariant &arg4 = QVariant());
47 
48  static QEvent::Type eventType();
49  static quint16 registerType(const char *id);
50  static const char *getId(quint16 id);
51  static QObject *eventManager();
52 
53  template<typename T>
54  T at(int index) const { return args[index].value<T>(); }
55  void send();
56 
57  quint16 id;
58  QVarLengthArray<QVariant, 5> args;
59 };
60 
61 Event::Event(const char *id, const QVariant &arg0, const QVariant &arg1, const QVariant &arg2,
62  const QVariant &arg3, const QVariant &arg4) : QEvent(eventType()), args(5)
63 {
64  this->id = registerType(id);
65  args[0] = arg0; args[1] = arg1; args[2] = arg2; args[3] = arg3; args[4] = arg4;
66 }
67 
68 Event::Event(quint16 id, const QVariant &arg0, const QVariant &arg1, const QVariant &arg2,
69  const QVariant &arg3, const QVariant &arg4) : QEvent(eventType()), args(5)
70 {
71  this->id = id;
72  args[0] = arg0; args[1] = arg1; args[2] = arg2; args[3] = arg3; args[4] = arg4;
73 }
74 
75 LIBQUTIM_EXPORT QDebug operator<<(QDebug, const Event &);
76 }
77 
78 #endif // EVENT_H
79 

Generated by Doxygen