Use QWheelEvent instead of QGraphicsSceneWheelEvent

Since WheelEvent is not floating point based, we can
use it instead of the graphics scene event.

Change-Id: Ifa8411ca9c3a986ea311c8741f60213637b7c6ae
Reviewed-on: http://codereview.qt.nokia.com/1140
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
This commit is contained in:
Lars Knoll 2011-06-30 10:53:50 +02:00 committed by Qt by Nokia
parent 63f23475f0
commit 19a4cf3c4f
7 changed files with 20 additions and 28 deletions

View File

@ -1296,7 +1296,7 @@ bool QSGCanvasPrivate::deliverHoverEvent(QSGItem *item, QGraphicsSceneHoverEvent
return false;
}
bool QSGCanvasPrivate::deliverWheelEvent(QSGItem *item, QGraphicsSceneWheelEvent *event)
bool QSGCanvasPrivate::deliverWheelEvent(QSGItem *item, QWheelEvent *event)
{
Q_Q(QSGCanvas);
QSGItemPrivate *itemPrivate = QSGItemPrivate::get(item);
@ -1304,7 +1304,7 @@ bool QSGCanvasPrivate::deliverWheelEvent(QSGItem *item, QGraphicsSceneWheelEvent
return false;
if (itemPrivate->flags & QSGItem::ItemClipsChildrenToShape) {
QPointF p = item->mapFromScene(event->scenePos());
QPointF p = item->mapFromScene(event->pos());
if (!QRectF(0, 0, item->width(), item->height()).contains(p))
return false;
}
@ -1318,13 +1318,15 @@ bool QSGCanvasPrivate::deliverWheelEvent(QSGItem *item, QGraphicsSceneWheelEvent
return true;
}
QPointF p = item->mapFromScene(event->scenePos());
QPointF p = item->mapFromScene(event->pos());
if (QRectF(0, 0, item->width(), item->height()).contains(p)) {
event->setPos(itemPrivate->canvasToItemTransform().map(event->scenePos()));
event->accept();
q->sendEvent(item, event);
if (event->isAccepted())
QWheelEvent wheel(p, event->delta(), event->buttons(), event->modifiers(), event->orientation());
wheel.accept();
q->sendEvent(item, &wheel);
if (wheel.isAccepted()) {
event->accept();
return true;
}
}
return false;
@ -1337,18 +1339,8 @@ void QSGCanvas::wheelEvent(QWheelEvent *event)
#ifdef MOUSE_DEBUG
qWarning() << "QSGCanvas::wheelEvent()" << event->pos() << event->delta() << event->orientation();
#endif
QGraphicsSceneWheelEvent wheelEvent(QEvent::GraphicsSceneWheel);
wheelEvent.setWidget(this);
wheelEvent.setScenePos(event->pos());
wheelEvent.setScreenPos(event->globalPos());
wheelEvent.setButtons(event->buttons());
wheelEvent.setModifiers(event->modifiers());
wheelEvent.setDelta(event->delta());
wheelEvent.setOrientation(event->orientation());
wheelEvent.setAccepted(false);
d->deliverWheelEvent(d->rootItem, &wheelEvent);
event->setAccepted(wheelEvent.isAccepted());
event->ignore();
d->deliverWheelEvent(d->rootItem, event);
}
#endif // QT_NO_WHEELEVENT
@ -1635,8 +1627,8 @@ bool QSGCanvas::sendEvent(QSGItem *item, QEvent *e)
}
}
break;
case QEvent::GraphicsSceneWheel:
QSGItemPrivate::get(item)->deliverWheelEvent(static_cast<QGraphicsSceneWheelEvent *>(e));
case QEvent::Wheel:
QSGItemPrivate::get(item)->deliverWheelEvent(static_cast<QWheelEvent *>(e));
break;
case QEvent::GraphicsSceneHoverEnter:
case QEvent::GraphicsSceneHoverLeave:

View File

@ -110,7 +110,7 @@ public:
bool deliverInitialMousePressEvent(QSGItem *, QGraphicsSceneMouseEvent *);
bool deliverMouseEvent(QGraphicsSceneMouseEvent *);
bool sendFilteredMouseEvent(QSGItem *, QSGItem *, QGraphicsSceneMouseEvent *);
bool deliverWheelEvent(QSGItem *, QGraphicsSceneWheelEvent *);
bool deliverWheelEvent(QSGItem *, QWheelEvent *);
bool deliverTouchPoints(QSGItem *, QTouchEvent *, const QList<QTouchEvent::TouchPoint> &, QSet<int> *,
QHash<QSGItem *, QList<QTouchEvent::TouchPoint> > *);
bool deliverTouchEvent(QTouchEvent *);

View File

@ -794,7 +794,7 @@ void QSGFlickable::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
}
void QSGFlickable::wheelEvent(QGraphicsSceneWheelEvent *event)
void QSGFlickable::wheelEvent(QWheelEvent *event)
{
Q_D(QSGFlickable);
if (!d->interactive) {

View File

@ -183,7 +183,7 @@ protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
virtual void wheelEvent(QWheelEvent *event);
virtual void timerEvent(QTimerEvent *event);
QSGFlickableVisibleArea *visibleArea();

View File

@ -1664,7 +1664,7 @@ void QSGItem::mouseUngrabEvent()
// XXX todo
}
void QSGItem::wheelEvent(QGraphicsSceneWheelEvent *event)
void QSGItem::wheelEvent(QWheelEvent *event)
{
event->ignore();
}
@ -2140,7 +2140,7 @@ void QSGItemPrivate::deliverMouseEvent(QGraphicsSceneMouseEvent *e)
}
}
void QSGItemPrivate::deliverWheelEvent(QGraphicsSceneWheelEvent *e)
void QSGItemPrivate::deliverWheelEvent(QWheelEvent *e)
{
Q_Q(QSGItem);
q->wheelEvent(e);

View File

@ -359,7 +359,7 @@ protected:
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseUngrabEvent(); // XXX todo - params?
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
virtual void wheelEvent(QWheelEvent *event);
virtual void touchEvent(QTouchEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);

View File

@ -321,7 +321,7 @@ public:
void deliverInputMethodEvent(QInputMethodEvent *);
void deliverFocusEvent(QFocusEvent *);
void deliverMouseEvent(QGraphicsSceneMouseEvent *);
void deliverWheelEvent(QGraphicsSceneWheelEvent *);
void deliverWheelEvent(QWheelEvent *);
void deliverTouchEvent(QTouchEvent *);
void deliverHoverEvent(QGraphicsSceneHoverEvent *);
void deliverDragEvent(QSGDragEvent *);