Remove QWidget dependency from QTouchEvent.
QWidget *widget() is replaced with QObject *target(). Change-Id: Ib2c860480764410cf1527662e89f352ff688b32a Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
5da5230ab2
commit
4471e45f74
@ -3467,7 +3467,8 @@ QTouchEvent::QTouchEvent(QEvent::Type eventType,
|
||||
Qt::TouchPointStates touchPointStates,
|
||||
const QList<QTouchEvent::TouchPoint> &touchPoints)
|
||||
: QInputEvent(eventType, modifiers),
|
||||
_widget(0),
|
||||
_window(0),
|
||||
_target(0),
|
||||
_device(device),
|
||||
_touchPointStates(touchPointStates),
|
||||
_touchPoints(touchPoints)
|
||||
@ -3479,11 +3480,6 @@ QTouchEvent::QTouchEvent(QEvent::Type eventType,
|
||||
QTouchEvent::~QTouchEvent()
|
||||
{ }
|
||||
|
||||
/*! \fn QWidget *QTouchEvent::widget() const
|
||||
|
||||
Returns the widget on which the event occurred.
|
||||
*/
|
||||
|
||||
/*! \fn QWindow *QTouchEvent::window() const
|
||||
|
||||
Returns the window on which the event occurred. Useful for doing
|
||||
@ -3492,6 +3488,12 @@ QTouchEvent::~QTouchEvent()
|
||||
touch event.
|
||||
*/
|
||||
|
||||
/*! \fn QObject *QTouchEvent::target() const
|
||||
|
||||
Returns the target object within the window on which the event occurred.
|
||||
This is typically a QWidget or a QQuickItem. May be 0 when no specific target is available.
|
||||
*/
|
||||
|
||||
/*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const
|
||||
|
||||
Returns the touch device Type, which is of type \l {QTouchEvent::DeviceType} {DeviceType}.
|
||||
@ -3521,13 +3523,6 @@ QTouchEvent::~QTouchEvent()
|
||||
Returns the touch device from which this touch event originates.
|
||||
*/
|
||||
|
||||
/*! \fn void QTouchEvent::setWidget(QWidget *widget)
|
||||
|
||||
\internal
|
||||
|
||||
Sets the widget for this event.
|
||||
*/
|
||||
|
||||
/*! \fn void QTouchEvent::setWindow(QWindow *window)
|
||||
|
||||
\internal
|
||||
@ -3535,6 +3530,13 @@ QTouchEvent::~QTouchEvent()
|
||||
Sets the window for this event.
|
||||
*/
|
||||
|
||||
/*! \fn void QTouchEvent::setTarget(QObject *target)
|
||||
|
||||
\internal
|
||||
|
||||
Sets the target within the window (typically a widget) for this event.
|
||||
*/
|
||||
|
||||
/*! \fn void QTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates)
|
||||
|
||||
\internal
|
||||
|
@ -776,23 +776,23 @@ public:
|
||||
const QList<QTouchEvent::TouchPoint> &touchPoints = QList<QTouchEvent::TouchPoint>());
|
||||
~QTouchEvent();
|
||||
|
||||
inline QWidget *widget() const { return _widget; }
|
||||
inline QWindow *window() const { return _window; }
|
||||
inline QObject *target() const { return _target; }
|
||||
QT_DEPRECATED inline QTouchEvent::DeviceType deviceType() const { return static_cast<DeviceType>(int(_device->type())); }
|
||||
inline Qt::TouchPointStates touchPointStates() const { return _touchPointStates; }
|
||||
inline const QList<QTouchEvent::TouchPoint> &touchPoints() const { return _touchPoints; }
|
||||
inline QTouchDevice *device() const { return _device; }
|
||||
|
||||
// internal
|
||||
inline void setWidget(QWidget *awidget) { _widget = awidget; }
|
||||
inline void setWindow(QWindow *awindow) { _window = awindow; }
|
||||
inline void setTarget(QObject *atarget) { _target = atarget; }
|
||||
inline void setTouchPointStates(Qt::TouchPointStates aTouchPointStates) { _touchPointStates = aTouchPointStates; }
|
||||
inline void setTouchPoints(const QList<QTouchEvent::TouchPoint> &atouchPoints) { _touchPoints = atouchPoints; }
|
||||
inline void setDevice(QTouchDevice *device) { _device = device; }
|
||||
|
||||
protected:
|
||||
QWidget *_widget;
|
||||
QWindow *_window;
|
||||
QObject *_target;
|
||||
QTouchDevice *_device;
|
||||
Qt::TouchPointStates _touchPointStates;
|
||||
QList<QTouchEvent::TouchPoint> _touchPoints;
|
||||
|
@ -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<QWidget *>(touchEvent->target())));
|
||||
touchPoint.setLastPos(item->d_ptr->genericMapFromScene(touchPoint.lastScenePos(), static_cast<QWidget *>(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<QWidget *>(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<QWidget *>(touchEvent->target()));
|
||||
}
|
||||
Q_ASSERT(cachedItemsUnderMouse.first() == origin);
|
||||
|
||||
|
@ -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<QTouchEvent *>(event);
|
||||
touchEvent->setWidget(viewport());
|
||||
touchEvent->setTarget(viewport());
|
||||
QGraphicsViewPrivate::translateTouchEvent(d, touchEvent);
|
||||
(void) QApplication::sendEvent(d->scene, touchEvent);
|
||||
}
|
||||
|
@ -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<QWidget> 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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user