예제 #1
0
bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event) {
    if (!filterEnabled(originalDestination, event)) {
        return false;
    }
#ifdef DEBUG
    // Don't intercept our own events, or we enter an infinite recursion
    {
        auto rootItem = _sharedObject->getRootItem();
        auto quickWindow = _sharedObject->getWindow();
        QObject* recurseTest = originalDestination;
        while (recurseTest) {
            Q_ASSERT(recurseTest != rootItem && recurseTest != quickWindow);
            recurseTest = recurseTest->parent();
        }
    }
#endif

    switch (event->type()) {
        case QEvent::KeyPress:
        case QEvent::KeyRelease: {
            event->ignore();
            if (QCoreApplication::sendEvent(_sharedObject->getWindow(), event)) {
                return event->isAccepted();
            }
            break;
        }

        case QEvent::Wheel: {
            QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event);
            QPointF transformedPos = mapToVirtualScreen(wheelEvent->pos());
            QWheelEvent mappedEvent(transformedPos, wheelEvent->delta(), wheelEvent->buttons(), wheelEvent->modifiers(),
                                    wheelEvent->orientation());
            mappedEvent.ignore();
            if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) {
                return mappedEvent.isAccepted();
            }
            break;
        }
        case QEvent::MouseMove: {
            QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
            QPointF transformedPos = mapToVirtualScreen(mouseEvent->localPos());
            QMouseEvent mappedEvent(mouseEvent->type(), transformedPos, mouseEvent->screenPos(), mouseEvent->button(),
                                    mouseEvent->buttons(), mouseEvent->modifiers());
            if (event->type() == QEvent::MouseMove) {
                // TODO - this line necessary for the QML Tooltop to work (which is not currently being used), but it causes interface to crash on launch on a fresh install
                // need to investigate into why this crash is happening.
                //_qmlContext->setContextProperty("lastMousePosition", transformedPos);
            }
            mappedEvent.ignore();
            if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) {
                return mappedEvent.isAccepted();
            }
            break;
        }
        default:
            break;
    }

    return false;
}
예제 #2
0
bool WebPage::event(QEvent *ev)
{
    QMouseEvent* mouseEvent = NULL;
    QWheelEvent* wheelEvent = NULL;
    QKeyEvent* keyEvent = NULL;
    
    QByteArray byteArray;
    QBuffer buffer(&byteArray);
    buffer.open(QIODevice::ReadWrite);

    QDataStream out(&buffer);

    out << (int) ev->type();
    
    switch (ev->type()) {
    case QEvent::MouseMove:
    case QEvent::MouseButtonPress:
    case QEvent::MouseButtonDblClick:
    case QEvent::MouseButtonRelease:
        if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica())
            return false;
        mouseEvent = (static_cast<QMouseEvent*>(ev));
        out << mouseEvent->pos() << mouseEvent->globalPos()
            << (int) mouseEvent->button() << (int) mouseEvent->buttons()
            << (int) mouseEvent->modifiers();
        OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray);
        break;
    case QEvent::Wheel:
        if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica())
            return false;;
        wheelEvent = (static_cast<QWheelEvent*>(ev));
        out << wheelEvent->pos() << wheelEvent->globalPos()
            << wheelEvent->delta() << (int) wheelEvent->buttons()
            << (int) wheelEvent->modifiers() << (int) wheelEvent->orientation();
        OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray);
        break;
    case QEvent::KeyPress:
    case QEvent::KeyRelease:
        if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica())
            return false;
        keyEvent = (static_cast<QKeyEvent*>(ev));
        out << keyEvent->key() << (int) keyEvent->modifiers()
            << keyEvent->text() << keyEvent->isAutoRepeat()
            << (int) keyEvent->count();
        OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray);
        break;
    default:
        break;
    }

    return QWebPage::event(ev);
}
예제 #3
0
파일: wheelbox.cpp 프로젝트: Spinetta/qwt
    virtual bool eventFilter( QObject *object, QEvent *event )
    {
        if ( event->type() == QEvent::Wheel )
        {
            QWheelEvent *we = ( QWheelEvent * )event;

            QWheelEvent wheelEvent( QPoint( 5, 5 ), we->delta(),
                we->buttons(), we->modifiers(),
                we->orientation() );

            QApplication::sendEvent( this, &wheelEvent );
            return true;
        }
        return QwtWheel::eventFilter( object, event );
    }
