summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-03-20 14:24:50 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-05-11 14:51:42 (GMT)
commitd4e64228ef8154a1f69f91cfd6a78f29d89718e1 (patch)
tree2bdd1b95bc008674008f1a7b8f6c03ef14c7736b
parent0fde21aa44289f367f11e79500310a54db1787bb (diff)
downloadQt-d4e64228ef8154a1f69f91cfd6a78f29d89718e1.zip
Qt-d4e64228ef8154a1f69f91cfd6a78f29d89718e1.tar.gz
Qt-d4e64228ef8154a1f69f91cfd6a78f29d89718e1.tar.bz2
Gesture manager takes ownership of the provided gesture recognizers.
-rw-r--r--src/gui/kernel/qapplication.cpp2
-rw-r--r--src/gui/kernel/qgesturemanager.cpp7
-rw-r--r--src/gui/kernel/qgesturerecognizer.cpp6
-rw-r--r--src/gui/kernel/qgesturerecognizer.h2
-rw-r--r--src/gui/kernel/qgesturestandardrecognizers.cpp12
-rw-r--r--src/gui/kernel/qgesturestandardrecognizers_p.h6
6 files changed, 19 insertions, 16 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index d9a39c7..b042597 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -5091,6 +5091,8 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy)
/*!
Adds custom gesture \a recognizer object.
+ Qt takes ownership of the provided \a recognizer.
+
\sa Qt::AA_EnableGestures, QGestureEvent
*/
void QApplication::addGestureRecognizer(QGestureRecognizer *recognizer)
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp
index 173b1a0..3e3f976 100644
--- a/src/gui/kernel/qgesturemanager.cpp
+++ b/src/gui/kernel/qgesturemanager.cpp
@@ -70,9 +70,9 @@ QGestureManager::QGestureManager(QObject *parent)
qRegisterMetaType<Qt::DirectionType>();
qRegisterMetaType<Qt::GestureState>();
- recognizers << new QDoubleTapGestureRecognizer();
- recognizers << new QTapAndHoldGestureRecognizer();
- recognizers << new QGestureRecognizerPan();
+ recognizers << new QDoubleTapGestureRecognizer(this);
+ recognizers << new QTapAndHoldGestureRecognizer(this);
+ recognizers << new QGestureRecognizerPan(this);
foreach(QGestureRecognizer *r, recognizers)
connect(r, SIGNAL(stateChanged(QGestureRecognizer::Result)),
@@ -81,6 +81,7 @@ QGestureManager::QGestureManager(QObject *parent)
void QGestureManager::addRecognizer(QGestureRecognizer *recognizer)
{
+ recognizer->setParent(this);
recognizers << recognizer;
}
diff --git a/src/gui/kernel/qgesturerecognizer.cpp b/src/gui/kernel/qgesturerecognizer.cpp
index 7791ad7..278389a 100644
--- a/src/gui/kernel/qgesturerecognizer.cpp
+++ b/src/gui/kernel/qgesturerecognizer.cpp
@@ -125,13 +125,13 @@ QGestureRecognizerPrivate::QGestureRecognizerPrivate()
/*!
Creates a new gesture recognizer object that handles gestures of
- the specific \a type.
+ the specific \a type as a child of \a parent.
\sa QApplication::addGestureRecognizer(),
QApplication::removeGestureRecognizer(),
*/
-QGestureRecognizer::QGestureRecognizer(const QString &type)
- : QObject(*new QGestureRecognizerPrivate, 0)
+QGestureRecognizer::QGestureRecognizer(const QString &type, QObject *parent)
+ : QObject(*new QGestureRecognizerPrivate, parent)
{
d_func()->customGestureType = type;
}
diff --git a/src/gui/kernel/qgesturerecognizer.h b/src/gui/kernel/qgesturerecognizer.h
index 9ffdb0d..9e51e7e 100644
--- a/src/gui/kernel/qgesturerecognizer.h
+++ b/src/gui/kernel/qgesturerecognizer.h
@@ -64,7 +64,7 @@ public:
MaybeGesture
};
- explicit QGestureRecognizer(const QString &type);
+ explicit QGestureRecognizer(const QString &type, QObject *parent = 0);
QString gestureType() const;
diff --git a/src/gui/kernel/qgesturestandardrecognizers.cpp b/src/gui/kernel/qgesturestandardrecognizers.cpp
index 0fa5201..cb448c5 100644
--- a/src/gui/kernel/qgesturestandardrecognizers.cpp
+++ b/src/gui/kernel/qgesturestandardrecognizers.cpp
@@ -78,8 +78,8 @@ QString qt_getStandardGestureTypeName(Qt::GestureType gestureType)
// QGestureRecognizerPan
//
-QGestureRecognizerPan::QGestureRecognizerPan()
- : QGestureRecognizer(QString()),
+QGestureRecognizerPan::QGestureRecognizerPan(QObject *parent)
+ : QGestureRecognizer(QString(), parent),
mousePressed(false), gestureFinished(false),
lastDirection(Qt::NoDirection), currentDirection(Qt::NoDirection)
{
@@ -177,8 +177,8 @@ void QGestureRecognizerPan::internalReset()
//
// QDoubleTapGestureRecognizer
//
-QDoubleTapGestureRecognizer::QDoubleTapGestureRecognizer()
- : QGestureRecognizer(QString()),
+QDoubleTapGestureRecognizer::QDoubleTapGestureRecognizer(QObject *parent)
+ : QGestureRecognizer(QString(), parent),
gesture(0, qt_getStandardGestureTypeName(Qt::DoubleTapGesture))
{
Q_D(QGestureRecognizer);
@@ -229,8 +229,8 @@ void QDoubleTapGestureRecognizer::reset()
const int QTapAndHoldGestureRecognizer::iterationCount = 40;
const int QTapAndHoldGestureRecognizer::iterationTimeout = 50;
-QTapAndHoldGestureRecognizer::QTapAndHoldGestureRecognizer()
- : QGestureRecognizer(QString()), iteration(0),
+QTapAndHoldGestureRecognizer::QTapAndHoldGestureRecognizer(QObject *parent)
+ : QGestureRecognizer(QString(), parent), iteration(0),
gesture(0, qt_getStandardGestureTypeName(Qt::TapAndHoldGesture))
{
Q_D(QGestureRecognizer);
diff --git a/src/gui/kernel/qgesturestandardrecognizers_p.h b/src/gui/kernel/qgesturestandardrecognizers_p.h
index 5163bd6..a7a631c 100644
--- a/src/gui/kernel/qgesturestandardrecognizers_p.h
+++ b/src/gui/kernel/qgesturestandardrecognizers_p.h
@@ -66,7 +66,7 @@ class QGestureRecognizerPan : public QGestureRecognizer
{
Q_OBJECT
public:
- QGestureRecognizerPan();
+ QGestureRecognizerPan(QObject *parent);
QGestureRecognizer::Result filterEvent(const QEvent *event);
QGesture* getGesture();
@@ -92,7 +92,7 @@ class QDoubleTapGestureRecognizer : public QGestureRecognizer
{
Q_OBJECT
public:
- QDoubleTapGestureRecognizer();
+ QDoubleTapGestureRecognizer(QObject *parent);
QGestureRecognizer::Result filterEvent(const QEvent *event);
QGesture* getGesture();
@@ -107,7 +107,7 @@ class QTapAndHoldGestureRecognizer : public QGestureRecognizer
{
Q_OBJECT
public:
- QTapAndHoldGestureRecognizer();
+ QTapAndHoldGestureRecognizer(QObject *parent);
QGestureRecognizer::Result filterEvent(const QEvent *event);
QGesture* getGesture();