00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "wvqthook.moc"
00011
00012 WvQtHook::WvQtHook(WvQtHookCallback _callback) :
00013 callback(_callback)
00014 {
00015 }
00016
00017
00018 void WvQtHook::setcallback(WvQtHookCallback _callback)
00019 {
00020 callback = _callback;
00021 }
00022
00023
00024 bool WvQtHook::event(QEvent *event)
00025 {
00026 if (! callback)
00027 return false;
00028 QEvent::Type eventtype = event->type();
00029 if (eventtype < QEvent::User || eventtype > QEvent::MaxUser)
00030 return false;
00031 QCustomEvent *ce = static_cast<QCustomEvent*>(event);
00032 callback(*this, eventtype - QEvent::User, ce->data());
00033 return true;
00034 }
00035
00036
00037 void WvQtHook::post(int type, void *data)
00038 {
00039
00040 QEvent::Type eventtype = QEvent::Type(QEvent::User + type);
00041 QCustomEvent *event = new QCustomEvent(eventtype, data);
00042 QApplication::postEvent(this, event);
00043 }
00044
00045
00046 void WvQtHook::send(int type, void *data)
00047 {
00048 QEvent::Type eventtype = QEvent::Type(QEvent::User + type);
00049 QCustomEvent event(eventtype, data);
00050 QApplication::sendEvent(this, & event);
00051 }