summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-06-15 14:00:46 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-07-02 15:16:07 (GMT)
commit60e965fd35037f4a27816d2aeccafdff0d6ae9d6 (patch)
tree8a968022a03057cc29aa3f7cc246ee708d869b8a /src/gui/graphicsview
parent099a32d121cbc80a1a234c3146f4be9b5237e7e8 (diff)
downloadQt-60e965fd35037f4a27816d2aeccafdff0d6ae9d6.zip
Qt-60e965fd35037f4a27816d2aeccafdff0d6ae9d6.tar.gz
Qt-60e965fd35037f4a27816d2aeccafdff0d6ae9d6.tar.bz2
Refactored gesture api
Rewritten the api almost from scratch, making it simplier and more flexible at the same time. The current implementation will not have complex gseturemanager class inside Qt, but the QGesture base class, which represents both a gesture recognizer and a gesture itself with a set of properties. A set of common gestures that can use used in third-party applications (and in Qt itself internally) is supposed to be found in qstandardgestures.h, and a base class for user-defined gestures is in qgesture.h Gesture implementation for Pan on Windows7 has also been added as a reference implementation for platform gestures.
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp119
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h5
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h33
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget.cpp13
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp127
-rw-r--r--src/gui/graphicsview/qgraphicsscene.h1
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h8
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.cpp249
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.h43
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp14
10 files changed, 1 insertions, 611 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 2223f5d..c82c2e5 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -574,7 +574,6 @@
#include <private/qtextcontrol_p.h>
#include <private/qtextdocumentlayout_p.h>
#include <private/qtextengine_p.h>
-#include <private/qgesturemanager_p.h>
#ifdef Q_WS_X11
#include <private/qt_x11_p.h>
@@ -615,8 +614,6 @@ public:
};
Q_GLOBAL_STATIC(QGraphicsItemCustomDataStore, qt_dataStore)
-QString qt_getStandardGestureTypeName(Qt::GestureType type);
-
/*!
\internal
@@ -1131,7 +1128,6 @@ QGraphicsItem::~QGraphicsItem()
{
d_ptr->inDestructor = 1;
d_ptr->removeExtraItemCache();
- d_ptr->removeExtraGestures();
clearFocus();
if (!d_ptr->children.isEmpty()) {
@@ -6251,104 +6247,6 @@ QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const
}
/*!
- \since 4.6
-
- Subscribes the graphics item to the specified \a gesture type.
-
- Returns the id of the gesture.
-
- \sa releaseGesture(), setGestureEnabled()
-*/
-int QGraphicsItem::grabGesture(Qt::GestureType gesture)
-{
- /// TODO: if we are QGraphicsProxyWidget we should subscribe the widget to gesture as well.
- return grabGesture(qt_getStandardGestureTypeName(gesture));
-}
-
-/*!
- \since 4.6
-
- Subscribes the graphics item to the specified \a gesture type.
-
- Returns the id of the gesture.
-
- \sa releaseGesture(), setGestureEnabled()
-*/
-int QGraphicsItem::grabGesture(const QString &gesture)
-{
- int id = QGestureManager::instance()->makeGestureId(gesture);
- d_ptr->grabGesture(id);
- return id;
-}
-
-void QGraphicsItemPrivate::grabGesture(int id)
-{
- Q_Q(QGraphicsItem);
- extraGestures()->gestures << id;
- if (scene)
- scene->d_func()->grabGesture(q, id);
-}
-
-bool QGraphicsItemPrivate::releaseGesture(int id)
-{
- Q_Q(QGraphicsItem);
- QGestureExtraData *extra = maybeExtraGestures();
- if (extra && extra->gestures.contains(id)) {
- if (scene)
- scene->d_func()->releaseGesture(q, id);
- extra->gestures.remove(id);
- return true;
- }
- return false;
-}
-
-/*!
- \since 4.6
-
- Unsubscribes the graphics item from a gesture, which is specified
- by the \a gestureId.
-
- \sa grabGesture(), setGestureEnabled()
-*/
-void QGraphicsItem::releaseGesture(int gestureId)
-{
- /// TODO: if we are QGraphicsProxyWidget we should unsubscribe the widget from gesture as well.
- if (d_ptr->releaseGesture(gestureId))
- QGestureManager::instance()->releaseGestureId(gestureId);
-}
-
-/*!
- \since 4.6
-
- If \a enable is true, the gesture with the given \a gestureId is
- enabled; otherwise the gesture is disabled.
-
- The id of the gesture is returned by the grabGesture().
-
- \sa grabGesture(), releaseGesture()
-*/
-void QGraphicsItem::setGestureEnabled(int gestureId, bool enable)
-{
- Q_UNUSED(gestureId);
- Q_UNUSED(enable);
- //###
-}
-
-bool QGraphicsItemPrivate::hasGesture(const QString &name) const
-{
- if (QGestureExtraData *extra = maybeExtraGestures()) {
- QGestureManager *gm = QGestureManager::instance();
- QSet<int>::const_iterator it = extra->gestures.begin(),
- e = extra->gestures.end();
- for (; it != e; ++it) {
- if (gm->gestureNameFromId(*it) == name)
- return true;
- }
- }
- return false;
-}
-
-/*!
This virtual function is called by QGraphicsItem to notify custom items
that some part of the item's state changes. By reimplementing this
function, your can react to a change, and in some cases, (depending on \a
@@ -6372,23 +6270,6 @@ bool QGraphicsItemPrivate::hasGesture(const QString &name) const
QVariant QGraphicsItem::itemChange(GraphicsItemChange change, const QVariant &value)
{
Q_UNUSED(change);
- if (change == QGraphicsItem::ItemSceneChange) {
- QGestureExtraData *extra = d_ptr->maybeExtraGestures();
- if (!qVariantValue<QGraphicsScene*>(value) && extra) {
- // the item has been removed from a scene, unsubscribe gestures.
- Q_ASSERT(d_ptr->scene);
- foreach(int id, extra->gestures)
- d_ptr->scene->d_func()->releaseGesture(this, id);
- }
- } else if (change == QGraphicsItem::ItemSceneHasChanged) {
- QGraphicsScene *scene = qVariantValue<QGraphicsScene*>(value);
- QGestureExtraData *extra = d_ptr->maybeExtraGestures();
- if (scene && extra) {
- // item has been added to the scene
- foreach(int id, extra->gestures)
- scene->d_func()->grabGesture(this, id);
- }
- }
return value;
}
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index 3a3d1a1..b0571c2 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -379,11 +379,6 @@ public:
QVariant data(int key) const;
void setData(int key, const QVariant &value);
- int grabGesture(Qt::GestureType gesture);
- int grabGesture(const QString &gesture);
- void releaseGesture(int gestureId);
- void setGestureEnabled(int gestureId, bool enable = true);
-
enum {
Type = 1,
UserType = 65536
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index a0d061b..a977e1e 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -93,12 +93,6 @@ public:
void purge();
};
-class QGestureExtraData
-{
-public:
- QSet<int> gestures;
-};
-
class Q_AUTOTEST_EXPORT QGraphicsItemPrivate
{
Q_DECLARE_PUBLIC(QGraphicsItem)
@@ -108,8 +102,7 @@ public:
ExtraCursor,
ExtraCacheData,
ExtraMaxDeviceCoordCacheSize,
- ExtraBoundingRegionGranularity,
- ExtraGestures
+ ExtraBoundingRegionGranularity
};
enum AncestorFlag {
@@ -394,30 +387,6 @@ public:
int index;
int depth;
- inline QGestureExtraData* extraGestures() const
- {
- QGestureExtraData *c = (QGestureExtraData *)qVariantValue<void *>(extra(ExtraGestures));
- if (!c) {
- QGraphicsItemPrivate *that = const_cast<QGraphicsItemPrivate *>(this);
- c = new QGestureExtraData;
- that->setExtra(ExtraGestures, qVariantFromValue<void *>(c));
- }
- return c;
- }
- QGestureExtraData* maybeExtraGestures() const
- {
- return (QGestureExtraData *)qVariantValue<void *>(extra(ExtraGestures));
- }
- inline void removeExtraGestures()
- {
- QGestureExtraData *c = (QGestureExtraData *)qVariantValue<void *>(extra(ExtraGestures));
- delete c;
- unsetExtra(ExtraGestures);
- }
- bool hasGesture(const QString &gesture) const;
- void grabGesture(int id);
- bool releaseGesture(int id);
-
// Packed 32 bytes
quint32 acceptedMouseButtons : 5;
quint32 visible : 1;
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp
index f081222..0b421ad 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp
@@ -48,7 +48,6 @@
#include "private/qgraphicsproxywidget_p.h"
#include "private/qwidget_p.h"
#include "private/qapplication_p.h"
-#include "private/qgesturemanager_p.h"
#include <QtCore/qdebug.h>
#include <QtGui/qevent.h>
@@ -649,9 +648,6 @@ void QGraphicsProxyWidgetPrivate::setWidget_helper(QWidget *newWidget, bool auto
q->setAttribute(Qt::WA_OpaquePaintEvent);
widget = newWidget;
- foreach(int gestureId, widget->d_func()->gestures) {
- grabGesture(gestureId);
- }
// Changes only go from the widget to the proxy.
enabledChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
@@ -875,15 +871,6 @@ bool QGraphicsProxyWidget::event(QEvent *event)
}
break;
}
- case QEvent::GraphicsSceneGesture: {
- qDebug() << "QGraphicsProxyWidget: graphicsscenegesture";
- if (d->widget && d->widget->isVisible()) {
- //### TODO: widget->childAt(): decompose gesture event and find widget under hotspots.
- //QGestureManager::instance()->sendGestureEvent(d->widget, ge->gestures().toSet(), ge->cancelledGestures());
- return true;
- }
- break;
- }
default:
break;
}
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index e50ee94..c3f72e6 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -247,8 +247,6 @@
#ifdef Q_WS_X11
#include <private/qt_x11_p.h>
#endif
-#include <private/qgesturemanager_p.h>
-#include <private/qgesture_p.h>
QT_BEGIN_NAMESPACE
@@ -4018,47 +4016,6 @@ bool QGraphicsScene::event(QEvent *event)
// geometries that do not have an explicit style set.
update();
break;
- case QEvent::GraphicsSceneGesture: {
- QGraphicsSceneGestureEvent *ev = static_cast<QGraphicsSceneGestureEvent*>(event);
- QGraphicsView *view = qobject_cast<QGraphicsView*>(ev->widget());
- if (!view) {
- qWarning("QGraphicsScene::event: gesture event was received without a view");
- break;
- }
-
- // get a list of gestures that just started.
- QSet<QGesture*> startedGestures;
- QList<QGesture*> gestures = ev->gestures();
- for(QList<QGesture*>::const_iterator it = gestures.begin(), e = gestures.end();
- it != e; ++it) {
- QGesture *g = *it;
- QGesturePrivate *gd = g->d_func();
- if (g->state() == Qt::GestureStarted || gd->singleshot) {
- startedGestures.insert(g);
- }
- }
- if (!startedGestures.isEmpty()) {
- // find a target for each started gesture.
- for(QSet<QGesture*>::const_iterator it = startedGestures.begin(), e = startedGestures.end();
- it != e; ++it) {
- QGesture *g = *it;
- QGesturePrivate *gd = g->d_func();
- gd->graphicsItem = 0;
- QList<QGraphicsItem*> itemsInGestureArea = items(g->hotSpot());
- const QString gestureName = g->type();
- foreach(QGraphicsItem *item, itemsInGestureArea) {
- if (item->d_func()->hasGesture(gestureName)) {
- Q_ASSERT(gd->graphicsItem == 0);
- gd->graphicsItem = item;
- d->itemsWithGestures[item].insert(g);
- break;
- }
- }
- }
- }
- d->sendGestureEvent(ev->gestures().toSet(), ev->cancelledGestures());
- }
- break;
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
@@ -4080,69 +4037,6 @@ bool QGraphicsScene::event(QEvent *event)
return true;
}
-void QGraphicsScenePrivate::sendGestureEvent(const QSet<QGesture*> &gestures, const QSet<QString> &cancelled)
-{
- Q_Q(QGraphicsScene);
- typedef QMap<QGraphicsItem*, QSet<QGesture*> > ItemGesturesMap;
- ItemGesturesMap itemGestures;
- QSet<QGesture*> startedGestures;
- for(QSet<QGesture*>::const_iterator it = gestures.begin(), e = gestures.end();
- it != e; ++it) {
- QGesture *g = *it;
- Q_ASSERT(g != 0);
- QGesturePrivate *gd = g->d_func();
- if (gd->graphicsItem != 0) {
- itemGestures[gd->graphicsItem].insert(g);
- if (g->state() == Qt::GestureStarted || gd->singleshot)
- startedGestures.insert(g);
- }
- }
-
- QSet<QGesture*> ignoredGestures;
- for(ItemGesturesMap::const_iterator it = itemGestures.begin(), e = itemGestures.end();
- it != e; ++it) {
- QGraphicsItem *receiver = it.key();
- Q_ASSERT(receiver != 0);
- QGraphicsSceneGestureEvent event;
- event.setGestures(it.value());
- event.setCancelledGestures(cancelled);
- bool processed = sendEvent(receiver, &event);
- QSet<QGesture*> started = startedGestures.intersect(it.value());
- if (event.isAccepted())
- foreach(QGesture *g, started)
- g->accept();
- if (!started.isEmpty() && !(processed && event.isAccepted())) {
- // there are started gestures event that weren't
- // accepted, so propagating each gesture independently.
- QSet<QGesture*>::const_iterator it = started.begin(),
- e = started.end();
- for(; it != e; ++it) {
- QGesture *g = *it;
- if (processed && g->isAccepted()) {
- continue;
- }
- QGesturePrivate *gd = g->d_func();
- gd->graphicsItem = 0;
-
- //### THIS IS BS, DONT FORGET TO REWRITE THIS CODE
- // need to make sure we try to deliver event just once to each widget
- const QString gestureType = g->type();
- QList<QGraphicsItem*> itemsUnderGesture = q->items(g->hotSpot());
- for (int i = 0; i < itemsUnderGesture.size(); ++i) {
- QGraphicsItem *item = itemsUnderGesture.at(i);
- if (item != receiver && item->d_func()->hasGesture(gestureType)) {
- ignoredGestures.insert(g);
- gd->graphicsItem = item;
- break;
- }
- }
- }
- }
- }
- if (!ignoredGestures.isEmpty())
- sendGestureEvent(ignoredGestures, cancelled);
-}
-
/*!
\reimp
@@ -6018,32 +5912,11 @@ bool QGraphicsScene::sendEvent(QGraphicsItem *item, QEvent *event)
void QGraphicsScenePrivate::addView(QGraphicsView *view)
{
views << view;
- foreach(int gestureId, grabbedGestures)
- view->d_func()->grabGesture(gestureId);
}
void QGraphicsScenePrivate::removeView(QGraphicsView *view)
{
views.removeAll(view);
- foreach(int gestureId, grabbedGestures)
- view->releaseGesture(gestureId);
-}
-
-void QGraphicsScenePrivate::grabGesture(QGraphicsItem *item, int gestureId)
-{
- if (!grabbedGestures.contains(gestureId)) {
- foreach(QGraphicsView *view, views)
- view->d_func()->grabGesture(gestureId);
- }
- (void)itemsWithGestures[item];
- grabbedGestures << gestureId;
-}
-
-void QGraphicsScenePrivate::releaseGesture(QGraphicsItem *item, int gestureId)
-{
- Q_UNUSED(gestureId);
- itemsWithGestures.remove(item);
- //###
}
void QGraphicsScenePrivate::updateTouchPointsForItem(QGraphicsItem *item, QTouchEvent *touchEvent)
diff --git a/src/gui/graphicsview/qgraphicsscene.h b/src/gui/graphicsview/qgraphicsscene.h
index c8b147f..6aaeb91 100644
--- a/src/gui/graphicsview/qgraphicsscene.h
+++ b/src/gui/graphicsview/qgraphicsscene.h
@@ -79,7 +79,6 @@ class QGraphicsSceneHelpEvent;
class QGraphicsSceneHoverEvent;
class QGraphicsSceneMouseEvent;
class QGraphicsSceneWheelEvent;
-class QGraphicsSceneGestureEvent;
class QGraphicsSimpleTextItem;
class QGraphicsTextItem;
class QGraphicsView;
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index 3c3a811..d2d603a 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -78,7 +78,6 @@ QT_BEGIN_NAMESPACE
class QGraphicsView;
class QGraphicsWidget;
-class QGesture;
class QGraphicsScenePrivate : public QObjectPrivate
{
@@ -309,13 +308,6 @@ public:
QStyleOptionGraphicsItem styleOptionTmp;
- // items with gestures -> list of started gestures.
- QMap<QGraphicsItem*, QSet<QGesture*> > itemsWithGestures;
- QSet<int> grabbedGestures;
- void grabGesture(QGraphicsItem *item, int gestureId);
- void releaseGesture(QGraphicsItem *item, int gestureId);
- void sendGestureEvent(const QSet<QGesture*> &gestures, const QSet<QString> &cancelled);
-
QMap<int, QTouchEvent::TouchPoint> sceneCurrentTouchPoints;
QMap<int, QGraphicsItem *> itemForTouchPointId;
static void updateTouchPointsForItem(QGraphicsItem *item, QTouchEvent *touchEvent);
diff --git a/src/gui/graphicsview/qgraphicssceneevent.cpp b/src/gui/graphicsview/qgraphicssceneevent.cpp
index 27a2d7e..53019f2 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.cpp
+++ b/src/gui/graphicsview/qgraphicssceneevent.cpp
@@ -275,8 +275,6 @@
QT_BEGIN_NAMESPACE
-QString qt_getStandardGestureTypeName(Qt::GestureType type);
-
class QGraphicsSceneEventPrivate
{
public:
@@ -1679,253 +1677,6 @@ void QGraphicsSceneMoveEvent::setNewPos(const QPointF &pos)
d->newPos = pos;
}
-/*!
- \class QGraphicsSceneGestureEvent
- \brief The QGraphicsSceneGestureEvent class provides gesture events for
- the graphics view framework.
- \since 4.6
- \ingroup multimedia
- \ingroup graphicsview-api
-
- QGraphicsSceneGestureEvent extends information provided by
- QGestureEvent by adding some convenience functions like
- \l{QGraphicsSceneEvent::}{widget()} to get a widget that received
- original gesture event, and convenience functions mapToScene(),
- mapToItem() for converting positions of the gesture into
- QGraphicsScene and QGraphicsItem coordinate system respectively.
-
- The scene sends the event to the first QGraphicsItem under the
- mouse cursor that accepts gestures; a graphics item is set to accept
- gestures with \l{QGraphicsItem::}{grabGesture()}.
-
- \sa QGestureEvent
-*/
-
-/*!
- Constructs a QGraphicsSceneGestureEvent.
-*/
-QGraphicsSceneGestureEvent::QGraphicsSceneGestureEvent()
- : QGraphicsSceneEvent(QEvent::GraphicsSceneGesture)
-{
- setAccepted(false);
-}
-
-/*!
- Destroys a QGraphicsSceneGestureEvent.
-*/
-QGraphicsSceneGestureEvent::~QGraphicsSceneGestureEvent()
-{
-}
-
-/*!
- Returns true if the gesture event contains gesture of specific \a
- type; returns false otherwise.
-*/
-bool QGraphicsSceneGestureEvent::contains(const QString &type) const
-{
- return gesture(type) != 0;
-}
-
-/*!
- Returns true if the gesture event contains gesture of specific \a
- type; returns false otherwise.
-*/
-bool QGraphicsSceneGestureEvent::contains(Qt::GestureType type) const
-{
- return contains(qt_getStandardGestureTypeName(type));
-}
-
-/*!
- Returns a list of gesture names that this event contains.
-*/
-QList<QString> QGraphicsSceneGestureEvent::gestureTypes() const
-{
- return m_gestures.keys();
-}
-
-/*!
- Returns extended information about a gesture of specific \a type.
-*/
-const QGesture* QGraphicsSceneGestureEvent::gesture(const QString &type) const
-{
- return m_gestures.value(type, 0);
-}
-
-/*!
- Returns extended information about a gesture of specific \a type.
-*/
-const QGesture* QGraphicsSceneGestureEvent::gesture(Qt::GestureType type) const
-{
- return gesture(qt_getStandardGestureTypeName(type));
-}
-
-/*!
- Returns extended information about all gestures in the event.
-*/
-QList<QGesture*> QGraphicsSceneGestureEvent::gestures() const
-{
- return m_gestures.values();
-}
-
-/*!
- Returns a set of gesture names that used to be executed, but were
- cancelled (i.e. they were not finished properly).
-*/
-QSet<QString> QGraphicsSceneGestureEvent::cancelledGestures() const
-{
- return m_cancelledGestures;
-}
-
-/*!
- Sets a list of gesture names \a cancelledGestures that used to be
- executed, but were cancelled (i.e. they were not finished
- properly).
-*/
-void QGraphicsSceneGestureEvent::setCancelledGestures(const QSet<QString> &cancelledGestures)
-{
- m_cancelledGestures = cancelledGestures;
-}
-
-/*!
- Maps the point \a point, which is in a view coordinate system, to
- scene coordinate system, and returns the mapped coordinate.
-
- A \a point is in coordinate system of the widget that received
- gesture event.
-
- \sa mapToItem(), {The Graphics View Coordinate System}
-*/
-QPointF QGraphicsSceneGestureEvent::mapToScene(const QPoint &point) const
-{
- if (QGraphicsView *view = qobject_cast<QGraphicsView*>(widget()))
- return view->mapToScene(point);
- return QPointF();
-}
-
-/*!
- Maps the rectangular \a rect, which is in a view coordinate system, to
- scene coordinate system, and returns the mapped coordinate.
-
- A \a rect is in coordinate system of the widget that received
- gesture event.
-
- \sa mapToItem(), {The Graphics View Coordinate System}
-*/
-QPolygonF QGraphicsSceneGestureEvent::mapToScene(const QRect &rect) const
-{
- if (QGraphicsView *view = qobject_cast<QGraphicsView*>(widget()))
- return view->mapToScene(rect);
- return QPolygonF();
-}
-
-/*!
- Maps the point \a point, which is in a view coordinate system, to
- item's \a item coordinate system, and returns the mapped coordinate.
-
- If \a item is 0, this function returns the same as mapToScene().
-
- \sa mapToScene(), {The Graphics View Coordinate System}
-*/
-QPointF QGraphicsSceneGestureEvent::mapToItem(const QPoint &point, QGraphicsItem *item) const
-{
- if (item) {
- if (QGraphicsView *view = qobject_cast<QGraphicsView*>(widget()))
- return item->mapFromScene(view->mapToScene(point));
- } else {
- return mapToScene(point);
- }
- return QPointF();
-}
-
-/*!
- Maps the rectangualar \a rect, which is in a view coordinate system, to
- item's \a item coordinate system, and returns the mapped coordinate.
-
- If \a item is 0, this function returns the same as mapToScene().
-
- \sa mapToScene(), {The Graphics View Coordinate System}
-*/
-QPolygonF QGraphicsSceneGestureEvent::mapToItem(const QRect &rect, QGraphicsItem *item) const
-{
- if (item) {
- if (QGraphicsView *view = qobject_cast<QGraphicsView*>(widget()))
- return item->mapFromScene(view->mapToScene(rect));
- } else {
- return mapToScene(rect);
- }
- return QPolygonF();
-}
-
-/*!
- Set a list of gesture objects containing extended information about \a gestures.
-*/
-void QGraphicsSceneGestureEvent::setGestures(const QList<QGesture*> &gestures)
-{
- foreach(QGesture *g, gestures)
- m_gestures.insert(g->type(), g);
-}
-
-/*!
- Set a list of gesture objects containing extended information about \a gestures.
-*/
-void QGraphicsSceneGestureEvent::setGestures(const QSet<QGesture*> &gestures)
-{
- foreach(QGesture *g, gestures)
- m_gestures.insert(g->type(), g);
-}
-
-/*!
- Sets the accept flag of the all gestures for the event object.
- This is the equivalent of calling \l{QEvent::accept()} {accept()}
- or \l{QEvent::setAccepted()}{setAccepted(true)}.
-
- Setting the accept flag indicates that the event receiver wants
- the gesture. Unwanted gestures might be propagated to the parent
- widget.
-*/
-void QGraphicsSceneGestureEvent::acceptAll()
-{
- QHash<QString, QGesture*>::iterator it = m_gestures.begin(),
- e = m_gestures.end();
- for(; it != e; ++it)
- it.value()->accept();
- setAccepted(true);
-}
-
-/*! \fn void QGraphicsSceneGestureEvent::accept()
- Calls QEvent::accept().
-*/
-
-/*!
- Sets the accept flag of the gesture specified by \a type. This is
- equivalent to calling \l{QGestureEvent::gesture()} {gesture(type)}->
- \l{QGesture::accept()}{accept()}
-
- Setting the accept flag indicates that the event receiver
- wants the gesture. Unwanted gestures might be propagated to the parent
- widget.
-*/
-void QGraphicsSceneGestureEvent::accept(Qt::GestureType type)
-{
- if (QGesture *g = m_gestures.value(qt_getStandardGestureTypeName(type), 0))
- g->accept();
-}
-
-/*!
-
- Sets the accept flag of the gesture specified by \a type. This is
- equivalent to calling \l{QGestureEvent::gesture()} {gesture(type)}->
- \l{QGesture::accept()}{accept()}
-
- Setting the accept flag indicates that the event receiver wants the
- gesture. Unwanted gestures might be propagated to the parent widget.
-*/
-void QGraphicsSceneGestureEvent::accept(const QString &type)
-{
- if (QGesture *g = m_gestures.value(type, 0))
- g->accept();
-}
-
QT_END_NAMESPACE
#endif // QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicssceneevent.h b/src/gui/graphicsview/qgraphicssceneevent.h
index 8a30bb8..b38e757 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.h
+++ b/src/gui/graphicsview/qgraphicssceneevent.h
@@ -306,49 +306,6 @@ public:
void setNewPos(const QPointF &pos);
};
-class QGesture;
-class QGraphicsItem;
-class QGraphicsSceneGestureEventPrivate;
-class Q_GUI_EXPORT QGraphicsSceneGestureEvent : public QGraphicsSceneEvent
-{
- Q_DECLARE_PRIVATE(QGraphicsSceneGestureEvent)
-public:
- QGraphicsSceneGestureEvent();
- ~QGraphicsSceneGestureEvent();
-
- bool contains(const QString &type) const;
- bool contains(Qt::GestureType type) const;
-
- QList<QString> gestureTypes() const;
-
- const QGesture* gesture(Qt::GestureType type) const;
- const QGesture* gesture(const QString &type) const;
- QList<QGesture*> gestures() const;
- void setGestures(const QList<QGesture*> &gestures);
- void setGestures(const QSet<QGesture*> &gestures);
-
- QSet<QString> cancelledGestures() const;
- void setCancelledGestures(const QSet<QString> &cancelledGestures);
-
- void acceptAll();
-#ifndef Q_NO_USING_KEYWORD
- using QEvent::accept;
-#else
- inline void accept() { QEvent::accept(); }
-#endif
- void accept(Qt::GestureType type);
- void accept(const QString &type);
-
- QPointF mapToScene(const QPoint &point) const;
- QPolygonF mapToScene(const QRect &rect) const;
- QPointF mapToItem(const QPoint &point, QGraphicsItem *item) const;
- QPolygonF mapToItem(const QRect &rect, QGraphicsItem *item) const;
-
-protected:
- QHash<QString, QGesture*> m_gestures;
- QSet<QString> m_cancelledGestures;
-};
-
#endif // QT_NO_GRAPHICSVIEW
QT_END_NAMESPACE
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index a2adf82..56a69f7 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -2658,9 +2658,6 @@ bool QGraphicsView::event(QEvent *event)
}
}
break;
- case QEvent::Gesture:
- viewportEvent(event);
- return true;
default:
break;
}
@@ -2742,17 +2739,6 @@ bool QGraphicsView::viewportEvent(QEvent *event)
d->scene->d_func()->updateAll = false;
}
break;
- case QEvent::Gesture: {
- QGraphicsSceneGestureEvent gestureEvent;
- gestureEvent.setWidget(this);
- QGestureEvent *ev = static_cast<QGestureEvent*>(event);
- gestureEvent.setGestures(ev->gestures());
- gestureEvent.setCancelledGestures(ev->cancelledGestures());
- QApplication::sendEvent(d->scene, &gestureEvent);
- event->setAccepted(gestureEvent.isAccepted());
- return true;
- }
- break;
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd: