summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-10-09 17:09:09 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-10-09 17:09:09 (GMT)
commitf2437d3aa6cc274b9e663801892fd4e40e693546 (patch)
tree7a5b1425ac403336eb77c80ca0a551e7222f60f8 /src/gui/graphicsview
parent7566a1f15ea32504c10d9467fb69a6399a06c325 (diff)
downloadQt-f2437d3aa6cc274b9e663801892fd4e40e693546.zip
Qt-f2437d3aa6cc274b9e663801892fd4e40e693546.tar.gz
Qt-f2437d3aa6cc274b9e663801892fd4e40e693546.tar.bz2
A new implementation of the Gesture API.
Implemented gestures using gesture events and separate QGesture/QGestureRecognizer classes. Reviewed-by: trustme
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp9
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h4
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h1
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp11
-rw-r--r--src/gui/graphicsview/qgraphicsscene.h1
5 files changed, 21 insertions, 5 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 3069733..81bbb5c 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -663,6 +663,8 @@
#include <private/qpixmap_x11_p.h>
#endif
+#include <private/qgesturemanager_p.h>
+
#include <math.h>
QT_BEGIN_NAMESPACE
@@ -7285,6 +7287,13 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent
QGraphicsItem::d_ptr->isObject = true;
}
+void QGraphicsObject::grabGesture(Qt::GestureType type, Qt::GestureContext context)
+{
+ QGraphicsItemPrivate * const d = QGraphicsItem::d_func();
+ d->gestureContext.insert(type, context);
+ (void)QGestureManager::instance(); // create a gesture manager
+}
+
/*!
\property QGraphicsObject::parent
\brief the parent of the item
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index e6e324a..2665235 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -464,6 +464,7 @@ private:
friend class QGraphicsSceneBspTree;
friend class QGraphicsView;
friend class QGraphicsViewPrivate;
+ friend class QGraphicsObject;
friend class QGraphicsWidget;
friend class QGraphicsWidgetPrivate;
friend class QGraphicsProxyWidgetPrivate;
@@ -473,6 +474,7 @@ private:
friend class QGraphicsSceneBspTreeIndexPrivate;
friend class QGraphicsItemEffectSourcePrivate;
friend class QGraphicsTransformPrivate;
+ friend class QGestureManager;
friend class ::tst_QGraphicsItem;
friend bool qt_closestLeaf(const QGraphicsItem *, const QGraphicsItem *);
friend bool qt_closestItemFirst(const QGraphicsItem *, const QGraphicsItem *);
@@ -553,6 +555,8 @@ public:
using QObject::children;
#endif
+ void grabGesture(Qt::GestureType type, Qt::GestureContext context = Qt::WidgetWithChildrenGesture);
+
Q_SIGNALS:
void parentChanged();
void opacityChanged();
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 51bfea1..6550362 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -450,6 +450,7 @@ public:
QGraphicsItem *focusScopeItem;
Qt::InputMethodHints imHints;
QGraphicsItem::PanelModality panelModality;
+ QMap<Qt::GestureType, Qt::GestureContext> gestureContext;
// Packed 32 bits
quint32 acceptedMouseButtons : 5;
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 961f44f..0f33a66 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -5475,11 +5475,11 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent)
}
if (itemsNeedingEvents.isEmpty()) {
- sceneTouchEvent->ignore();
+ sceneTouchEvent->accept();
return;
}
- bool acceptSceneTouchEvent = false;
+ bool ignoreSceneTouchEvent = true;
QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator it = itemsNeedingEvents.constBegin();
const QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator end = itemsNeedingEvents.constEnd();
for (; it != end; ++it) {
@@ -5522,19 +5522,20 @@ void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent)
item->d_ptr->acceptedTouchBeginEvent = true;
bool res = sendTouchBeginEvent(item, &touchEvent)
&& touchEvent.isAccepted();
- acceptSceneTouchEvent = acceptSceneTouchEvent || res;
+ if (!res)
+ ignoreSceneTouchEvent = false;
break;
}
default:
if (item->d_ptr->acceptedTouchBeginEvent) {
updateTouchPointsForItem(item, &touchEvent);
(void) sendEvent(item, &touchEvent);
- acceptSceneTouchEvent = true;
+ ignoreSceneTouchEvent = false;
}
break;
}
}
- sceneTouchEvent->setAccepted(acceptSceneTouchEvent);
+ sceneTouchEvent->setAccepted(ignoreSceneTouchEvent);
}
bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEvent *touchEvent)
diff --git a/src/gui/graphicsview/qgraphicsscene.h b/src/gui/graphicsview/qgraphicsscene.h
index ba47530..d6d48d7 100644
--- a/src/gui/graphicsview/qgraphicsscene.h
+++ b/src/gui/graphicsview/qgraphicsscene.h
@@ -311,6 +311,7 @@ private:
friend class QGraphicsSceneBspTreeIndex;
friend class QGraphicsSceneBspTreeIndexPrivate;
friend class QGraphicsItemEffectSourcePrivate;
+ friend class QGesture;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsScene::SceneLayers)