summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsscene.cpp
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-10-13 08:11:54 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-10-22 14:59:18 (GMT)
commitd1a60dcbddbae46aaea655bb55c0c8fd46f38b2c (patch)
tree7da27d0d94a66a7806acffc57211c8d8556b5e5f /src/gui/graphicsview/qgraphicsscene.cpp
parent1b154ddf00473700d697411304804ac065ef32ac (diff)
downloadQt-d1a60dcbddbae46aaea655bb55c0c8fd46f38b2c.zip
Qt-d1a60dcbddbae46aaea655bb55c0c8fd46f38b2c.tar.gz
Qt-d1a60dcbddbae46aaea655bb55c0c8fd46f38b2c.tar.bz2
Improved gesture event filtering inside QGraphicsView for QGraphicObjects
Reviewed-by: trustme
Diffstat (limited to 'src/gui/graphicsview/qgraphicsscene.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index a624b10..373ee89 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -242,7 +242,6 @@
#include <QtGui/qstyleoption.h>
#include <QtGui/qtooltip.h>
#include <QtGui/qtransform.h>
-#include <QtGui/qgesture.h>
#include <QtGui/qinputcontext.h>
#include <QtGui/qgraphicseffect.h>
#include <private/qapplication_p.h>
@@ -251,6 +250,7 @@
#include <private/qt_x11_p.h>
#endif
#include <private/qgraphicseffect_p.h>
+#include <private/qgesturemanager_p.h>
QT_BEGIN_NAMESPACE
@@ -1052,6 +1052,14 @@ bool QGraphicsScenePrivate::filterEvent(QGraphicsItem *item, QEvent *event)
*/
bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event)
{
+ if (QGraphicsObject *object = item->toGraphicsObject()) {
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
+ if (qAppPriv->gestureManager) {
+ if (qAppPriv->gestureManager->filterEvent(object, event))
+ return true;
+ }
+ }
+
if (filterEvent(item, event))
return false;
if (filterDescendantEvent(item, event))
@@ -3365,6 +3373,10 @@ bool QGraphicsScene::event(QEvent *event)
case QEvent::TouchEnd:
d->touchEventHandler(static_cast<QTouchEvent *>(event));
break;
+ case QEvent::Gesture:
+ case QEvent::GestureOverride:
+ d->gestureEventHandler(static_cast<QGestureEvent *>(event));
+ break;
default:
return QObject::event(event);
}
@@ -5699,6 +5711,32 @@ void QGraphicsScenePrivate::leaveModal(QGraphicsItem *panel)
dispatchHoverEvent(&hoverEvent);
}
+void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event)
+{
+ QWidget *viewport = event->widget();
+ QList<QGesture *> gestures = event->allGestures();
+ for (int i = 0; i < gestures.size(); ++i) {
+ QGesture *gesture = gestures.at(i);
+ Qt::GestureType gestureType = gesture->gestureType();
+ QPoint screenPos = gesture->hotSpot().toPoint();
+ QList<QGraphicsItem *> items = itemsAtPosition(screenPos, QPointF(), viewport);
+ for (int j = 0; j < items.size(); ++j) {
+ QGraphicsObject *item = items.at(j)->toGraphicsObject();
+ if (!item)
+ continue;
+ QGraphicsItemPrivate *d = item->QGraphicsItem::d_func();
+ if (d->gestureContext.contains(gestureType)) {
+ QGestureEvent ev(QList<QGesture *>() << gesture);
+ ev.t = event->t;
+ ev.spont = event->spont;
+ ev.setWidget(event->widget());
+ sendEvent(item, &ev);
+ break;
+ }
+ }
+ }
+}
+
QT_END_NAMESPACE
#include "moc_qgraphicsscene.cpp"