summaryrefslogtreecommitdiff
path: root/src/gui/widgets/qplaintextedit.cpp
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@nokia.com>2009-11-04 14:02:41 +0100
committerMorten Johan Sørvig <morten.sorvig@nokia.com>2009-11-04 14:02:41 +0100
commit94b595f37b3a49d44d1a795e5f2b003ac921d4b7 (patch)
tree74009d7bd395e7bd39076875914c5f1353a30902 /src/gui/widgets/qplaintextedit.cpp
parent3c3db55c205012de15bab758b3bb4857d132cb98 (diff)
parent51c9b68425c1d3fe64a08e6ef0357fbd6bdd8f8a (diff)
downloadqt4-tools-94b595f37b3a49d44d1a795e5f2b003ac921d4b7.tar.gz
Merge commit '51c9b68' into 4.6
Conflicts: dist/changes-4.6.0 src/gui/kernel/qevent.h
Diffstat (limited to 'src/gui/widgets/qplaintextedit.cpp')
-rw-r--r--src/gui/widgets/qplaintextedit.cpp53
1 files changed, 26 insertions, 27 deletions
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index bb93546a21..0de7421f16 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -730,9 +730,6 @@ QPlainTextEditPrivate::QPlainTextEditPrivate()
backgroundVisible = false;
centerOnScroll = false;
inDrag = false;
-#ifdef Q_WS_WIN
- singleFingerPanEnabled = true;
-#endif
}
@@ -789,6 +786,9 @@ void QPlainTextEditPrivate::init(const QString &txt)
viewport->setCursor(Qt::IBeamCursor);
#endif
originalOffsetY = 0;
+#ifdef Q_WS_WIN
+ setSingleFingerPanEnabled(true);
+#endif
}
void QPlainTextEditPrivate::_q_repaintContents(const QRectF &contentsRect)
@@ -1450,6 +1450,29 @@ bool QPlainTextEdit::event(QEvent *e)
d->sendControlEvent(e);
}
#endif
+ else if (e->type() == QEvent::Gesture) {
+ QGestureEvent *ge = static_cast<QGestureEvent *>(e);
+ QPanGesture *g = static_cast<QPanGesture *>(ge->gesture(Qt::PanGesture));
+ if (g) {
+ QScrollBar *hBar = horizontalScrollBar();
+ QScrollBar *vBar = verticalScrollBar();
+ if (g->state() == Qt::GestureStarted)
+ d->originalOffsetY = vBar->value();
+ QPointF offset = g->offset();
+ if (!offset.isNull()) {
+ if (QApplication::isRightToLeft())
+ offset.rx() *= -1;
+ // QPlainTextEdit scrolls by lines only in vertical direction
+ QFontMetrics fm(document()->defaultFont());
+ int lineHeight = fm.height();
+ int newX = hBar->value() - g->lastOffset().x();
+ int newY = d->originalOffsetY - offset.y()/lineHeight;
+ hBar->setValue(newX);
+ vBar->setValue(newY);
+ }
+ }
+ return true;
+ }
return QAbstractScrollArea::event(e);
}
@@ -2929,30 +2952,6 @@ QAbstractTextDocumentLayout::PaintContext QPlainTextEdit::getPaintContext() cons
(\a available is true) or unavailable (\a available is false).
*/
-//void QPlainTextEditPrivate::_q_gestureTriggered()
-//{
-// Q_Q(QPlainTextEdit);
-// QPanGesture *g = qobject_cast<QPanGesture*>(q->sender());
-// if (!g)
-// return;
-// QScrollBar *hBar = q->horizontalScrollBar();
-// QScrollBar *vBar = q->verticalScrollBar();
-// if (g->state() == Qt::GestureStarted)
-// originalOffsetY = vBar->value();
-// QSizeF totalOffset = g->totalOffset();
-// if (!totalOffset.isNull()) {
-// if (QApplication::isRightToLeft())
-// totalOffset.rwidth() *= -1;
-// // QPlainTextEdit scrolls by lines only in vertical direction
-// QFontMetrics fm(q->document()->defaultFont());
-// int lineHeight = fm.height();
-// int newX = hBar->value() - g->lastOffset().width();
-// int newY = originalOffsetY - totalOffset.height()/lineHeight;
-// hbar->setValue(newX);
-// vbar->setValue(newY);
-// }
-//}
-
QT_END_NAMESPACE
#include "moc_qplaintextedit.cpp"