summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextcontrol.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-02-04 11:52:40 +0100
committerOlivier Goffart <olivier.goffart@nokia.com>2011-02-04 11:52:40 +0100
commitac60946777c55cf19ee0fc5ae1f60d3c75146e6f (patch)
tree8c8a271c71e360d567a6a95278de1c903c1b6592 /src/gui/text/qtextcontrol.cpp
parentf67f6bc8bcb2092da77905aa67942f59cd49470b (diff)
parentbc331aca61a2f212a347708c9d44a4fb092183fd (diff)
Merge remote-tracking branch 'origin/4.7' into qt-master-from-4.7
Conflicts: demos/declarative/samegame/SamegameCore/samegame.js mkspecs/features/symbian/default_post.prf src/declarative/qml/qdeclarativeengine.cpp src/gui/text/qtextdocumentlayout.cpp src/plugins/plugins.pro src/s60installs/bwins/QtCoreu.def src/s60installs/bwins/QtGuiu.def src/s60installs/eabi/QtCoreu.def src/s60installs/eabi/QtGuiu.def src/s60installs/s60installs.pro tests/auto/declarative/declarative.pro tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp tests/auto/declarative/qmlvisual/qmlvisual.pro
Diffstat (limited to 'src/gui/text/qtextcontrol.cpp')
-rw-r--r--src/gui/text/qtextcontrol.cpp44
1 files changed, 41 insertions, 3 deletions
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index 89ca6bf8c1..e15c06d1af 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -115,6 +115,7 @@ static QTextLine currentTextLine(const QTextCursor &cursor)
QTextControlPrivate::QTextControlPrivate()
: doc(0), cursorOn(false), cursorIsFocusIndicator(false),
interactionFlags(Qt::TextEditorInteraction),
+ dragEnabled(true),
#ifndef QT_NO_DRAGANDDROP
mousePressed(false), mightStartDrag(false),
#endif
@@ -129,7 +130,8 @@ QTextControlPrivate::QTextControlPrivate()
isEnabled(true),
hadSelectionOnMousePress(false),
ignoreUnusedNavigationEvents(false),
- openExternalLinks(false)
+ openExternalLinks(false),
+ wordSelectionEnabled(false)
{}
bool QTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
@@ -1544,15 +1546,21 @@ void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, con
}
#endif
if (modifiers == Qt::ShiftModifier) {
+ if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) {
+ selectedWordOnDoubleClick = cursor;
+ selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor);
+ }
+
if (selectedBlockOnTrippleClick.hasSelection())
extendBlockwiseSelection(cursorPos);
else if (selectedWordOnDoubleClick.hasSelection())
extendWordwiseSelection(cursorPos, pos.x());
- else
+ else if (wordSelectionEnabled)
setCursorPosition(cursorPos, QTextCursor::KeepAnchor);
} else {
- if (cursor.hasSelection()
+ if (dragEnabled
+ && cursor.hasSelection()
&& !cursorIsFocusIndicator
&& cursorPos >= cursor.selectionStart()
&& cursorPos <= cursor.selectionEnd()
@@ -1625,6 +1633,11 @@ void QTextControlPrivate::mouseMoveEvent(Qt::MouseButtons buttons, const QPointF
if (newCursorPos == -1)
return;
+ if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) {
+ selectedWordOnDoubleClick = cursor;
+ selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor);
+ }
+
if (selectedBlockOnTrippleClick.hasSelection())
extendBlockwiseSelection(newCursorPos);
else if (selectedWordOnDoubleClick.hasSelection())
@@ -2331,6 +2344,31 @@ bool QTextControl::cursorIsFocusIndicator() const
return d->cursorIsFocusIndicator;
}
+
+void QTextControl::setDragEnabled(bool enabled)
+{
+ Q_D(QTextControl);
+ d->dragEnabled = enabled;
+}
+
+bool QTextControl::isDragEnabled() const
+{
+ Q_D(const QTextControl);
+ return d->dragEnabled;
+}
+
+void QTextControl::setWordSelectionEnabled(bool enabled)
+{
+ Q_D(QTextControl);
+ d->wordSelectionEnabled = enabled;
+}
+
+bool QTextControl::isWordSelectionEnabled() const
+{
+ Q_D(const QTextControl);
+ return d->wordSelectionEnabled;
+}
+
#ifndef QT_NO_PRINTER
void QTextControl::print(QPrinter *printer) const
{