From 4471e45f74a74827464774480306c1fbd70a5d7e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 30 Nov 2011 18:51:00 +0200 Subject: Remove QWidget dependency from QTouchEvent. QWidget *widget() is replaced with QObject *target(). Change-Id: Ib2c860480764410cf1527662e89f352ff688b32a Reviewed-by: Lars Knoll --- src/widgets/graphicsview/qgraphicsscene.cpp | 12 ++++++------ src/widgets/graphicsview/qgraphicsview.cpp | 2 +- src/widgets/kernel/qapplication.cpp | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 791f25aa27..f5057490c7 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -5777,8 +5777,8 @@ void QGraphicsScenePrivate::updateTouchPointsForItem(QGraphicsItem *item, QTouch for (int i = 0; i < touchPoints.count(); ++i) { QTouchEvent::TouchPoint &touchPoint = touchPoints[i]; touchPoint.setRect(item->mapFromScene(touchPoint.sceneRect()).boundingRect()); - touchPoint.setStartPos(item->d_ptr->genericMapFromScene(touchPoint.startScenePos(), touchEvent->widget())); - touchPoint.setLastPos(item->d_ptr->genericMapFromScene(touchPoint.lastScenePos(), touchEvent->widget())); + touchPoint.setStartPos(item->d_ptr->genericMapFromScene(touchPoint.startScenePos(), static_cast(touchEvent->target()))); + touchPoint.setLastPos(item->d_ptr->genericMapFromScene(touchPoint.lastScenePos(), static_cast(touchEvent->target()))); } touchEvent->setTouchPoints(touchPoints); } @@ -5819,7 +5819,7 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent) // determine which item this touch point will go to cachedItemsUnderMouse = itemsAtPosition(touchPoint.screenPos().toPoint(), touchPoint.scenePos(), - sceneTouchEvent->widget()); + static_cast(sceneTouchEvent->target())); item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.first(); } @@ -5888,13 +5888,13 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent) } QTouchEvent touchEvent(eventType); - touchEvent.setWidget(sceneTouchEvent->widget()); + touchEvent.setWindow(sceneTouchEvent->window()); + touchEvent.setTarget(sceneTouchEvent->target()); touchEvent.setDevice(sceneTouchEvent->device()); touchEvent.setModifiers(sceneTouchEvent->modifiers()); touchEvent.setTouchPointStates(it.value().first); touchEvent.setTouchPoints(it.value().second); touchEvent.setTimestamp(sceneTouchEvent->timestamp()); - touchEvent.setWindow(sceneTouchEvent->window()); switch (touchEvent.type()) { case QEvent::TouchBegin: @@ -5935,7 +5935,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first(); cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(), firstTouchPoint.scenePos(), - touchEvent->widget()); + static_cast(touchEvent->target())); } Q_ASSERT(cachedItemsUnderMouse.first() == origin); diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 2ebd4ecc63..8efd4eee4a 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -2836,7 +2836,7 @@ bool QGraphicsView::viewportEvent(QEvent *event) if (d->scene && d->sceneInteractionAllowed) { // Convert and deliver the touch event to the scene. QTouchEvent *touchEvent = static_cast(event); - touchEvent->setWidget(viewport()); + touchEvent->setTarget(viewport()); QGraphicsViewPrivate::translateTouchEvent(d, touchEvent); (void) QApplication::sendEvent(d->scene, touchEvent); } diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index afd5fb70e1..e6e8a8eab4 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3896,7 +3896,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) while (widget) { // first, try to deliver the touch event bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents); - touchEvent->setWidget(widget); + touchEvent->setTarget(widget); touchEvent->setAccepted(acceptTouchEvents); QWeakPointer p = widget; res = acceptTouchEvents && d->notify_helper(widget, touchEvent); @@ -3920,7 +3920,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) } QPoint offset = widget->pos(); widget = widget->parentWidget(); - touchEvent->setWidget(widget); + touchEvent->setTarget(widget); for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) { QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i]; QRectF rect = pt.rect(); @@ -5355,6 +5355,7 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, updateTouchPointsForWidget(widget, &touchEvent); touchEvent.setTimestamp(timestamp); touchEvent.setWindow(window->windowHandle()); + touchEvent.setTarget(window); switch (touchEvent.type()) { case QEvent::TouchBegin: -- cgit v1.2.3