diff options
Diffstat (limited to 'src/gui/graphicsview/qgraphicsitem.cpp')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index e2b8115..d9f450a 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -5802,6 +5802,7 @@ QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const */ 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)); } @@ -5817,12 +5818,30 @@ int QGraphicsItem::grabGesture(Qt::GestureType gesture) int QGraphicsItem::grabGesture(const QString &gesture) { int id = QGestureManager::instance()->makeGestureId(gesture); - d_ptr->gestures << id; - if (d_ptr->scene) - d_ptr->scene->d_func()->grabGesture(this, id); + d_ptr->grabGesture(id); return id; } +void QGraphicsItemPrivate::grabGesture(int id) +{ + Q_Q(QGraphicsItem); + gestures << id; + if (scene) + scene->d_func()->grabGesture(q, id); +} + +bool QGraphicsItemPrivate::releaseGesture(int id) +{ + Q_Q(QGraphicsItem); + if (gestures.contains(id)) { + if (scene) + scene->d_func()->releaseGesture(q, id); + gestures.remove(id); + return true; + } + return false; +} + /*! \since 4.6 @@ -5833,10 +5852,9 @@ int QGraphicsItem::grabGesture(const QString &gesture) */ void QGraphicsItem::releaseGesture(int gestureId) { - if (d_ptr->scene) - d_ptr->scene->d_func()->releaseGesture(this, gestureId); - QGestureManager::instance()->releaseGestureId(gestureId); - d_ptr->gestures.remove(gestureId); + /// TODO: if we are QGraphicsProxyWidget we should unsubscribe the widget from gesture as well. + if (d_ptr->releaseGesture(gestureId)) + QGestureManager::instance()->releaseGestureId(gestureId); } /*! @@ -5854,6 +5872,18 @@ void QGraphicsItem::setGestureEnabled(int gestureId, bool enable) //### } +bool QGraphicsItemPrivate::hasGesture(const QString &name) const +{ + QGestureManager *gm = QGestureManager::instance(); + QSet<int>::const_iterator it = gestures.begin(), + e = 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 |