From ba62482f69385ba929384e0402135891c77eddcb Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 12 Aug 2009 09:44:51 +0200 Subject: Revert "Changed the behavior of ImCursorPosition slightly." This reverts commit ce02d0e9e0ad8d8ac47e4f3ee95bac5cb74ed184. This turned out not to be enough for proper selection support together with S60 FEP. Instead we will revert the behavior and add new API. (cherry picked from commit 6545932efa45ea2b8fbc1459d760ec5f15c63120) Conflicts: doc/src/qnamespace.qdoc src/gui/widgets/qlineedit.cpp --- src/gui/widgets/qlineedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 5b04616..cd9666d 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1657,7 +1657,7 @@ QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const case Qt::ImFont: return font(); case Qt::ImCursorPosition: - return QVariant(d->control->hasSelectedText() ? d->control->selectionEnd() : d->control->cursor()); + return QVariant(d->control->cursor()); case Qt::ImSurroundingText: return QVariant(text()); case Qt::ImCurrentSelection: -- cgit v0.12 From 9e03643608527e9ea567b186c7b9209a52908d27 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 12 Aug 2009 09:59:17 +0200 Subject: Redid patch that was lost during merge with 4.6. See commit 203b2b2c611e2 for details. --- src/gui/widgets/qlineedit_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h index b21820c..f1263c6 100644 --- a/src/gui/widgets/qlineedit_p.h +++ b/src/gui/widgets/qlineedit_p.h @@ -101,7 +101,7 @@ public: inline bool shouldEnableInputMethod() const { - return !control->isReadOnly() && (control->echoMode() == QLineEdit::Normal || control->echoMode() == QLineEdit::PasswordEchoOnEdit); + return !control->isReadOnly(); } QPoint tripleClick; -- cgit v0.12 From 4d1c7a4f2f8f451d13d9a5bffc4c44c3221c3ca1 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 12 Aug 2009 10:09:50 +0200 Subject: Redid 7b95b70bc307 for QLineControl. --- src/gui/widgets/qlinecontrol.cpp | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index f4a2348..80215e1 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -400,8 +400,17 @@ void QLineControl::moveCursor(int pos, bool mark) */ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) { - int priorState = m_undoState; - removeSelectedText(); + int priorState = 0; + bool isGettingInput = !event->commitString().isEmpty() || !event->preeditString().isEmpty() + || event->replacementLength() > 0; + bool cursorPositionChanged = false; + + if (isGettingInput) { + // If any text is being input, remove selected text. + priorState = m_undoState; + removeSelectedText(); + } + int c = m_cursor; // cursor position after insertion of commit string if (event->replacementStart() <= 0) @@ -415,11 +424,30 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) m_selend = m_selstart + event->replacementLength(); removeSelectedText(); } - if (!event->commitString().isEmpty()) + if (!event->commitString().isEmpty()) { insert(event->commitString()); + cursorPositionChanged = true; + } m_cursor = qMin(c, m_text.length()); + for (int i = 0; i < event->attributes().size(); ++i) { + const QInputMethodEvent::Attribute &a = event->attributes().at(i); + if (a.type == QInputMethodEvent::Selection) { + m_cursor = qBound(0, a.start + a.length, m_text.length()); + if (a.length) { + m_selstart = qMax(0, qMin(a.start, m_text.length())); + m_selend = m_cursor; + if (m_selend < m_selstart) { + qSwap(m_selstart, m_selend); + } + } else { + m_selstart = m_selend = 0; + } + cursorPositionChanged = true; + } + } + setPreeditArea(m_cursor, event->preeditString()); m_preeditCursor = event->preeditString().length(); m_hideCursor = false; @@ -442,9 +470,10 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) } m_textLayout.setAdditionalFormats(formats); updateDisplayText(); - if (!event->commitString().isEmpty()) + if (cursorPositionChanged) emitCursorPositionChanged(); - finishChange(priorState); + if (isGettingInput) + finishChange(priorState); } /*! -- cgit v0.12 From 8cfcc81c9ff784d61eccdef53a3ce7ef125526f8 Mon Sep 17 00:00:00 2001 From: axis Date: Wed, 12 Aug 2009 10:57:22 +0200 Subject: Fixed warning. --- src/gui/widgets/qlineedit_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h index f1263c6..2c0d08f 100644 --- a/src/gui/widgets/qlineedit_p.h +++ b/src/gui/widgets/qlineedit_p.h @@ -76,7 +76,7 @@ public: QLineEditPrivate() : control(0), frame(1), contextMenuEnabled(1), cursorVisible(0), - dragEnabled(0), hscroll(0), vscroll(0), clickCausedFocus(0), + dragEnabled(0), clickCausedFocus(0), hscroll(0), vscroll(0), alignment(Qt::AlignLeading | Qt::AlignVCenter), leftTextMargin(0), topTextMargin(0), rightTextMargin(0), bottomTextMargin(0) { -- cgit v0.12