summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-08-03 15:02:58 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-08-04 14:22:46 (GMT)
commit6b85ec8790aad8ac01c04f7e7bd4913d8cd8d104 (patch)
treeb45584416ababa562478ca35a7f2ef2c63936942 /src/gui/kernel
parent6e7a6478279a94a82af46e6814f113244aca46dd (diff)
downloadQt-6b85ec8790aad8ac01c04f7e7bd4913d8cd8d104.zip
Qt-6b85ec8790aad8ac01c04f7e7bd4913d8cd8d104.tar.gz
Qt-6b85ec8790aad8ac01c04f7e7bd4913d8cd8d104.tar.bz2
Removed the QTapAndHoldGesture
Moved the gesture implementation to the imageviewer example as it cannot be fully implemented in a crossplatform way - for example on Windows tap and hold is a system gesture that is transparent to the application. Reviewed-by: trustme
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qstandardgestures.cpp101
-rw-r--r--src/gui/kernel/qstandardgestures.h16
-rw-r--r--src/gui/kernel/qstandardgestures_p.h14
3 files changed, 16 insertions, 115 deletions
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index 1fbfe15..e4b9abb 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -295,106 +295,37 @@ QSize QPanGesture::lastOffset() const
#endif
}
+/*!
+ \property QPanGesture::startPos
+
+ \brief The start position of the gesture.
+*/
QPoint QPanGesture::startPos() const
{
Q_D(const QPanGesture);
return d->startPos;
}
+
+/*!
+ \property QPanGesture::lastPos
+
+ \brief The last recorded position of the gesture.
+*/
QPoint QPanGesture::lastPos() const
{
Q_D(const QPanGesture);
return d->lastPos;
}
-QPoint QPanGesture::pos() const
-{
- Q_D(const QPanGesture);
- return d->pos;
-}
-
/*!
- \class QTapAndHoldGesture
- \since 4.6
-
- \brief The QTapAndHoldGesture class represents a Tap-and-Hold gesture,
- providing additional information.
-*/
-
-const int QTapAndHoldGesturePrivate::iterationCount = 40;
-const int QTapAndHoldGesturePrivate::iterationTimeout = 50;
-
-/*!
- Creates a new Tap and Hold gesture handler object and marks it as a child
- of \a parent.
+ \property QPanGesture::pos
- On some platforms like Windows there is a system-wide tap and hold gesture
- that cannot be overriden, hence the gesture might never trigger and default
- context menu will be shown instead.
+ \brief The current position of the gesture.
*/
-QTapAndHoldGesture::QTapAndHoldGesture(QWidget *parent)
- : QGesture(*new QTapAndHoldGesturePrivate, parent)
-{
-}
-
-/*! \internal */
-bool QTapAndHoldGesture::filterEvent(QEvent *event)
-{
- Q_D(QTapAndHoldGesture);
- if (!event->spontaneous())
- return false;
- const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
- switch (event->type()) {
- case QEvent::TouchBegin: {
- if (d->timer.isActive())
- d->timer.stop();
- d->timer.start(QTapAndHoldGesturePrivate::iterationTimeout, this);
- const QPoint p = ev->touchPoints().at(0).pos().toPoint();
- setStartPos(p);
- setLastPos(p);
- setPos(p);
- break;
- }
- case QEvent::TouchUpdate:
- if (ev->touchPoints().size() != 1)
- reset();
- else if ((startPos() - ev->touchPoints().at(0).pos().toPoint()).manhattanLength() > 15)
- reset();
- break;
- case QEvent::TouchEnd:
- reset();
- break;
- default:
- break;
- }
- return false;
-}
-
-/*! \internal */
-void QTapAndHoldGesture::timerEvent(QTimerEvent *event)
-{
- Q_D(QTapAndHoldGesture);
- if (event->timerId() != d->timer.timerId())
- return;
- if (d->iteration == QTapAndHoldGesturePrivate::iterationCount) {
- d->timer.stop();
- setState(Qt::GestureFinished);
- emit triggered();
- } else {
- setState(Qt::GestureStarted);
- emit triggered();
- }
- ++d->iteration;
-}
-
-/*! \internal */
-void QTapAndHoldGesture::reset()
+QPoint QPanGesture::pos() const
{
- Q_D(QTapAndHoldGesture);
- if (state() != Qt::NoGesture)
- emit cancelled();
- setState(Qt::NoGesture);
- d->timer.stop();
- d->iteration = 0;
+ Q_D(const QPanGesture);
+ return d->pos;
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qstandardgestures.h b/src/gui/kernel/qstandardgestures.h
index 030aac8..c6f6d9b 100644
--- a/src/gui/kernel/qstandardgestures.h
+++ b/src/gui/kernel/qstandardgestures.h
@@ -81,22 +81,6 @@ private:
friend class QWidget;
};
-class QTapAndHoldGesturePrivate;
-class Q_GUI_EXPORT QTapAndHoldGesture : public QGesture
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QTapAndHoldGesture)
-
-public:
- QTapAndHoldGesture(QWidget *parent);
-
- bool filterEvent(QEvent *event);
- void reset();
-
-protected:
- void timerEvent(QTimerEvent *event);
-};
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/kernel/qstandardgestures_p.h b/src/gui/kernel/qstandardgestures_p.h
index dd4fbc0..0fe24ee 100644
--- a/src/gui/kernel/qstandardgestures_p.h
+++ b/src/gui/kernel/qstandardgestures_p.h
@@ -85,20 +85,6 @@ public:
#endif
};
-class QTapAndHoldGesturePrivate : public QGesturePrivate
-{
- Q_DECLARE_PUBLIC(QTapAndHoldGesture)
-
-public:
- QTapAndHoldGesturePrivate()
- : iteration(0) { }
-
- QBasicTimer timer;
- int iteration;
- static const int iterationCount;
- static const int iterationTimeout;
-};
-
QT_END_NAMESPACE
#endif // QSTANDARDGESTURES_P_H