Fix compiler warnings from deprecated QTouchEvent::touchPoints

Replace with QPointerEvent::points().

As a drive-by, turn QEventPoint copies into const references where possible.

Change-Id: Ia5e0645493984fe9177dd3ca16afdb4d56e384ee
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Volker Hilsheimer 2020-09-17 12:06:52 +02:00
parent 850d850c5a
commit 9c5698a8fc
4 changed files with 36 additions and 38 deletions

View File

@ -5858,7 +5858,7 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent)
typedef QPair<QEventPoint::States, QList<QEventPoint> > StatesAndTouchPoints;
QHash<QGraphicsItem *, StatesAndTouchPoints> itemsNeedingEvents;
const auto touchPoints = sceneTouchEvent->touchPoints();
const auto &touchPoints = sceneTouchEvent->points();
for (const auto &touchPoint : touchPoints) {
// update state
QGraphicsItem *item = nullptr;
@ -5956,7 +5956,7 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent)
bool res = sendTouchBeginEvent(item, &touchEvent) && touchEvent.isAccepted();
if (!res) {
// forget about these touch points, we didn't handle them
const auto unhandledTouchPoints = touchEvent.touchPoints();
const auto &unhandledTouchPoints = touchEvent.points();
for (const auto &touchPoint : unhandledTouchPoints) {
itemForTouchPointId.remove(touchPoint.id());
sceneCurrentTouchPoints.remove(touchPoint.id());
@ -5983,7 +5983,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
if (focusOnTouch) {
if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.constFirst() != origin) {
const QEventPoint &firstTouchPoint = touchEvent->touchPoints().first();
const QEventPoint &firstTouchPoint = touchEvent->points().first();
cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.globalPosition().toPoint(),
firstTouchPoint.scenePosition(),
static_cast<QWidget *>(touchEvent->target()));
@ -6026,7 +6026,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
touchEvent->setAccepted(acceptTouchEvents);
res = acceptTouchEvents && sendEvent(item, touchEvent);
eventAccepted = touchEvent->isAccepted();
if (itemForTouchPointId.value(touchEvent->touchPoints().first().id()) == 0) {
if (itemForTouchPointId.value(touchEvent->points().first().id()) == 0) {
// item was deleted
item = nullptr;
} else {
@ -6035,7 +6035,7 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve
touchEvent->spont = false;
if (res && eventAccepted) {
// the first item to accept the TouchBegin gets an implicit grab.
const auto touchPoints = touchEvent->touchPoints();
const auto &touchPoints = touchEvent->points();
for (const auto &touchPoint : touchPoints)
itemForTouchPointId[touchPoint.id()] = item; // can be zero
break;

View File

@ -203,7 +203,7 @@ QMacPanGestureRecognizer::recognize(QGesture *gesture, QObject *target, QEvent *
switch (event->type()) {
case QEvent::TouchBegin: {
const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
if (ev->touchPoints().size() == 1) {
if (ev->points().size() == 1) {
reset(gesture);
_startPos = QCursor::pos();
_target = target;
@ -217,7 +217,7 @@ QMacPanGestureRecognizer::recognize(QGesture *gesture, QObject *target, QEvent *
break;
const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
if (ev->touchPoints().size() == 1)
if (ev->points().size() == 1)
return QGestureRecognizer::FinishGesture;
break;}
case QEvent::TouchUpdate: {
@ -225,7 +225,7 @@ QMacPanGestureRecognizer::recognize(QGesture *gesture, QObject *target, QEvent *
break;
const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
if (ev->touchPoints().size() == 1) {
if (ev->points().size() == 1) {
if (_panTimer.isActive()) {
// INVARIANT: Still in maybeGesture. Check if the user
// moved his finger so much that it makes sense to cancel the pan:

View File

@ -90,9 +90,7 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state,
QGestureRecognizer::Result result = QGestureRecognizer::Ignore;
switch (event->type()) {
case QEvent::TouchBegin: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
result = QGestureRecognizer::MayBeGesture;
QEventPoint p = ev->touchPoints().at(0);
d->lastOffset = d->offset = QPointF();
d->pointCount = m_pointCount;
break;
@ -100,9 +98,9 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state,
case QEvent::TouchEnd: {
if (q->state() != Qt::NoGesture) {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
if (ev->touchPoints().size() == d->pointCount) {
if (ev->points().size() == d->pointCount) {
d->lastOffset = d->offset;
d->offset = panOffset(ev->touchPoints(), d->pointCount);
d->offset = panOffset(ev->points(), d->pointCount);
}
result = QGestureRecognizer::FinishGesture;
} else {
@ -112,12 +110,12 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state,
}
case QEvent::TouchUpdate: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
if (ev->touchPoints().size() >= d->pointCount) {
if (ev->points().size() >= d->pointCount) {
d->lastOffset = d->offset;
d->offset = panOffset(ev->touchPoints(), d->pointCount);
d->offset = panOffset(ev->points(), d->pointCount);
if (d->offset.x() > 10 || d->offset.y() > 10 ||
d->offset.x() < -10 || d->offset.y() < -10) {
q->setHotSpot(ev->touchPoints().first().globalPressPosition());
q->setHotSpot(ev->points().first().globalPressPosition());
result = QGestureRecognizer::TriggerGesture;
} else {
result = QGestureRecognizer::MayBeGesture;
@ -184,9 +182,9 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state,
case QEvent::TouchUpdate: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
d->changeFlags = { };
if (ev->touchPoints().size() == 2) {
QEventPoint p1 = ev->touchPoints().at(0);
QEventPoint p2 = ev->touchPoints().at(1);
if (ev->points().size() == 2) {
const QEventPoint &p1 = ev->points().at(0);
const QEventPoint &p2 = ev->points().at(1);
d->hotSpot = p1.globalPosition();
d->isHotSpotSet = true;
@ -313,11 +311,11 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
if (d->state == QSwipeGesturePrivate::NoGesture)
result = QGestureRecognizer::CancelGesture;
else if (ev->touchPoints().size() == 3) {
else if (ev->points().size() == 3) {
d->state = QSwipeGesturePrivate::ThreePointsReached;
QEventPoint p1 = ev->touchPoints().at(0);
QEventPoint p2 = ev->touchPoints().at(1);
QEventPoint p3 = ev->touchPoints().at(2);
const QEventPoint &p1 = ev->points().at(0);
const QEventPoint &p2 = ev->points().at(1);
const QEventPoint &p3 = ev->points().at(2);
if (d->lastPositions[0].isNull()) {
d->lastPositions[0] = p1.globalPressPosition().toPoint();
@ -370,7 +368,7 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
else
result = QGestureRecognizer::MayBeGesture;
}
} else if (ev->touchPoints().size() > 3) {
} else if (ev->points().size() > 3) {
result = QGestureRecognizer::CancelGesture;
} else { // less than 3 touch points
switch (d->state) {
@ -439,15 +437,15 @@ QGestureRecognizer::Result QTapGestureRecognizer::recognize(QGesture *state,
switch (event->type()) {
case QEvent::TouchBegin: {
d->position = ev->touchPoints().at(0).position();
q->setHotSpot(ev->touchPoints().at(0).globalPosition());
d->position = ev->points().at(0).position();
q->setHotSpot(ev->points().at(0).globalPosition());
result = QGestureRecognizer::TriggerGesture;
break;
}
case QEvent::TouchUpdate:
case QEvent::TouchEnd: {
if (q->state() != Qt::NoGesture && ev->touchPoints().size() == 1) {
QEventPoint p = ev->touchPoints().at(0);
if (q->state() != Qt::NoGesture && ev->points().size() == 1) {
const QEventPoint &p = ev->points().at(0);
QPoint delta = p.position().toPoint() - p.pressPosition().toPoint();
enum { TapRadius = 40 };
if (delta.manhattanLength() <= TapRadius) {
@ -535,7 +533,7 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
}
case QEvent::TouchBegin: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
d->position = ev->touchPoints().at(0).globalPressPosition();
d->position = ev->points().at(0).globalPressPosition();
q->setHotSpot(d->position);
if (d->timerId)
q->killTimer(d->timerId);
@ -550,8 +548,8 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
return QGestureRecognizer::CancelGesture; // get out of the MayBeGesture state
case QEvent::TouchUpdate: {
const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
if (d->timerId && ev->touchPoints().size() == 1) {
QEventPoint p = ev->touchPoints().at(0);
if (d->timerId && ev->points().size() == 1) {
const QEventPoint &p = ev->points().at(0);
QPoint delta = p.position().toPoint() - p.pressPosition().toPoint();
if (delta.manhattanLength() <= TapRadius)
return QGestureRecognizer::MayBeGesture;

View File

@ -464,8 +464,8 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
if (button == Qt::NoButton) {
te = static_cast<const QTouchEvent *>(event);
keyboardModifiers = te->modifiers();
if (!te->touchPoints().isEmpty())
globalPos = te->touchPoints().at(0).globalPosition().toPoint();
if (!te->points().isEmpty())
globalPos = te->points().at(0).globalPosition().toPoint();
}
break;
@ -555,17 +555,17 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state,
inputType = QScroller::InputMove;
if (te->pointingDevice()->type() == QInputDevice::DeviceType::TouchPad) {
if (te->touchPoints().count() != 2) // 2 fingers on pad
if (te->points().count() != 2) // 2 fingers on pad
return Ignore;
point = te->touchPoints().at(0).scenePressPosition() +
((te->touchPoints().at(0).scenePosition() - te->touchPoints().at(0).scenePressPosition()) +
(te->touchPoints().at(1).scenePosition() - te->touchPoints().at(1).scenePressPosition())) / 2;
point = te->points().at(0).scenePressPosition() +
((te->points().at(0).scenePosition() - te->points().at(0).scenePressPosition()) +
(te->points().at(1).scenePosition() - te->points().at(1).scenePressPosition())) / 2;
} else { // TouchScreen
if (te->touchPoints().count() != 1) // 1 finger on screen
if (te->points().count() != 1) // 1 finger on screen
return Ignore;
point = te->touchPoints().at(0).scenePosition();
point = te->points().at(0).scenePosition();
}
break;