summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp46
-rw-r--r--src/gui/graphicsview/qgraphicsitemanimation.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicslayoutitem.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp31
-rw-r--r--src/gui/graphicsview/qgraphicsscene.h1
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h3
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp5
7 files changed, 63 insertions, 27 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index fd128b8..dfd58b3 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -50,7 +50,7 @@
It provides a light-weight foundation for writing your own custom items.
This includes defining the item's geometry, collision detection, its
painting implementation and item interaction through its event handlers.
- QGraphicsItem is part of \l{The Graphics View Framework}
+ QGraphicsItem is part of the \l{Graphics View Framework}
\image graphicsview-items.png
@@ -264,7 +264,7 @@
functionality is completely untouched by Qt itself; it is provided for the
user's convenience.
- \sa QGraphicsScene, QGraphicsView, {The Graphics View Framework}
+ \sa QGraphicsScene, QGraphicsView, {Graphics View Framework}
*/
/*!
@@ -7652,9 +7652,10 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent
*/
void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags)
{
- QGraphicsItemPrivate * const d = QGraphicsItem::d_func();
- d->gestureContext.insert(gesture, flags);
- (void)QGestureManager::instance(); // create a gesture manager
+ bool contains = QGraphicsItem::d_ptr->gestureContext.contains(gesture);
+ QGraphicsItem::d_ptr->gestureContext.insert(gesture, flags);
+ if (!contains && QGraphicsItem::d_ptr->scene)
+ QGraphicsItem::d_ptr->scene->d_func()->grabGesture(this, gesture);
}
/*!
@@ -7664,11 +7665,8 @@ void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flag
*/
void QGraphicsObject::ungrabGesture(Qt::GestureType gesture)
{
- QGraphicsItemPrivate * const d = QGraphicsItem::d_func();
- if (d->gestureContext.remove(gesture)) {
- QGestureManager *manager = QGestureManager::instance();
- manager->cleanupCachedGestures(this, gesture);
- }
+ if (QGraphicsItem::d_ptr->gestureContext.remove(gesture) && QGraphicsItem::d_ptr->scene)
+ QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture);
}
/*!
Updates the item's micro focus. This is slot for convenience.
@@ -8007,7 +8005,7 @@ void QGraphicsItemPrivate::resetHeight()
\sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPathItem,
QGraphicsPolygonItem, QGraphicsTextItem, QGraphicsLineItem,
- QGraphicsPixmapItem, {The Graphics View Framework}
+ QGraphicsPixmapItem, {Graphics View Framework}
*/
class QAbstractGraphicsShapeItemPrivate : public QGraphicsItemPrivate
@@ -8146,7 +8144,7 @@ QPainterPath QAbstractGraphicsShapeItem::opaqueArea() const
setBrush() functions.
\sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPolygonItem,
- QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {The Graphics
+ QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics
View Framework}
*/
@@ -8355,7 +8353,7 @@ QVariant QGraphicsPathItem::extension(const QVariant &variant) const
those instead.
\sa QGraphicsPathItem, QGraphicsEllipseItem, QGraphicsPolygonItem,
- QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {The Graphics
+ QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics
View Framework}
*/
@@ -8599,7 +8597,7 @@ QVariant QGraphicsRectItem::extension(const QVariant &variant) const
brush, which you can set by calling setPen() and setBrush().
\sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsPolygonItem,
- QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {The Graphics
+ QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics
View Framework}
*/
@@ -8908,7 +8906,7 @@ QVariant QGraphicsEllipseItem::extension(const QVariant &variant) const
setPen() and setBrush() functions.
\sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,
- QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {The Graphics
+ QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics
View Framework}
*/
@@ -9140,8 +9138,8 @@ QVariant QGraphicsPolygonItem::extension(const QVariant &variant) const
function draws the line using the item's associated pen.
\sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,
- QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem, {The
- Graphics View Framework}
+ QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem,
+ {Graphics View Framework}
*/
class QGraphicsLineItemPrivate : public QGraphicsItemPrivate
@@ -9410,8 +9408,8 @@ QVariant QGraphicsLineItem::extension(const QVariant &variant) const
transformation mode for the item.
\sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,
- QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem, {The
- Graphics View Framework}
+ QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem,
+ {Graphics View Framework}
*/
/*!
@@ -9781,7 +9779,7 @@ QVariant QGraphicsPixmapItem::extension(const QVariant &variant) const
\sa QGraphicsSimpleTextItem, QGraphicsPathItem, QGraphicsRectItem,
QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem,
- QGraphicsLineItem, {The Graphics View Framework}
+ QGraphicsLineItem, {Graphics View Framework}
*/
class QGraphicsTextItemPrivate
@@ -10697,9 +10695,9 @@ void QGraphicsSimpleTextItemPrivate::updateBoundingRect()
\img graphicsview-simpletextitem.png
- \sa QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,
- QGraphicsPixmapItem, QGraphicsPolygonItem, QGraphicsLineItem, {The
- Graphics View Framework}
+ \sa QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem,
+ QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem,
+ QGraphicsLineItem, {Graphics View Framework}
*/
/*!
@@ -10960,7 +10958,7 @@ QVariant QGraphicsSimpleTextItem::extension(const QVariant &variant) const
item group. As with addToGroup(), the item's scene-relative
position and transformation remain intact.
- \sa QGraphicsItem, {The Graphics View Framework}
+ \sa QGraphicsItem, {Graphics View Framework}
*/
class QGraphicsItemGroupPrivate : public QGraphicsItemPrivate
diff --git a/src/gui/graphicsview/qgraphicsitemanimation.cpp b/src/gui/graphicsview/qgraphicsitemanimation.cpp
index 839c4ee..9cb9a8d 100644
--- a/src/gui/graphicsview/qgraphicsitemanimation.cpp
+++ b/src/gui/graphicsview/qgraphicsitemanimation.cpp
@@ -77,7 +77,7 @@
so scheduling several transformations of the same kind (e.g.,
rotations) at the same step is not recommended.
- \sa QTimeLine, {The Graphics View Framework}
+ \sa QTimeLine, {Graphics View Framework}
*/
#include "qgraphicsitemanimation.h"
diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp
index 9f9a39d..5a7f1af 100644
--- a/src/gui/graphicsview/qgraphicslayoutitem.cpp
+++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp
@@ -322,7 +322,7 @@ void QGraphicsLayoutItemPrivate::setSizeComponent(
layout, or false otherwise.
Qt uses QGraphicsLayoutItem to provide layout functionality in the
- \l{The Graphics View Framework}, but in the future its use may spread
+ \l{Graphics View Framework}, but in the future its use may spread
throughout Qt itself.
\sa QGraphicsWidget, QGraphicsLayout, QGraphicsLinearLayout,
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 9b7cf12..4b09a7e 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -50,7 +50,7 @@
The class serves as a container for QGraphicsItems. It is used together
with QGraphicsView for visualizing graphical items, such as lines,
rectangles, text, or even custom items, on a 2D surface. QGraphicsScene is
- part of \l{The Graphics View Framework}.
+ part of the \l{Graphics View Framework}.
QGraphicsScene also provides functionality that lets you efficiently
determine both the location of items, and for determining what items are
@@ -710,6 +710,9 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
cachedTargetItems.removeOne(dummy);
cachedItemGestures.remove(dummy);
cachedAlreadyDeliveredGestures.remove(dummy);
+
+ foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys())
+ ungrabGesture(item, gesture);
}
/*!
@@ -2595,6 +2598,9 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
d->enableTouchEventsOnViews();
}
+ foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys())
+ d->grabGesture(item, gesture);
+
// Update selection lists
if (item->isSelected())
d->selectedItems << item;
@@ -5609,6 +5615,8 @@ bool QGraphicsScene::sendEvent(QGraphicsItem *item, QEvent *event)
void QGraphicsScenePrivate::addView(QGraphicsView *view)
{
views << view;
+ foreach (Qt::GestureType gesture, grabbedGestures.keys())
+ view->viewport()->grabGesture(gesture);
}
void QGraphicsScenePrivate::removeView(QGraphicsView *view)
@@ -6306,6 +6314,27 @@ void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original)
}
}
+void QGraphicsScenePrivate::grabGesture(QGraphicsItem *, Qt::GestureType gesture)
+{
+ (void)QGestureManager::instance(); // create a gesture manager
+ if (!grabbedGestures[gesture]++) {
+ foreach (QGraphicsView *view, views)
+ view->viewport()->grabGesture(gesture);
+ }
+}
+
+void QGraphicsScenePrivate::ungrabGesture(QGraphicsItem *item, Qt::GestureType gesture)
+{
+ // we know this can only be an object
+ Q_ASSERT(item->d_ptr->isObject);
+ QGraphicsObject *obj = static_cast<QGraphicsObject *>(item);
+ QGestureManager::instance()->cleanupCachedGestures(obj, gesture);
+ if (!--grabbedGestures[gesture]) {
+ foreach (QGraphicsView *view, views)
+ view->viewport()->ungrabGesture(gesture);
+ }
+}
+
QT_END_NAMESPACE
#include "moc_qgraphicsscene.cpp"
diff --git a/src/gui/graphicsview/qgraphicsscene.h b/src/gui/graphicsview/qgraphicsscene.h
index e5b15ef..c34a303 100644
--- a/src/gui/graphicsview/qgraphicsscene.h
+++ b/src/gui/graphicsview/qgraphicsscene.h
@@ -302,6 +302,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_updateScenePosDescendants())
friend class QGraphicsItem;
friend class QGraphicsItemPrivate;
+ friend class QGraphicsObject;
friend class QGraphicsView;
friend class QGraphicsViewPrivate;
friend class QGraphicsWidget;
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index 77bf450..8ad2a0a 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -302,6 +302,7 @@ public:
QHash<QGraphicsObject *, QSet<QGesture *> > cachedItemGestures;
QHash<QGraphicsObject *, QSet<QGesture *> > cachedAlreadyDeliveredGestures;
QHash<QGesture *, QGraphicsObject *> gestureTargets;
+ QHash<Qt::GestureType, int> grabbedGestures;
void gestureEventHandler(QGestureEvent *event);
void gestureTargetsAtHotSpots(const QSet<QGesture *> &gestures,
Qt::GestureFlag flag,
@@ -310,6 +311,8 @@ public:
QSet<QGesture *> *normal = 0,
QSet<QGesture *> *conflicts = 0);
void cancelGesturesForChildren(QGesture *original);
+ void grabGesture(QGraphicsItem *, Qt::GestureType gesture);
+ void ungrabGesture(QGraphicsItem *, Qt::GestureType gesture);
void updateInputMethodSensitivityInViews();
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index d2964ca..9dfcd2c 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -2688,6 +2688,11 @@ void QGraphicsView::setupViewport(QWidget *widget)
if (d->scene && !d->scene->d_func()->allItemsIgnoreTouchEvents)
widget->setAttribute(Qt::WA_AcceptTouchEvents);
+ if (d->scene) {
+ foreach (Qt::GestureType gesture, d->scene->d_func()->grabbedGestures.keys())
+ widget->grabGesture(gesture);
+ }
+
widget->setAcceptDrops(acceptDrops());
}