summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextcontrol.cpp
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-01-10 08:11:19 (GMT)
committerAndrew den Exter <andrew.den-exter@nokia.com>2011-01-11 00:34:50 (GMT)
commit7d43a31902ca6d2132004c45db313194c9669bb6 (patch)
tree4f9528033ad7835cde33636adea1aacdbd0fd862 /src/gui/text/qtextcontrol.cpp
parent17872d698be857d93b4d613f6423800308614684 (diff)
downloadQt-7d43a31902ca6d2132004c45db313194c9669bb6.zip
Qt-7d43a31902ca6d2132004c45db313194c9669bb6.tar.gz
Qt-7d43a31902ca6d2132004c45db313194c9669bb6.tar.bz2
Disable dragging text in TextEdit.
Add a dragEnabled property to QTextControl so text dragging can optionally be disabled. Task-number: QTBUG-16248 Reviewed-by: Martin Jones
Diffstat (limited to 'src/gui/text/qtextcontrol.cpp')
-rw-r--r--src/gui/text/qtextcontrol.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index 7f2c4e9..548d81e 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -114,6 +114,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
@@ -1551,7 +1552,8 @@ void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, con
setCursorPosition(cursorPos, QTextCursor::KeepAnchor);
} else {
- if (cursor.hasSelection()
+ if (dragEnabled
+ && cursor.hasSelection()
&& !cursorIsFocusIndicator
&& cursorPos >= cursor.selectionStart()
&& cursorPos <= cursor.selectionEnd()
@@ -2328,6 +2330,19 @@ 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;
+}
+
#ifndef QT_NO_PRINTER
void QTextControl::print(QPrinter *printer) const
{