예제 #4
0
void WebView::mouseWheelTimerFired()
{
   pMouseWheelTimer_->stop();

   if (mouseWheelEvents_.empty())
      return;

   int totalDelta = 0;
   for (int i = 0; i < mouseWheelEvents_.length(); i++)
   {
      totalDelta += mouseWheelEvents_.at(i).delta();
   }
   QWheelEvent event = mouseWheelEvents_.last();
   mouseWheelEvents_.clear();

   while (totalDelta != 0)
   {
      // If the absolute delta value exceeds 5000, Ace editor
      // goes into a super fine granularity mode that we need
      // to avoid
      const int MAX_ABS_DELTA_VALUE = 5000;

      int thisDelta = totalDelta;
      if (thisDelta > MAX_ABS_DELTA_VALUE)
      {
         thisDelta = MAX_ABS_DELTA_VALUE;
      }
      else if (thisDelta < -MAX_ABS_DELTA_VALUE)
      {
         thisDelta = -MAX_ABS_DELTA_VALUE;
      }
      totalDelta -= thisDelta;

      QWheelEvent totalEvent(event.pos(),
                             event.globalPos(),
                             thisDelta,
                             event.buttons(),
                             event.modifiers(),
                             event.orientation());
      this->QWebView::wheelEvent(&totalEvent);
   }
}
예제 #5
0
bool
ArtistInfoWidget::eventFilter( QObject* obj, QEvent* event )
{
    if ( event->type() == QEvent::Wheel )
    {
        QWheelEvent* we = static_cast<QWheelEvent*>( event );
        QWheelEvent* wheelEvent = new QWheelEvent(
            we->pos(),
            we->globalPos(),
            we->delta(),
            we->buttons(),
            we->modifiers(),
            we->orientation() );

        qApp->postEvent( m_area->viewport(), wheelEvent );
        event->accept();
        return true;
    }
    else
        return QObject::eventFilter( obj, event );
}
예제 #6
0
void WebView::mouseWheelTimerFired()
{
   pMouseWheelTimer_->stop();

   if (mouseWheelEvents_.empty())
      return;

   int totalDelta = 0;
   for (int i = 0; i < mouseWheelEvents_.length(); i++)
   {
      totalDelta += mouseWheelEvents_.at(i).delta();
   }
   QWheelEvent event = mouseWheelEvents_.last();
   mouseWheelEvents_.clear();
   QWheelEvent totalEvent(event.pos(),
                          event.globalPos(),
                          totalDelta,
                          event.buttons(),
                          event.modifiers(),
                          event.orientation());
   this->QWebView::wheelEvent(&totalEvent);
}
예제 #7
0
bool QtWebKitWebWidget::eventFilter(QObject *object, QEvent *event)
{
	if (object == m_webView)
	{
		if (event->type() == QEvent::Resize)
		{
			emit progressBarGeometryChanged();
		}
		else if (event->type() == QEvent::ToolTip && m_isLinkHovered)
		{
			event->accept();

			return true;
		}
		else if (event->type() == QEvent::MouseButtonPress)
		{
			QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);

			if (mouseEvent->button() == Qt::MiddleButton)
			{
				QWebHitTestResult result = m_webView->page()->mainFrame()->hitTestContent(mouseEvent->pos());

				if (result.linkUrl().isValid())
				{
					emit requestedOpenUrl(result.linkUrl(), true, false);

					event->accept();

					return true;
				}
			}

			if (mouseEvent->button() == Qt::BackButton)
			{
				triggerAction(GoBackAction);

				event->accept();

				return true;
			}

			if (mouseEvent->button() == Qt::ForwardButton)
			{
				triggerAction(GoForwardAction);

				event->accept();

				return true;
			}
		}
		else if (event->type() == QEvent::MouseButtonDblClick && SettingsManager::getValue(QLatin1String("Browser/ShowSelectionContextMenuOnDoubleClick")).toBool())
		{
			QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);

			if (mouseEvent && mouseEvent->button() == Qt::LeftButton)
			{
				QTimer::singleShot(250, this, SLOT(showContextMenu()));
			}
		}
		else if (event->type() == QEvent::Wheel)
		{
			QWheelEvent *wheelEvent = static_cast<QWheelEvent*>(event);

			if (wheelEvent->modifiers() & Qt::CTRL || wheelEvent->buttons() & Qt::LeftButton)
			{
				setZoom(getZoom() + (wheelEvent->delta() / 16));

				event->accept();

				return true;
			}

		}
	}

	return QObject::eventFilter(object, event);
}
예제 #8
0
bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event) {
    if (!filterEnabled(originalDestination, event)) {
        return false;
    }
#ifdef DEBUG
    // Don't intercept our own events, or we enter an infinite recursion
    {
        auto rootItem = _sharedObject->getRootItem();
        auto quickWindow = _sharedObject->getWindow();
        QObject* recurseTest = originalDestination;
        while (recurseTest) {
            Q_ASSERT(recurseTest != rootItem && recurseTest != quickWindow);
            recurseTest = recurseTest->parent();
        }
    }
#endif

    switch (event->type()) {
        case QEvent::KeyPress:
        case QEvent::KeyRelease: {
            event->ignore();
            if (QCoreApplication::sendEvent(_sharedObject->getWindow(), event)) {
                return event->isAccepted();
            }
            break;
        }

        case QEvent::Wheel: {
            QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event);
            QPointF transformedPos = mapToVirtualScreen(wheelEvent->pos());
            QWheelEvent mappedEvent(transformedPos, wheelEvent->delta(), wheelEvent->buttons(), wheelEvent->modifiers(),
                                    wheelEvent->orientation());
            mappedEvent.ignore();
            if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) {
                return mappedEvent.isAccepted();
            }
            break;
        }
        case QEvent::MouseMove: {
            QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
            QPointF transformedPos = mapToVirtualScreen(mouseEvent->localPos());
            QMouseEvent mappedEvent(mouseEvent->type(), transformedPos, mouseEvent->screenPos(), mouseEvent->button(),
                                    mouseEvent->buttons(), mouseEvent->modifiers());
            mappedEvent.ignore();
            if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) {
                return mappedEvent.isAccepted();
            }
            break;
        }

