summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qgesture.cpp
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-08-21 11:57:18 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-08-21 12:52:16 (GMT)
commitf13908359f08d856c2825988e65651dbf744c0e4 (patch)
tree4841ec567fa09b50f73a5c58565605a22396ebf4 /src/gui/kernel/qgesture.cpp
parentb69bc882acdc445c5ef2334697f7eec9cb73f16d (diff)
downloadQt-f13908359f08d856c2825988e65651dbf744c0e4.zip
Qt-f13908359f08d856c2825988e65651dbf744c0e4.tar.gz
Qt-f13908359f08d856c2825988e65651dbf744c0e4.tar.bz2
Improved a QGesture api a little bit.
Changed the constructor of the QGesture to separate the gesture target (the object/widget that the gesture filters events for), and the parent object. Reviewed-by: Richard Moe Gustavsen
Diffstat (limited to 'src/gui/kernel/qgesture.cpp')
-rw-r--r--src/gui/kernel/qgesture.cpp37
1 files changed, 31 insertions, 6 deletions
diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
index 79dcae1..eeb6528 100644
--- a/src/gui/kernel/qgesture.cpp
+++ b/src/gui/kernel/qgesture.cpp
@@ -149,20 +149,18 @@ private:
\sa setGraphicsItem()
*/
-QGesture::QGesture(QObject *parent)
+QGesture::QGesture(QObject *gestureTarget, QObject *parent)
: QObject(*new QGesturePrivate, parent)
{
- if (parent)
- parent->installEventFilter(this);
+ setGestureTarget(gestureTarget);
}
/*! \internal
*/
-QGesture::QGesture(QGesturePrivate &dd, QObject *parent)
+QGesture::QGesture(QGesturePrivate &dd, QObject *gestureTarget, QObject *parent)
: QObject(dd, parent)
{
- if (parent)
- parent->installEventFilter(this);
+ setGestureTarget(gestureTarget);
}
/*!
@@ -172,6 +170,33 @@ QGesture::~QGesture()
{
}
+/*!
+ \property QGesture::gestureTarget
+
+ Gesture target is the object that the gesture will observe for events.
+ Typically this means that the gesture installs an event filter on the
+ target object.
+*/
+void QGesture::setGestureTarget(QObject *object)
+{
+ d_func()->setupGestureTarget(object);
+}
+
+QObject* QGesture::gestureTarget() const
+{
+ return d_func()->gestureTarget;
+}
+
+void QGesturePrivate::setupGestureTarget(QObject *object)
+{
+ Q_Q(QGesture);
+ if (gestureTarget)
+ gestureTarget->removeEventFilter(q);
+ if (object)
+ object->installEventFilter(q);
+ gestureTarget = object;
+}
+
/*! \internal
*/
bool QGesture::eventFilter(QObject *receiver, QEvent *event)