diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-08-31 13:42:22 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-08-31 13:59:30 +0000 |
commit | 35caa44992c32bd51e55b7b039df8fad7c945bc6 (patch) | |
tree | ca8c860c4d1cc55f17e83c476cdba75a86ee963c /tests/auto | |
parent | bdb18e33e8b8c7e62514849378107a47a3667431 (diff) |
Rename QQEventPoint::GrabState to GrabTransition
This enum represents a transient state transition, and only sometimes
corresponds to the current grab state of an event point. For example
after exclusive grab has been canceled, the current state is that
there is no exclusive grab: it doesn't make sense to remember that the
way it got there was by cancellation. There was an idea to add a
grabState property, but not all values would be eligible. An
EventPoint can be exclusively grabbed by one item or handler at a
time, and by multiple passive grabbers at the same time, so even a
Q_FLAG would not fully express all possible states. Besides, there is
already an exclusiveGrabber property, and we could add a
passiveGrabbers list property if we had a real need. So adding a
grabState property seems unlikely, and therefore is not a good enough
reason to keep this enum named as GrabState.
Change-Id: Ie37742b4bd431a7e51910d79a7223fba9a6bd848
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp | 26 | ||||
-rw-r--r-- | tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp | 4 |
2 files changed, 15 insertions, 15 deletions
diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp index 2a9ec272fa..e8b076052a 100644 --- a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp @@ -51,14 +51,14 @@ public: }; Q_ENUM(Destination) - Event(Destination d, QEvent::Type t, Qt::TouchPointState s, int grabState, QPointF item, QPointF scene) - : destination(d), type(t), state(s), grabState(grabState), posWrtItem(item), posWrtScene(scene) + Event(Destination d, QEvent::Type t, Qt::TouchPointState s, int grabTransition, QPointF item, QPointF scene) + : destination(d), type(t), state(s), grabTransition(grabTransition), posWrtItem(item), posWrtScene(scene) {} Destination destination; QEvent::Type type; // if this represents a QEvent that was received Qt::TouchPointState state; // if this represents an event (pointer, touch or mouse) - int grabState; // if this represents an onGrabChanged() notification (QQuickEventPoint::GrabState) + int grabTransition; // if this represents an onGrabChanged() notification (QQuickEventPoint::GrabTransition) QPointF posWrtItem; QPointF posWrtScene; }; @@ -73,9 +73,9 @@ QDebug operator<<(QDebug dbg, const class Event &event) { QtDebugUtils::formatQEnum(dbg, event.type); dbg << ' '; QtDebugUtils::formatQEnum(dbg, event.state); - if (event.grabState) { + if (event.grabTransition) { dbg << ' '; - QtDebugUtils::formatQEnum(dbg, QQuickEventPoint::GrabState(event.grabState)); + QtDebugUtils::formatQEnum(dbg, QQuickEventPoint::GrabTransition(event.grabTransition)); } dbg << " @ "; QtDebugUtils::formatQPoint(dbg, event.posWrtItem); @@ -98,7 +98,7 @@ public: : QQuickItem(parent), acceptPointer(false), grabPointer(false), acceptMouse(false), acceptTouch(false), filterTouch(false) {} - inline int grabState(bool accept, Qt::TouchPointState state) { + inline int grabTransition(bool accept, Qt::TouchPointState state) { return (accept && (state != Qt::TouchPointReleased)) ? (int)QQuickEventPoint::GrabExclusive : (int)NoGrab; } @@ -106,31 +106,31 @@ public: { qCDebug(lcPointerTests) << event << "will accept?" << acceptTouch; for (const QTouchEvent::TouchPoint &tp : event->touchPoints()) - eventList.append(Event(Event::TouchDestination, event->type(), tp.state(), grabState(acceptTouch, tp.state()), tp.pos(), tp.scenePos())); + eventList.append(Event(Event::TouchDestination, event->type(), tp.state(), grabTransition(acceptTouch, tp.state()), tp.pos(), tp.scenePos())); event->setAccepted(acceptTouch); } void mousePressEvent(QMouseEvent *event) { qCDebug(lcPointerTests) << event; - eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointPressed, grabState(acceptMouse, Qt::TouchPointPressed), event->pos(), event->windowPos())); + eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointPressed, grabTransition(acceptMouse, Qt::TouchPointPressed), event->pos(), event->windowPos())); event->setAccepted(acceptMouse); } void mouseMoveEvent(QMouseEvent *event) { qCDebug(lcPointerTests) << event; - eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointMoved, grabState(acceptMouse, Qt::TouchPointMoved), event->pos(), event->windowPos())); + eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointMoved, grabTransition(acceptMouse, Qt::TouchPointMoved), event->pos(), event->windowPos())); event->setAccepted(acceptMouse); } void mouseReleaseEvent(QMouseEvent *event) { qCDebug(lcPointerTests) << event; - eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointReleased, grabState(acceptMouse, Qt::TouchPointReleased), event->pos(), event->windowPos())); + eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointReleased, grabTransition(acceptMouse, Qt::TouchPointReleased), event->pos(), event->windowPos())); event->setAccepted(acceptMouse); } void mouseDoubleClickEvent(QMouseEvent *event) { qCDebug(lcPointerTests) << event; - eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointPressed, grabState(acceptMouse, Qt::TouchPointPressed), event->pos(), event->windowPos())); + eventList.append(Event(Event::MouseDestination, event->type(), Qt::TouchPointPressed, grabTransition(acceptMouse, Qt::TouchPointPressed), event->pos(), event->windowPos())); event->setAccepted(acceptMouse); } @@ -177,7 +177,7 @@ public: QCOMPARE(event.destination, d);\ QCOMPARE(event.type, t);\ QCOMPARE(event.state, s);\ - QCOMPARE(event.grabState, g);\ + QCOMPARE(event.grabTransition, g);\ }\ class EventHandler : public QQuickPointerHandler @@ -204,7 +204,7 @@ class EventHandler : public QQuickPointerHandler } } - void onGrabChanged(QQuickPointerHandler *, QQuickEventPoint::GrabState stateChange, QQuickEventPoint *point) override + void onGrabChanged(QQuickPointerHandler *, QQuickEventPoint::GrabTransition stateChange, QQuickEventPoint *point) override { EventItem *item = static_cast<EventItem *>(target()); item->eventList.append(Event(Event::HandlerDestination, QEvent::None, diff --git a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp index f9970df9f0..467c964001 100644 --- a/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquicktaphandler/tst_qquicktaphandler.cpp @@ -600,8 +600,8 @@ void tst_TapHandler::componentUserBehavioralOverride() QQuickTapHandler *userTapHandler = button->findChild<QQuickTapHandler*>("override"); QVERIFY(userTapHandler); QSignalSpy tappedSpy(button, SIGNAL(tapped())); - QSignalSpy innerGrabChangedSpy(innerTapHandler, SIGNAL(grabChanged(QQuickEventPoint::GrabState, QQuickEventPoint *))); - QSignalSpy userGrabChangedSpy(userTapHandler, SIGNAL(grabChanged(QQuickEventPoint::GrabState, QQuickEventPoint *))); + QSignalSpy innerGrabChangedSpy(innerTapHandler, SIGNAL(grabChanged(QQuickEventPoint::GrabTransition, QQuickEventPoint *))); + QSignalSpy userGrabChangedSpy(userTapHandler, SIGNAL(grabChanged(QQuickEventPoint::GrabTransition, QQuickEventPoint *))); QSignalSpy innerPressedChangedSpy(innerTapHandler, SIGNAL(pressedChanged())); QSignalSpy userPressedChangedSpy(userTapHandler, SIGNAL(pressedChanged())); |