#if defined(Q_OS_ANDROID)
        case QEvent::TouchBegin:
        case QEvent::TouchUpdate:
        case QEvent::TouchEnd: {
            QTouchEvent *originalEvent = static_cast<QTouchEvent *>(event);
            QEvent::Type fakeMouseEventType = QEvent::None;
            Qt::MouseButton fakeMouseButton = Qt::LeftButton;
            Qt::MouseButtons fakeMouseButtons = Qt::NoButton;
            switch (event->type()) {
                case QEvent::TouchBegin:
                    fakeMouseEventType = QEvent::MouseButtonPress;
                    fakeMouseButtons = Qt::LeftButton;
                    break;
                case QEvent::TouchUpdate:
                    fakeMouseEventType = QEvent::MouseMove;
                    fakeMouseButtons = Qt::LeftButton;
                    break;
                case QEvent::TouchEnd:
                    fakeMouseEventType = QEvent::MouseButtonRelease;
                    fakeMouseButtons = Qt::NoButton;
                    break;
            }
            // Same case as OffscreenUi.cpp::eventFilter: touch events are always being accepted so we now use mouse events and consider one touch, touchPoints()[0].
            QMouseEvent fakeMouseEvent(fakeMouseEventType, originalEvent->touchPoints()[0].pos(), fakeMouseButton, fakeMouseButtons, Qt::NoModifier);
            fakeMouseEvent.ignore();
            if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &fakeMouseEvent)) {
                /*qInfo() << __FUNCTION__ << "sent fake touch event:" << fakeMouseEvent.type()
                        << "_quickWindow handled it... accepted:" << fakeMouseEvent.isAccepted();*/
                return fakeMouseEvent.isAccepted();
            }
            break;
        }
        case QEvent::InputMethod:
        case QEvent::InputMethodQuery: {
            auto window = getWindow();
            if (window && window->activeFocusItem()) {
                event->ignore();
                if (QCoreApplication::sendEvent(window->activeFocusItem(), event)) {
                    bool eventAccepted = event->isAccepted();
                    if (event->type() == QEvent::InputMethodQuery) {
                        QInputMethodQueryEvent *imqEvent = static_cast<QInputMethodQueryEvent *>(event);
                        // this block disables the selection cursor in android which appears in
                        // the top-left corner of the screen
                        if (imqEvent->queries() & Qt::ImEnabled) {
                            imqEvent->setValue(Qt::ImEnabled, QVariant(false));
                        }
                    }
                    return eventAccepted;
                }
                return false;
            }
            break;
        }
