summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>2011-11-15 18:05:27 +0200
committerQt by Nokia <qt-info@nokia.com>2011-11-21 22:45:41 +0100
commitbd8188ebd4a4d8819a5d3bf85f01ce69d41f4f1e (patch)
tree65c16711913c2bea455150f8c65db28008ab4a40 /src/gui
parent7a0c0602685ddf0c5f15a8f3bd6ae8336cf9c858 (diff)
Support better committing preedit in QLineController
Similar as 7851568c65e0560056c6fa541039543d43a63e20 for QWidgetLineController Change-Id: I7c1a1dc22e9b73515a5a72093866ac747a80896f Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qlinecontrol.cpp28
-rw-r--r--src/gui/text/qlinecontrol_p.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/src/gui/text/qlinecontrol.cpp b/src/gui/text/qlinecontrol.cpp
index 91a07d926e..62f4515fcc 100644
--- a/src/gui/text/qlinecontrol.cpp
+++ b/src/gui/text/qlinecontrol.cpp
@@ -151,6 +151,30 @@ void QLineControl::paste(QClipboard::Mode clipboardMode)
/*!
\internal
+ Exits preedit mode and commits parts marked as tentative commit
+*/
+void QLineControl::commitPreedit()
+{
+ if (!composeMode())
+ return;
+
+ qApp->inputPanel()->reset();
+
+ if (!m_tentativeCommit.isEmpty()) {
+ internalInsert(m_tentativeCommit);
+ m_tentativeCommit.clear();
+ finishChange(-1, true/*not used, not documented*/, false);
+ }
+
+ m_preeditCursor = 0;
+ setPreeditArea(-1, QString());
+ m_textLayout.clearAdditionalFormats();
+ updateDisplayText(/*force*/ true);
+}
+
+/*!
+ \internal
+
Handles the behavior for the backspace key or function.
Removes the current selection if there is a selection, otherwise
removes the character prior to the cursor position.
@@ -243,6 +267,8 @@ void QLineControl::clear()
*/
void QLineControl::setSelection(int start, int length)
{
+ commitPreedit();
+
if(start < 0 || start > (int)m_text.length()){
qWarning("QLineControl::setSelection: Invalid start position");
return;
@@ -403,6 +429,8 @@ bool QLineControl::fixup() // this function assumes that validate currently retu
*/
void QLineControl::moveCursor(int pos, bool mark)
{
+ commitPreedit();
+
if (pos != m_cursor) {
separate();
if (m_maskData)
diff --git a/src/gui/text/qlinecontrol_p.h b/src/gui/text/qlinecontrol_p.h
index 7f5244ee07..4970a8c05e 100644
--- a/src/gui/text/qlinecontrol_p.h
+++ b/src/gui/text/qlinecontrol_p.h
@@ -209,6 +209,7 @@ public:
QString text() const;
QString realText() const;
void setText(const QString &txt);
+ void commitPreedit();
QString displayText() const { return m_textLayout.text(); }