summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorTasuku Suzuki <tasuku.suzuki@nokia.com>2010-06-02 07:35:14 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2010-06-02 07:37:03 (GMT)
commitf62926954a742990a33a54ad598de1af0989d92b (patch)
tree34a392cc5c8359eac142207c3c726294c514d822 /src/gui/graphicsview
parent37a0291f932b0af0f6844898ccbce52415f0f179 (diff)
downloadQt-f62926954a742990a33a54ad598de1af0989d92b.zip
Qt-f62926954a742990a33a54ad598de1af0989d92b.tar.gz
Qt-f62926954a742990a33a54ad598de1af0989d92b.tar.bz2
Add a new qconfig feature GESTURES
Merge-request: 535 Reviewed-by: Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp5
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h4
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp13
-rw-r--r--src/gui/graphicsview/qgraphicsscene.h2
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp4
7 files changed, 32 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index b3e1701..8042c46 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1427,12 +1427,14 @@ QGraphicsItem::~QGraphicsItem()
d_ptr->inDestructor = 1;
d_ptr->removeExtraItemCache();
+#ifndef QT_NO_GESTURES
if (d_ptr->isObject && !d_ptr->gestureContext.isEmpty()) {
QGraphicsObject *o = static_cast<QGraphicsObject *>(this);
QGestureManager *manager = QGestureManager::instance();
foreach (Qt::GestureType type, d_ptr->gestureContext.keys())
manager->cleanupCachedGestures(o, type);
}
+#endif
clearFocus();
@@ -7571,6 +7573,7 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent
QGraphicsItem::d_ptr->isObject = true;
}
+#ifndef QT_NO_GESTURES
/*!
Subscribes the graphics object to the given \a gesture with specific \a flags.
@@ -7594,6 +7597,8 @@ void QGraphicsObject::ungrabGesture(Qt::GestureType gesture)
if (QGraphicsItem::d_ptr->gestureContext.remove(gesture) && QGraphicsItem::d_ptr->scene)
QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture);
}
+#endif // QT_NO_GESTURES
+
/*!
Updates the item's micro focus. This is slot for convenience.
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index 9891af3..d7d5332 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -485,7 +485,9 @@ private:
friend class QGraphicsSceneBspTreeIndexPrivate;
friend class QGraphicsItemEffectSourcePrivate;
friend class QGraphicsTransformPrivate;
+#ifndef QT_NO_GESTURES
friend class QGestureManager;
+#endif
friend class ::tst_QGraphicsItem;
friend bool qt_closestLeaf(const QGraphicsItem *, const QGraphicsItem *);
friend bool qt_closestItemFirst(const QGraphicsItem *, const QGraphicsItem *);
@@ -572,8 +574,10 @@ public:
using QObject::children;
#endif
+#ifndef QT_NO_GESTURES
void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags());
void ungrabGesture(Qt::GestureType type);
+#endif
protected Q_SLOTS:
void updateMicroFocus();
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index e812f29..bde6e7d 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -525,7 +525,9 @@ public:
QGraphicsItem *focusScopeItem;
Qt::InputMethodHints imHints;
QGraphicsItem::PanelModality panelModality;
+#ifndef QT_NO_GESTURES
QMap<Qt::GestureType, Qt::GestureFlags> gestureContext;
+#endif
// Packed 32 bits
quint32 acceptedMouseButtons : 5;
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 22c3f92..7b0722e 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -699,6 +699,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
if (!selectionChanging && selectedItems.size() != oldSelectedItemsSize)
emit q->selectionChanged();
+#ifndef QT_NO_GESTURES
QHash<QGesture *, QGraphicsObject *>::iterator it;
for (it = gestureTargets.begin(); it != gestureTargets.end();) {
if (it.value() == item)
@@ -706,6 +707,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
else
++it;
}
+
QGraphicsObject *dummy = static_cast<QGraphicsObject *>(item);
cachedTargetItems.removeOne(dummy);
cachedItemGestures.remove(dummy);
@@ -713,6 +715,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys())
ungrabGesture(item, gesture);
+#endif // QT_NO_GESTURES
}
/*!
@@ -1180,11 +1183,13 @@ bool QGraphicsScenePrivate::filterEvent(QGraphicsItem *item, QEvent *event)
bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event)
{
if (QGraphicsObject *object = item->toGraphicsObject()) {
+#ifndef QT_NO_GESTURES
QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager;
if (gestureManager) {
if (gestureManager->filterEvent(object, event))
return true;
}
+#endif // QT_NO_GESTURES
}
if (filterEvent(item, event))
@@ -2602,8 +2607,10 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
d->enableTouchEventsOnViews();
}
+#ifndef QT_NO_GESTURES
foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys())
d->grabGesture(item, gesture);
+#endif
// Update selection lists
if (item->isSelected())
@@ -3525,10 +3532,12 @@ bool QGraphicsScene::event(QEvent *event)
case QEvent::TouchEnd:
d->touchEventHandler(static_cast<QTouchEvent *>(event));
break;
+#ifndef QT_NO_GESTURES
case QEvent::Gesture:
case QEvent::GestureOverride:
d->gestureEventHandler(static_cast<QGestureEvent *>(event));
break;
+#endif // QT_NO_GESTURES
default:
return QObject::event(event);
}
@@ -5637,8 +5646,10 @@ bool QGraphicsScene::sendEvent(QGraphicsItem *item, QEvent *event)
void QGraphicsScenePrivate::addView(QGraphicsView *view)
{
views << view;
+#ifndef QT_NO_GESTURES
foreach (Qt::GestureType gesture, grabbedGestures.keys())
view->viewport()->grabGesture(gesture);
+#endif
}
void QGraphicsScenePrivate::removeView(QGraphicsView *view)
@@ -5968,6 +5979,7 @@ void QGraphicsScenePrivate::leaveModal(QGraphicsItem *panel)
dispatchHoverEvent(&hoverEvent);
}
+#ifndef QT_NO_GESTURES
void QGraphicsScenePrivate::gestureTargetsAtHotSpots(const QSet<QGesture *> &gestures,
Qt::GestureFlag flag,
QHash<QGraphicsObject *, QSet<QGesture *> > *targets,
@@ -6356,6 +6368,7 @@ void QGraphicsScenePrivate::ungrabGesture(QGraphicsItem *item, Qt::GestureType g
view->viewport()->ungrabGesture(gesture);
}
}
+#endif // QT_NO_GESTURES
QT_END_NAMESPACE
diff --git a/src/gui/graphicsview/qgraphicsscene.h b/src/gui/graphicsview/qgraphicsscene.h
index c34a303..f8615f4 100644
--- a/src/gui/graphicsview/qgraphicsscene.h
+++ b/src/gui/graphicsview/qgraphicsscene.h
@@ -313,7 +313,9 @@ private:
friend class QGraphicsSceneBspTreeIndex;
friend class QGraphicsSceneBspTreeIndexPrivate;
friend class QGraphicsItemEffectSourcePrivate;
+#ifndef QT_NO_GESTURES
friend class QGesture;
+#endif
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsScene::SceneLayers)
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index 8ad2a0a..f28dfe9 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -299,6 +299,7 @@ public:
void enableTouchEventsOnViews();
QList<QGraphicsObject *> cachedTargetItems;
+#ifndef QT_NO_GESTURES
QHash<QGraphicsObject *, QSet<QGesture *> > cachedItemGestures;
QHash<QGraphicsObject *, QSet<QGesture *> > cachedAlreadyDeliveredGestures;
QHash<QGesture *, QGraphicsObject *> gestureTargets;
@@ -313,6 +314,7 @@ public:
void cancelGesturesForChildren(QGesture *original);
void grabGesture(QGraphicsItem *, Qt::GestureType gesture);
void ungrabGesture(QGraphicsItem *, Qt::GestureType gesture);
+#endif // QT_NO_GESTURES
void updateInputMethodSensitivityInViews();
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index a83b528..0674610 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -2688,10 +2688,12 @@ void QGraphicsView::setupViewport(QWidget *widget)
if (d->scene && !d->scene->d_func()->allItemsIgnoreTouchEvents)
widget->setAttribute(Qt::WA_AcceptTouchEvents);
+#ifndef QT_NO_GESTURES
if (d->scene) {
foreach (Qt::GestureType gesture, d->scene->d_func()->grabbedGestures.keys())
widget->grabGesture(gesture);
}
+#endif
widget->setAcceptDrops(acceptDrops());
}
@@ -2838,6 +2840,7 @@ bool QGraphicsView::viewportEvent(QEvent *event)
return true;
}
+#ifndef QT_NO_GESTURES
case QEvent::Gesture:
case QEvent::GestureOverride:
{
@@ -2851,6 +2854,7 @@ bool QGraphicsView::viewportEvent(QEvent *event)
}
return true;
}
+#endif // QT_NO_GESTURES
default:
break;
}