summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsitem.cpp
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-05-18 13:32:39 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-05-18 13:32:39 (GMT)
commit6cc1e0106845a0dfe9433c4413b3c064c73ccfe2 (patch)
treea0372fb3e03000dc1e1f93a4154adecd70fd5119 /src/gui/graphicsview/qgraphicsitem.cpp
parent86edc526684d80e405bcd1c63b5a314b70408679 (diff)
parent537243d70de1474cf234880b215c75e83e80abcd (diff)
downloadQt-6cc1e0106845a0dfe9433c4413b3c064c73ccfe2.zip
Qt-6cc1e0106845a0dfe9433c4413b3c064c73ccfe2.tar.gz
Qt-6cc1e0106845a0dfe9433c4413b3c064c73ccfe2.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-multitouch
Diffstat (limited to 'src/gui/graphicsview/qgraphicsitem.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp44
1 files changed, 37 insertions, 7 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 747d510..ae33674 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -5857,6 +5857,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));
}
@@ -5872,12 +5873,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
@@ -5888,10 +5907,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);
}
/*!
@@ -5909,6 +5927,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