diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-08-24 02:20:05 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-08-24 02:20:05 (GMT) |
commit | 52d3a7418818e5b6f497a4a7c6efd4b590356c35 (patch) | |
tree | 4bfca5cd744fcd764388d14fc7496bf8f6c2958e /src/gui/text | |
parent | 5bf62d2f11d36b2bfc1b970f2cfff97c87caa770 (diff) | |
parent | 33eb83565466d3dc31ea90dcf18dc3c7b16fd5b6 (diff) | |
download | Qt-52d3a7418818e5b6f497a4a7c6efd4b590356c35.zip Qt-52d3a7418818e5b6f497a4a7c6efd4b590356c35.tar.gz Qt-52d3a7418818e5b6f497a4a7c6efd4b590356c35.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml:
Make it easier to select words at the start of a line.
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qtextcontrol.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 9081ab7..f3d42f8 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -679,20 +679,30 @@ void QTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition, qrea if (!wordSelectionEnabled && (mouseXPosition < wordStartX || mouseXPosition > wordEndX)) return; - // keep the already selected word even when moving to the left - // (#39164) - if (suggestedNewPosition < selectedWordOnDoubleClick.position()) - cursor.setPosition(selectedWordOnDoubleClick.selectionEnd()); - else - cursor.setPosition(selectedWordOnDoubleClick.selectionStart()); + if (wordSelectionEnabled) { + if (suggestedNewPosition < selectedWordOnDoubleClick.position()) { + cursor.setPosition(selectedWordOnDoubleClick.selectionEnd()); + setCursorPosition(wordStartPos, QTextCursor::KeepAnchor); + } else { + cursor.setPosition(selectedWordOnDoubleClick.selectionStart()); + setCursorPosition(wordEndPos, QTextCursor::KeepAnchor); + } + } else { + // keep the already selected word even when moving to the left + // (#39164) + if (suggestedNewPosition < selectedWordOnDoubleClick.position()) + cursor.setPosition(selectedWordOnDoubleClick.selectionEnd()); + else + cursor.setPosition(selectedWordOnDoubleClick.selectionStart()); - const qreal differenceToStart = mouseXPosition - wordStartX; - const qreal differenceToEnd = wordEndX - mouseXPosition; + const qreal differenceToStart = mouseXPosition - wordStartX; + const qreal differenceToEnd = wordEndX - mouseXPosition; - if (differenceToStart < differenceToEnd) - setCursorPosition(wordStartPos, QTextCursor::KeepAnchor); - else - setCursorPosition(wordEndPos, QTextCursor::KeepAnchor); + if (differenceToStart < differenceToEnd) + setCursorPosition(wordStartPos, QTextCursor::KeepAnchor); + else + setCursorPosition(wordEndPos, QTextCursor::KeepAnchor); + } if (interactionFlags & Qt::TextSelectableByMouse) { #ifndef QT_NO_CLIPBOARD |