Qt 4.8
Public Functions | Private Functions | Static Private Functions | Properties | List of all members
QBBBpsEventFilter Class Reference

#include <qbbbpseventfilter.h>

Inheritance diagram for QBBBpsEventFilter:
QObject

Public Functions

void installOnEventDispatcher (QAbstractEventDispatcher *dispatcher)
 
 QBBBpsEventFilter (QBBNavigatorEventHandler *navigatorEventHandler, QBBScreenEventHandler *screenEventHandler, QBBVirtualKeyboardBps *virtualKeyboard, QObject *parent=0)
 
void registerForScreenEvents (QBBScreen *screen)
 
void unregisterForScreenEvents (QBBScreen *screen)
 
 ~QBBBpsEventFilter ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Functions

bool bpsEventFilter (bps_event_t *event)
 
bool handleNavigatorEvent (bps_event_t *event)
 

Static Private Functions

static bool dispatcherEventFilter (void *message)
 

Properties

QBBNavigatorEventHandlermNavigatorEventHandler
 
QBBScreenEventHandlermScreenEventHandler
 
QBBVirtualKeyboardBpsmVirtualKeyboard
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 57 of file qbbbpseventfilter.h.

Constructors and Destructors

◆ QBBBpsEventFilter()

QBBBpsEventFilter::QBBBpsEventFilter ( QBBNavigatorEventHandler navigatorEventHandler,
QBBScreenEventHandler screenEventHandler,
QBBVirtualKeyboardBps virtualKeyboard,
QObject parent = 0 
)

Definition at line 62 of file qbbbpseventfilter.cpp.

65  : QObject(parent)
66  , mNavigatorEventHandler(navigatorEventHandler)
67  , mScreenEventHandler(screenEventHandler)
68  , mVirtualKeyboard(virtualKeyboard)
69 {
70  Q_ASSERT(sInstance == 0);
71 
72  sInstance = this;
73 }
QBBScreenEventHandler * mScreenEventHandler
QBBNavigatorEventHandler * mNavigatorEventHandler
QBBVirtualKeyboardBps * mVirtualKeyboard
static QBBBpsEventFilter * sInstance
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

◆ ~QBBBpsEventFilter()

QBBBpsEventFilter::~QBBBpsEventFilter ( )

Definition at line 75 of file qbbbpseventfilter.cpp.

76 {
77  Q_ASSERT(sInstance == this);
78 
79  sInstance = 0;
80 }
static QBBBpsEventFilter * sInstance
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

Functions

◆ bpsEventFilter()

bool QBBBpsEventFilter::bpsEventFilter ( bps_event_t *  event)
private

Definition at line 147 of file qbbbpseventfilter.cpp.

Referenced by dispatcherEventFilter().

148 {
149  const int eventDomain = bps_event_get_domain(event);
150 
151 #if defined(QBBBPSEVENTFILTER_DEBUG)
152  qDebug() << Q_FUNC_INFO << "event=" << event << "domain=" << eventDomain;
153 #endif
154 
155  if (eventDomain == screen_get_domain()) {
156  if (!mScreenEventHandler) {
157  qWarning("QBB: registered for screen events, but no handler provided");
158  return false;
159  }
160 
161  screen_event_t screenEvent = screen_event_get_event(event);
162  return mScreenEventHandler->handleEvent(screenEvent);
163  }
164 
165  if (eventDomain == navigator_get_domain())
166  return handleNavigatorEvent(event);
167 
169  return true;
170 
171  return false;
172 }
QBBScreenEventHandler * mScreenEventHandler
QBBVirtualKeyboardBps * mVirtualKeyboard
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
Q_CORE_EXPORT void qDebug(const char *,...)
bool handleEvent(screen_event_t event)
Q_CORE_EXPORT void qWarning(const char *,...)
bool handleEvent(bps_event_t *event)
bool handleNavigatorEvent(bps_event_t *event)
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ dispatcherEventFilter()

bool QBBBpsEventFilter::dispatcherEventFilter ( void *  message)
staticprivate

Definition at line 135 of file qbbbpseventfilter.cpp.

Referenced by installOnEventDispatcher().

