summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>2011-10-05 14:39:57 +0300
committerQt by Nokia <qt-info@nokia.com>2011-10-06 14:37:36 +0200
commit1189ebff320b8dd03637947c92df6e3ef84a3c06 (patch)
tree21999ef560c63874d18f233142503b1deb64a9b0 /src
parentbb1f50b7b11fddec27efc4a436f64147f746f93e (diff)
Make QLineEdit unit test pass again
Widget failed to update cursor position if selection remained the same, but changed direction, and did not emit selectionChanged if change resulted from input method event. Change-Id: I6a4ae48d41efa5e126980749f89982f92e3ec499 Reviewed-on: http://codereview.qt-project.org/6131 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index ded325a121..c04671b710 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -265,13 +265,13 @@ void QWidgetLineControl::setSelection(int start, int length)
}
if (length > 0) {
- if (start == m_selstart && start + length == m_selend)
+ if (start == m_selstart && start + length == m_selend && m_cursor == m_selend)
return;
m_selstart = start;
m_selend = qMin(start + length, (int)m_text.length());
m_cursor = m_selend;
} else if (length < 0){
- if (start == m_selend && start + length == m_selstart)
+ if (start == m_selend && start + length == m_selstart && m_cursor == m_selstart)
return;
m_selstart = qMax(start + length, 0);
m_selend = start;
@@ -434,6 +434,7 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
|| event->preeditString() != preeditAreaText()
|| event->replacementLength() > 0;
bool cursorPositionChanged = false;
+ bool selectionChange = false;
if (isGettingInput) {
// If any text is being input, remove selected text.
@@ -477,6 +478,7 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
if (m_selend < m_selstart) {
qSwap(m_selstart, m_selend);
}
+ selectionChange = true;
} else {
m_selstart = m_selend = 0;
}
@@ -514,6 +516,8 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event)
emit updateMicroFocus();
if (isGettingInput)
finishChange(priorState);
+ if (selectionChange)
+ emit selectionChanged();
}
/*!
@@ -601,7 +605,7 @@ void QWidgetLineControl::selectWordAtPos(int cursor)
bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool edited)
{
Q_UNUSED(update)
- bool lineDirty = m_selDirty;
+
if (m_textDirty) {
// do validation
bool wasValidInput = m_validInput;
@@ -632,7 +636,7 @@ bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool e
m_textDirty = false;
}
updateDisplayText();
- lineDirty |= m_textDirty;
+
if (m_textDirty) {
m_textDirty = false;
QString actualText = text();