#endif
        default:
            break;
    }

    return false;
}
예제 #9
0
bool PopupItem::eventFilter( QObject *object, QEvent *e )
{
    MarbleWidget *widget = dynamic_cast<MarbleWidget*> ( object );
    if ( !widget ) {
        return BillboardGraphicsItem::eventFilter( object, e );
    }

    if ( e->type() == QEvent::MouseButtonDblClick
            || e->type() == QEvent::MouseMove
            || e->type() == QEvent::MouseButtonPress
            || e->type() == QEvent::MouseButtonRelease )
    {
        // Mouse events are forwarded to the underlying widget
        QMouseEvent *event = static_cast<QMouseEvent*> ( e );
        QPoint const shiftedPos = transform( event->pos() );
        bool const forcedMouseRelease = m_needMouseRelease && e->type() == QEvent::MouseButtonRelease;
        if ( !shiftedPos.isNull() || forcedMouseRelease ) {
            if ( !m_needMouseRelease && e->type() == QEvent::MouseButtonPress ) {
                m_needMouseRelease = true;
            } else if ( forcedMouseRelease ) {
                m_needMouseRelease = false;
            }
            widget->setCursor( Qt::ArrowCursor );
            // transform to children's coordinates
            QMouseEvent shiftedEvent = QMouseEvent( e->type(), shiftedPos,
                                                    event->globalPos(), event->button(), event->buttons(),
                                                    event->modifiers() );
            if ( QApplication::sendEvent( m_webView, &shiftedEvent ) ) {
                widget->setCursor( m_webView->cursor() );
                emit dirty();
                return true;
            }
        }
    } else if ( e->type() == QEvent::Wheel ) {
        // Wheel events are forwarded to the underlying widget
        QWheelEvent *event = static_cast<QWheelEvent*> ( e );
        QPoint const shiftedPos = transform( event->pos() );
        if ( !shiftedPos.isNull() ) {
            widget->setCursor( Qt::ArrowCursor );
            QWheelEvent shiftedEvent = QWheelEvent( shiftedPos,
                                                    event->globalPos(), event->delta(), event->buttons(),
                                                    event->modifiers() );
            if ( QApplication::sendEvent( m_webView, &shiftedEvent ) ) {
                widget->setCursor( m_webView->cursor() );
                emit dirty();
                return true;
            }
        }
    }

    return BillboardGraphicsItem::eventFilter( object, e );
}
예제 #10
0
bool QtInputService::eventFilter(QObject *obj, QEvent *event)
{
    switch(event->type())
    {
    case QEvent::KeyPress:
    {
        QKeyEvent *e = static_cast<QKeyEvent*>(event);

        KeyEvent keyEvent;
        keyEvent.keyCode = StripModifiersFromKey(e->key());
        keyEvent.keyPressCount = 1;
        keyEvent.modifiers = e->modifiers();
        keyEvent.text = e->text();
        keyEvent.sequence = QKeySequence(e->key() | e->modifiers()); ///\todo Track multi-key sequences.
        keyEvent.eventType = KeyEvent::KeyPressed;
//		keyEvent.otherHeldKeys = heldKeys; ///\todo
        keyEvent.handled = false;

        current_modifiers_ = e->modifiers(); // local tracking for mouse events

        // We only take key events from the main QGraphicsView.
        if (obj != qobject_cast<QObject*>(mainView))
            return false;

        std::map<Qt::Key, KeyPressInformation>::iterator keyRecord = heldKeys.find(keyEvent.keyCode);
        if (keyRecord != heldKeys.end())
        {
            if (e->isAutoRepeat()) // If this is a repeat, track the proper keyPressCount.
            {
                keyEvent.keyPressCount = ++keyRecord->second.keyPressCount;
                keyEvent.sequence = QKeySequence(); // Repeated keys do not trigger keysequences.
            }
        }
        else
        {
            KeyPressInformation info;
            info.keyPressCount = 1;
            info.keyState = KeyEvent::KeyPressed;
//            info.firstPressTime = now; ///\todo
            heldKeys[keyEvent.keyCode] = info;
        }

        // Queue up the press event for the polling API, independent of whether any Qt widget has keyboard focus.
        if (keyEvent.keyPressCount == 1) /// \todo The polling API does not get key repeats at all. Should it?
            newKeysPressedQueue.push_back(StripModifiersFromKey(e->key()));

        TriggerKeyEvent(keyEvent);

        return keyEvent.handled; // If we got true here, need to suppress this event from going to Qt.
    }

    case QEvent::KeyRelease:
    {
        // We only take key events from the main window.
        if (obj != qobject_cast<QObject*>(mainWindow))
            return false;

        QKeyEvent *e = static_cast<QKeyEvent *>(event);

        // Our input system policy: Key releases on repeated keys are not transmitted. This means
        // that the client gets always a sequences like "press (first), press(1st repeat), press(2nd repeat), release",
        // instead of "press(first), release, press(1st repeat), release, press(2nd repeat), release".
        if (e->isAutoRepeat())
            return false;

        HeldKeysMap::iterator existingKey = heldKeys.find(StripModifiersFromKey(e->key()));

        // If we received a release on an unknown key we haven't received a press for, don't pass it to the scene,
        // since we didn't pass the press to the scene either (or we've already passed the release before, so don't
        // pass duplicate releases).
        if (existingKey == heldKeys.end())
            return false;

        KeyEvent keyEvent;
        keyEvent.keyCode = StripModifiersFromKey(e->key());
        keyEvent.keyPressCount = existingKey->second.keyPressCount;
        keyEvent.modifiers = e->modifiers();
        keyEvent.text = e->text();
        keyEvent.eventType = KeyEvent::KeyReleased;
//		keyEvent.otherHeldKeys = heldKeys; ///\todo
        keyEvent.handled = false;

        heldKeys.erase(existingKey);
        current_modifiers_ = e->modifiers(); // local tracking for mouse events

        // Queue up the release event for the polling API, independent of whether any Qt widget has keyboard focus.
        if (keyEvent.keyPressCount == 1) /// \todo The polling API does not get key repeats at all. Should it?
            newKeysReleasedQueue.push_back(StripModifiersFromKey(e->key()));

        TriggerKeyEvent(keyEvent);

        return keyEvent.handled; // Suppress this event from going forward.
    }

    case QEvent::MouseButtonPress:
    case QEvent::MouseButtonRelease:
    {
        // We only take mouse button press and release events from the main QGraphicsView viewport.
        if (obj != qobject_cast<QObject*>(mainView->viewport()))
            return false;

        QMouseEvent *e = static_cast<QMouseEvent *>(event);
//		QGraphicsItem *itemUnderMouse = GetVisibleItemAtCoords(e->x(), e->y());
        /*
                // Update the flag that tracks whether the inworld scene or QGraphicsScene is grabbing mouse movement.
                if (event->type() == QEvent::MouseButtonPress)
                    sceneMouseCapture = (itemUnderMouse ? QtMouseCapture : SceneMouseCapture);
                else // event type == MouseButtonRelease
                    sceneMouseCapture = NoMouseCapture;
        */
        // We always update the global polled input states, independent of whether any the mouse cursor is
        // on top of any Qt widget.
        if (event->type() == QEvent::MouseButtonPress)
        {
            heldMouseButtons |= (MouseEvent::MouseButton)e->button();
            newMouseButtonsPressedQueue |= (MouseEvent::MouseButton)e->button();
        }
        else
        {
            if (lastMouseButtonReleaseTime.msecsTo(QTime::currentTime()) < 300)
            {
                doubleClickDetected = true;
            }
            heldMouseButtons &= ~(MouseEvent::MouseButton)e->button();
            newMouseButtonsReleasedQueue |= (MouseEvent::MouseButton)e->button();
            lastMouseButtonReleaseTime = QTime::currentTime();
        }

        // If there's a visible QGraphicsItem under the mouse and mouse is not in FPS mode,
        // the click's supposed to go there - don't send it at all to inworld scene.
//		if (itemUnderMouse && mouseCursorVisible)
//			return false;

        // The mouse coordinates we receive can come from different widgets, and we are interested only in the coordinates
        // in the QGraphicsView client area, so we need to remap them.
        QPoint mousePos = MapPointToMainGraphicsView(obj, e->pos());

        MouseEvent mouseEvent;
        mouseEvent.itemUnderMouse = GetVisibleItemAtCoords(e->x(), e->y());
        mouseEvent.origin = mouseEvent.itemUnderMouse ? MouseEvent::PressOriginQtWidget : MouseEvent::PressOriginScene;
        if ( !doubleClickDetected)
        {
            mouseEvent.eventType = (event->type() == QEvent::MouseButtonPress) ? MouseEvent::MousePressed : MouseEvent::MouseReleased;
        } else
        {
            mouseEvent.eventType = MouseEvent::MouseDoubleClicked;
        }
        mouseEvent.button = (MouseEvent::MouseButton)e->button();
        mouseEvent.x = mousePos.x();
        mouseEvent.y = mousePos.y();
        mouseEvent.z = 0;
        mouseEvent.relativeX = mouseEvent.x - lastMouseX;
        mouseEvent.relativeY = mouseEvent.y - lastMouseY;
        mouseEvent.modifiers = current_modifiers_;

        lastMouseX = mouseEvent.x;
        lastMouseY = mouseEvent.y;

        mouseEvent.globalX = e->globalX();
        mouseEvent.globalY = e->globalY();

        mouseEvent.otherButtons = e->buttons();

//		mouseEvent.heldKeys = heldKeys; ///\todo
        mouseEvent.handled = false;

        // The mouse press is going to the inworld scene - clear keyboard focus from the QGraphicsScene widget, if any had it so key events also go to inworld scene.
        if (event->type() == QEvent::MouseButtonPress && !mouseEvent.itemUnderMouse && mouseCursorVisible)
            mainView->scene()->clearFocus();

        TriggerMouseEvent(mouseEvent);

        return mouseEvent.handled;
    }

    case QEvent::MouseMove:
    {
        // If a mouse button is held down, we get the mouse drag events from the viewport widget.
        // If a mouse button is not held down, the application main window will get the events.
        // Duplicate events are not received, so no need to worry about filtering them here.

        QMouseEvent *e = static_cast<QMouseEvent *>(event);

        //QGraphicsItem *itemUnderMouse = GetVisibleItemAtCoords(e->x(), e->y());
        // If there is a graphicsItem under the mouse, don't pass the move message to the inworld scene, unless the inworld scene has captured it.
//        if (mouseCursorVisible)
//		    if ((itemUnderMouse && sceneMouseCapture != SceneMouseCapture) || sceneMouseCapture == QtMouseCapture)
//			    return false;

//        if (mouseCursorVisible && itemUnderMouse)
//            return false;

        MouseEvent mouseEvent;
        mouseEvent.eventType = MouseEvent::MouseMove;
        mouseEvent.button = (MouseEvent::MouseButton)e->button();
        mouseEvent.itemUnderMouse = GetVisibleItemAtCoords(e->x(), e->y());
        ///\todo Set whether the previous press originated over a Qt widget or scene.
        mouseEvent.origin = mouseEvent.itemUnderMouse ? MouseEvent::PressOriginQtWidget : MouseEvent::PressOriginScene;

        QWidget *sender = qobject_cast<QWidget*>(obj);
        assert(sender);

        // The mouse coordinates we receive can come from different widgets, and we are interested only in the coordinates
        // in the QGraphicsView client area, so we need to remap them.
        QPoint mousePos = MapPointToMainGraphicsView(obj, e->pos());

        if (mouseCursorVisible)
        {
            mouseEvent.x = mousePos.x();
            mouseEvent.y = mousePos.y();
        }
        else
        {
            // If mouse cursor is hidden, we're in relative "crosshair" mode. In this mode,
            // the mouse absolute coordinates are restricted to stay in the center of the screen.
            mouseEvent.x = mainView->size().width()/2;
            mouseEvent.y = mainView->size().height()/2;
        }
        mouseEvent.z = 0;
        mouseEvent.relativeX = mousePos.x() - lastMouseX;
        mouseEvent.relativeY = mousePos.y() - lastMouseY;

        // If there wasn't any change to the mouse relative coords in FPS mode, ignore this event.
        if (!mouseCursorVisible && mouseEvent.relativeX == 0 && mouseEvent.relativeY == 0)
            return true;

        mouseEvent.globalX = e->globalX(); // Note that these may "jitter" when mouse is in relative movement mode.
        mouseEvent.globalY = e->globalY();
        mouseEvent.otherButtons = e->buttons();
//		mouseEvent.heldKeys = heldKeys; ///\todo
        mouseEvent.handled = false;

        // Save the absolute coordinates to be able to compute the proper relative movement values in the next
        // mouse event.
        lastMouseX = mouseEvent.x;
        lastMouseY = mouseEvent.y;

        TriggerMouseEvent(mouseEvent);

        // In relative mouse movement mode, keep the mouse cursor hidden at screen center at all times.
        if (!mouseCursorVisible)
        {
            RecenterMouse();
            return true; // In relative mouse movement mode, the QGraphicsScene does not receive mouse movement at all.
        }

        return mouseEvent.handled;
    }

    case QEvent::Wheel:
    {
        // If this event did not originate from the application main window, we are not interested in it.
        if (obj != qobject_cast<QObject*>(mainWindow))
            return false;

        QObject *mv = qobject_cast<QObject*>(mainView);
        QObject *mw = qobject_cast<QObject*>(mainWindow);
        QWheelEvent *e = static_cast<QWheelEvent *>(event);
//		QGraphicsItem *itemUnderMouse = GetVisibleItemAtCoords(e->x(), e->y());
//		if (itemUnderMouse)
//			return false;

        MouseEvent mouseEvent;
        mouseEvent.eventType = MouseEvent::MouseScroll;
        mouseEvent.itemUnderMouse = GetVisibleItemAtCoords(e->x(), e->y());
        mouseEvent.origin = mouseEvent.itemUnderMouse ? MouseEvent::PressOriginQtWidget : MouseEvent::PressOriginScene;
        mouseEvent.button = MouseEvent::NoButton;
        mouseEvent.otherButtons = e->buttons();
        mouseEvent.x = e->x();
        mouseEvent.y = e->y();
        mouseEvent.z = 0; // Mouse wheel does not have an absolute z position, only relative.
        mouseEvent.relativeX = 0;
        mouseEvent.relativeY = 0;
        mouseEvent.relativeZ = e->delta();
        mouseEvent.globalX = e->globalX();
        mouseEvent.globalY = e->globalY();

        mouseEvent.otherButtons = e->buttons(); ///\todo Can this be trusted?

//		mouseEvent.heldKeys = heldKeys; ///\todo
        mouseEvent.handled = false;

        TriggerMouseEvent(mouseEvent);

        return mouseEvent.handled;
    }

    } // ~switch

    return QObject::eventFilter(obj, event);
}
void QtEventConsumer::handleWheelEvent ( QObject *obj, QEvent *event )
{
    // check the object
    QWidget *widget = isValidWidget(obj);
    if (!widget){
        DEBUG(D_CONSUMER,"(QtEventConsumer::handleWheelEvent) No widget to handle");
        return;
    }

    DEBUG(D_CONSUMER,"(QtEventConsumer::handleWheelEvent)");

    QWheelEvent *we = dynamic_cast<QWheelEvent*> ( event );

    //create the event
    QOE::QOE_MouseWheel qoe;

    qoe.timestamp(_timer.restart());
    completeBasicData(qoe,widget);

    qoe.delta(we->delta());
    qoe.orientation(we->orientation());
    qoe.buttons(we->buttons());
    qoe.modifiers(we->modifiers());

    ///sensitive value
    completeSensitiveData(qoe, widget);

    //send event if qoe is valid
    if (isValidQOE(qoe) && isValidQOEMouse(qoe))
        sendNewTestItem(qoe);
}