136 {
137 #if defined(QBBBPSEVENTFILTER_DEBUG)
138  qDebug() << Q_FUNC_INFO;
139 #endif
140  if (sInstance == 0)
141  return false;
142 
143  bps_event_t *event = static_cast<bps_event_t *>(message);
144  return sInstance->bpsEventFilter(event);
145 }
static QBBBpsEventFilter * sInstance
bool bpsEventFilter(bps_event_t *event)
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
Q_CORE_EXPORT void qDebug(const char *,...)
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ handleNavigatorEvent()

bool QBBBpsEventFilter::handleNavigatorEvent ( bps_event_t *  event)
private

Definition at line 174 of file qbbbpseventfilter.cpp.

Referenced by bpsEventFilter().

175 {
176  switch (bps_event_get_code(event)) {
177  case NAVIGATOR_ORIENTATION_CHECK: {
178  const int angle = navigator_event_get_orientation_angle(event);
179 
180  #if defined(QBBBPSEVENTFILTER_DEBUG)
181  qDebug() << "QBB: Navigator ORIENTATION CHECK event. angle=" << angle;
182  #endif
183 
184  const bool result = mNavigatorEventHandler->handleOrientationCheck(angle);
185 
186  #if defined(QBBBPSEVENTFILTER_DEBUG)
187  qDebug() << "QBB: Navigator ORIENTATION CHECK event. result=" << result;
188  #endif
189 
190  // reply to navigator whether orientation is acceptable
191  navigator_orientation_check_response(event, result);
192  break;
193  }
194 
195  case NAVIGATOR_ORIENTATION: {
196  const int angle = navigator_event_get_orientation_angle(event);
197 
198  #if defined(QBBBPSEVENTFILTER_DEBUG)
199  qDebug() << "QBB: Navigator ORIENTATION event. angle=" << angle;
200  #endif
201 
203 
204  navigator_done_orientation(event);
205  break;
206  }
207 
208  case NAVIGATOR_SWIPE_DOWN:
209  #if defined(QBBBPSEVENTFILTER_DEBUG)
210  qDebug() << "QBB: Navigator SWIPE DOWN event";
211  #endif
212 
214  break;
215 
216  case NAVIGATOR_EXIT:
217  #if defined(QBBBPSEVENTFILTER_DEBUG)
218  qDebug() << "QBB: Navigator EXIT event";
219  #endif
220 
222  break;
223 
224  case NAVIGATOR_WINDOW_STATE: {
225  #if defined(QBBBPSEVENTFILTER_DEBUG)
226  qDebug() << Q_FUNC_INFO << "WINDOW STATE event";
227  #endif
228 
229  const navigator_window_state_t state = navigator_event_get_window_state(event);
230  const QByteArray id(navigator_event_get_groupid(event));
231 
232  switch (state) {
233  case NAVIGATOR_WINDOW_FULLSCREEN:
235  break;
236  case NAVIGATOR_WINDOW_THUMBNAIL:
238  break;
239  case NAVIGATOR_WINDOW_INVISIBLE:
241  break;
242  }
243 
244  break;
245  }
246 
247  case NAVIGATOR_WINDOW_ACTIVE: {
248  #if defined(QBBBPSEVENTFILTER_DEBUG)
249  qDebug() << "QBB: Navigator WINDOW ACTIVE event";
250  #endif
251 
252  const QByteArray id(navigator_event_get_groupid(event));
254  break;
255  }
256 
257  case NAVIGATOR_WINDOW_INACTIVE: {
258  #if defined(QBBBPSEVENTFILTER_DEBUG)
259  qDebug() << "QBB: Navigator WINDOW INACTIVE event";
260  #endif
261 
262  const QByteArray id(navigator_event_get_groupid(event));
264  break;
265  }
266 
267  case NAVIGATOR_LOW_MEMORY:
268  qWarning() << "QApplication based process" << QCoreApplication::applicationPid()
269  << "received \"NAVIGATOR_LOW_MEMORY\" event";
270  return false;
271 
272  default:
273  #if defined(QBBBPSEVENTFILTER_DEBUG)
274  qDebug() << "QBB: Unhandled navigator event. code=" << bps_event_get_code(event);
275  #endif
276  return false;
277  }
278 
279  return true;
280 }
void handleWindowGroupActivated(const QByteArray &id)
QBBNavigatorEventHandler * mNavigatorEventHandler
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void handleWindowGroupDeactivated(const QByteArray &id)
void handleWindowGroupStateChanged(const QByteArray &id, Qt::WindowState state)
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT void qWarning(const char *,...)
static qint64 applicationPid()
Returns the current process ID for the application.
qreal angle(const QPointF &p1, const QPointF &p2)
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ installOnEventDispatcher()

