diff options
author | axis <qt-info@nokia.com> | 2009-06-03 11:17:16 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-06-03 11:17:16 (GMT) |
commit | 3d05a836cb0bc62e6dc31d297bada07ec60adc34 (patch) | |
tree | 21f3dc65344c2e094708615cbd430166f021ad65 /src/gui/widgets | |
parent | 612ebdbf04161b4768fc7a2800fbf0c7b73dd424 (diff) | |
parent | 3592724b1f7e635904c31ba09a61d6b7259c93e5 (diff) | |
download | Qt-3d05a836cb0bc62e6dc31d297bada07ec60adc34.zip Qt-3d05a836cb0bc62e6dc31d297bada07ec60adc34.tar.gz Qt-3d05a836cb0bc62e6dc31d297bada07ec60adc34.tar.bz2 |
Merge branch 'imSelections'
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qlineedit.cpp | 48 | ||||
-rw-r--r-- | src/gui/widgets/qmenu_symbian.cpp | 32 |
2 files changed, 73 insertions, 7 deletions
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 0d8e16f..d9e39d3 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -2274,8 +2274,15 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e) } #endif - int priorState = d->undoState; - d->removeSelectedText(); + int priorState = 0; + bool isGettingInput = !e->commitString().isEmpty() || !e->preeditString().isEmpty(); + bool cursorPositionChanged = false; + + if (isGettingInput) { + // If any text is being input, remove selected text. + priorState = d->undoState; + d->removeSelectedText(); + } int c = d->cursor; // cursor position after insertion of commit string if (e->replacementStart() <= 0) @@ -2289,11 +2296,30 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e) d->selend = d->selstart + e->replacementLength(); d->removeSelectedText(); } - if (!e->commitString().isEmpty()) + if (!e->commitString().isEmpty()) { d->insert(e->commitString()); + cursorPositionChanged = true; + } d->cursor = qMin(c, d->text.length()); + for (int i = 0; i < e->attributes().size(); ++i) { + const QInputMethodEvent::Attribute &a = e->attributes().at(i); + if (a.type == QInputMethodEvent::Selection) { + d->cursor = qBound(0, a.start + a.length, d->text.length()); + if (a.length) { + d->selstart = qMax(0, qMin(a.start, d->text.length())); + d->selend = d->cursor; + if (d->selend < d->selstart) { + qSwap(d->selstart, d->selend); + } + } else { + d->selstart = d->selend = 0; + } + cursorPositionChanged = true; + } + } + d->textLayout.setPreeditArea(d->cursor, e->preeditString()); d->preeditCursor = e->preeditString().length(); d->hideCursor = false; @@ -2317,9 +2343,12 @@ void QLineEdit::inputMethodEvent(QInputMethodEvent *e) d->textLayout.setAdditionalFormats(formats); d->updateTextLayout(); update(); - if (!e->commitString().isEmpty()) + if (cursorPositionChanged) d->emitCursorPositionChanged(); - d->finishChange(priorState); + + if (isGettingInput) + d->finishChange(priorState); + #ifndef QT_NO_COMPLETER if (!e->commitString().isEmpty()) d->complete(Qt::Key_unknown); @@ -2337,13 +2366,20 @@ QVariant QLineEdit::inputMethodQuery(Qt::InputMethodQuery property) const case Qt::ImFont: return font(); case Qt::ImCursorPosition: - return QVariant((d->selend - d->selstart == 0) ? d->cursor : d->selend); + return QVariant(d->cursor); case Qt::ImSurroundingText: return QVariant(d->text); case Qt::ImCurrentSelection: return QVariant(selectedText()); case Qt::ImMaximumTextLength: return QVariant(maxLength()); + case Qt::ImAnchorPosition: + if (d->selstart == d->selend) + return QVariant(d->cursor); + else if (d->selstart == d->cursor) + return QVariant(d->selend); + else + return QVariant(d->selstart); default: return QVariant(); } diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index f181924..48c2cf6 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -4,7 +4,37 @@ ** Contact: Qt Software Information (qt-info@nokia.com) ** ** -** $TROLLTECH_DUAL_EMBEDDED_LICENSE$ +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ ** ****************************************************************************/ |