summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>2011-11-08 16:47:10 +0200
committerQt by Nokia <qt-info@nokia.com>2011-11-10 13:07:30 +0100
commitb5c37d9e137dee2754335e83b8437dfd0e6cc7e7 (patch)
treecc55620a6f1c134b0941ded5d57cbd63abb4663b
parent1dbfbf4c66187e7522888c19d78024cfceaea570 (diff)
QTextEdit to use tentative commit instead of QInputPanel::commit()
Latter to be deprecated. Change-Id: I2c302c73a7ab2f4201af6a3c6fb4a64a4760263e Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp29
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p_p.h1
2 files changed, 25 insertions, 5 deletions
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index b6432ee53f..258ab1bb11 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -1537,8 +1537,7 @@ void QWidgetTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton butto
const QTextCursor oldSelection = cursor;
const int oldCursorPos = cursor.position();
- if (isPreediting())
- qApp->inputPanel()->commit();
+ commitPreedit();
if (trippleClickTimer.isActive()
&& ((pos - trippleClickPoint).toPoint().manhattanLength() < QApplication::startDragDistance())) {
@@ -1648,7 +1647,7 @@ void QWidgetTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button
int selectionStartPos = q->hitTest(mousePressPos, Qt::FuzzyHit);
if (newCursorPos != selectionStartPos) {
- qApp->inputPanel()->commit();
+ commitPreedit();
// commit invalidates positions
newCursorPos = q->hitTest(mousePos, Qt::FuzzyHit);
selectionStartPos = q->hitTest(mousePressPos, Qt::FuzzyHit);
@@ -1774,8 +1773,7 @@ void QWidgetTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton
#ifndef QT_NO_DRAGANDDROP
mightStartDrag = false;
#endif
- if (isPreediting())
- qApp->inputPanel()->commit();
+ commitPreedit();
const QTextCursor oldSelection = cursor;
setCursorPosition(pos);
@@ -2752,6 +2750,27 @@ bool QWidgetTextControlPrivate::isPreediting() const
return false;
}
+void QWidgetTextControlPrivate::commitPreedit()
+{
+ if (!isPreediting())
+ return;
+
+ cursor.beginEditBlock();
+ qApp->inputPanel()->reset();
+
+ if (!tentativeCommit.isEmpty()) {
+ cursor.insertText(tentativeCommit);
+ tentativeCommit.clear();
+ }
+
+ preeditCursor = 0;
+ QTextBlock block = cursor.block();
+ QTextLayout *layout = block.layout();
+ layout->setPreeditArea(-1, QString());
+ layout->clearAdditionalFormats();
+ cursor.endEditBlock();
+}
+
bool QWidgetTextControl::setFocusToNextOrPreviousAnchor(bool next)
{
Q_D(QWidgetTextControl);
diff --git a/src/widgets/widgets/qwidgettextcontrol_p_p.h b/src/widgets/widgets/qwidgettextcontrol_p_p.h
index f53e0808b8..cf493aff71 100644
--- a/src/widgets/widgets/qwidgettextcontrol_p_p.h
+++ b/src/widgets/widgets/qwidgettextcontrol_p_p.h
@@ -170,6 +170,7 @@ public:
#endif
bool isPreediting() const;
+ void commitPreedit();
void append(const QString &text, Qt::TextFormat format = Qt::AutoText);