void QBBBpsEventFilter::installOnEventDispatcher ( QAbstractEventDispatcher dispatcher)

Definition at line 82 of file qbbbpseventfilter.cpp.

Referenced by QBBIntegration::QBBIntegration().

83 {
84 #if defined(QBBBPSEVENTFILTER_DEBUG)
85  qDebug() << Q_FUNC_INFO << "dispatcher=" << dispatcher;
86 #endif
87  if (navigator_request_events(0) != BPS_SUCCESS)
88  qWarning("QBB: failed to register for navigator events");
89 
90  QAbstractEventDispatcher::EventFilter previousEventFilter = dispatcher->setEventFilter(dispatcherEventFilter);
91 
92  // the QPA plugin in created in the QApplication constructor which indirectly also creates
93  // the event dispatcher so we are the first event filter.
94  // assert on that just in case somebody adds another event filter
95  // in the QBBIntegration constructor instead of adding a new section in here
96  Q_ASSERT(previousEventFilter == 0);
97  Q_UNUSED(previousEventFilter);
98 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT void qWarning(const char *,...)
static bool dispatcherEventFilter(void *message)
bool(* EventFilter)(void *message)
Typedef for a function with the signature.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ registerForScreenEvents()

void QBBBpsEventFilter::registerForScreenEvents ( QBBScreen screen)

Definition at line 100 of file qbbbpseventfilter.cpp.

Referenced by QBBIntegration::QBBIntegration().

101 {
102  if (!mScreenEventHandler) {
103  qWarning("QBB: trying to register for screen events, but no handler provided");
104  return;
105  }
106 
107  int attached;
108  if (screen_get_display_property_iv(screen->nativeDisplay(), SCREEN_PROPERTY_ATTACHED, &attached) != BPS_SUCCESS) {
109  qWarning() << "QBB: unable to query display attachment";
110  return;
111  }
112 
113  if (!attached) {
114 #if defined(QBBBPSEVENTFILTER_DEBUG)
115  qDebug() << Q_FUNC_INFO << "skipping event registration for non-attached screen";
116 #endif
117  return;
118  }
119 
120  if (screen_request_events(screen->nativeContext()) != BPS_SUCCESS)
121  qWarning("QBB: failed to register for screen events on screen %p", screen->nativeContext());
122 }
QBBScreenEventHandler * mScreenEventHandler
screen_context_t nativeContext() const
Definition: qbbscreen.h:73
Q_CORE_EXPORT void qDebug(const char *,...)
Q_CORE_EXPORT void qWarning(const char *,...)
screen_display_t nativeDisplay() const
Definition: qbbscreen.h:72
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ unregisterForScreenEvents()

void QBBBpsEventFilter::unregisterForScreenEvents ( QBBScreen screen)

Definition at line 124 of file qbbbpseventfilter.cpp.

Referenced by QBBIntegration::~QBBIntegration().

125 {
126  if (!mScreenEventHandler) {
127  qWarning("QBB: trying to unregister for screen events, but no handler provided");
128  return;
129  }
130 
131  if (screen_stop_events(screen->nativeContext()) != BPS_SUCCESS)
132  qWarning("QBB: failed to unregister for screen events on screen %p", screen->nativeContext());
133 }
QBBScreenEventHandler * mScreenEventHandler
screen_context_t nativeContext() const
Definition: qbbscreen.h:73
Q_CORE_EXPORT void qWarning(const char *,...)

Properties

◆ mNavigatorEventHandler

QBBNavigatorEventHandler* QBBBpsEventFilter::mNavigatorEventHandler
private

Definition at line 78 of file qbbbpseventfilter.h.

Referenced by handleNavigatorEvent().

◆ mScreenEventHandler

QBBScreenEventHandler* QBBBpsEventFilter::mScreenEventHandler
private

◆ mVirtualKeyboard

QBBVirtualKeyboardBps* QBBBpsEventFilter::mVirtualKeyboard
private

Definition at line 80 of file qbbbpseventfilter.h.

Referenced by bpsEventFilter().


The documentation for this class was generated from the following files: