Revert "Use single finger pan to scroll text edits on touch screens."

This reverts commit 2ffa46054d.

It completely broke text selection in text edits on iOS, and wasn't
even tested on that platform before landing. It's also changing
behavior in a patch release for multiple platforms, from being
able to both scroll and select text, to only being able to scroll,
which would be considered a feature-regression and an automatic
-2 on the original patch.

This means QTBUG-40461, a P2 regression from Qt 4 on Windows, will
have to be re-opened, so that we can fix it properly.

Task-number: QTBUG-43101
Change-Id: I26a2bafb4500b1ff4dc3fb942f197d11038b630b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
Tor Arne Vestbø 2014-12-03 15:33:10 +01:00 committed by Tor Arne Vestbø
parent 20d10d90f2
commit fd29be6a6b

View File

@ -38,7 +38,6 @@
#include "qwidget.h"
#include "qabstractscrollarea.h"
#include <qgraphicssceneevent.h>
#include <QtGui/QTouchDevice>
#include "qdebug.h"
#ifndef QT_NO_GESTURES
@ -68,26 +67,8 @@ static QPointF panOffset(const QList<QTouchEvent::TouchPoint> &touchPoints, int
return result / qreal(count);
}
// ### fixme: Remove this
// Use single finger pan to scroll QPlainTextEdit/QTextEdit
// by changing the number of pan points to 1 for these classes.
// This used to be Qt 4's behavior on Windows which was achieved using native
// Windows gesture recognizers for these classes.
// The other classes inheriting QScrollArea still use standard 2 finger pan.
// In the long run, they should also use single finger pan to
// scroll on touch screens, however, this requires a distinct Tap&Hold-followed-by-pan
// type gesture to avoid clashes with item view selection and DnD.
static inline int panTouchPoints(const QTouchEvent *event, const QObject *object,
int defaultTouchPoints)
{
return event->device()->type() == QTouchDevice::TouchScreen && object && object->parent()
&& (object->parent()->inherits("QPlainTextEdit") || object->parent()->inherits("QTextEdit"))
? 1 : defaultTouchPoints;
}
QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state,
QObject *object,
QObject *,
QEvent *event)
{
QPanGesture *q = static_cast<QPanGesture *>(state);
@ -100,7 +81,7 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state,
result = QGestureRecognizer::MayBeGesture;
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
d->lastOffset = d->offset = QPointF();
d->pointCount = panTouchPoints(ev, object, m_pointCount);
d->pointCount = m_pointCount;
break;
}
case QEvent::TouchEnd: {