summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextcontrol.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-17 14:27:48 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-11-17 14:27:48 (GMT)
commit62e641691b9a3eadc8b9fb2e31150cdf5b66115d (patch)
tree9033ae42f5b599e564421db69737ca0c70a85f53 /src/gui/text/qtextcontrol.cpp
parente76c4c03c98091ee3e509a0f9b64daba472567ff (diff)
parente02859c3c7910ab3de0ec594fd493df946a5102d (diff)
downloadQt-62e641691b9a3eadc8b9fb2e31150cdf5b66115d.zip
Qt-62e641691b9a3eadc8b9fb2e31150cdf5b66115d.tar.gz
Qt-62e641691b9a3eadc8b9fb2e31150cdf5b66115d.tar.bz2
Merge remote branch 'mainline/4.6' into 4.6
Diffstat (limited to 'src/gui/text/qtextcontrol.cpp')
-rw-r--r--src/gui/text/qtextcontrol.cpp37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index 2bfe33c..be79773 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -55,6 +55,7 @@
#include <qstyle.h>
#include <qtimer.h>
#include "private/qtextdocumentlayout_p.h"
+#include "private/qabstracttextdocumentlayout_p.h"
#include "private/qtextedit_p.h"
#include "qtextdocument.h"
#include "private/qtextdocument_p.h"
@@ -126,6 +127,7 @@ QTextControlPrivate::QTextControlPrivate()
#endif
isEnabled(true),
hadSelectionOnMousePress(false),
+ ignoreUnusedNavigationEvents(false),
openExternalLinks(false)
{}
@@ -264,19 +266,25 @@ bool QTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
cursor.setVisualNavigation(visualNavigation);
q->ensureCursorVisible();
+ bool ignoreNavigationEvents = ignoreUnusedNavigationEvents;
+ bool isNavigationEvent = e->key() == Qt::Key_Up || e->key() == Qt::Key_Down;
+
+#ifdef QT_KEYPAD_NAVIGATION
+ ignoreNavigationEvents = ignoreNavigationEvents || QApplication::keypadNavigationEnabled();
+ isNavigationEvent = isNavigationEvent ||
+ (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional
+ && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right));
+#else
+ isNavigationEvent = isNavigationEvent || e->key() == Qt::Key_Left || e->key() == Qt::Key_Right;
+#endif
+
if (moved) {
if (cursor.position() != oldCursorPos)
emit q->cursorPositionChanged();
emit q->microFocusChanged();
- }
-#ifdef QT_KEYPAD_NAVIGATION
- else if (QApplication::keypadNavigationEnabled()
- && ((e->key() == Qt::Key_Up || e->key() == Qt::Key_Down)
- || QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional
- && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right))) {
+ } else if (ignoreNavigationEvents && isNavigationEvent) {
return false;
}
-#endif
selectionChanged(/*forceEmitSelectionChanged =*/(mode == QTextCursor::KeepAnchor));
@@ -2263,6 +2271,18 @@ bool QTextControl::openExternalLinks() const
return d->openExternalLinks;
}
+bool QTextControl::ignoreUnusedNavigationEvents() const
+{
+ Q_D(const QTextControl);
+ return d->ignoreUnusedNavigationEvents;
+}
+
+void QTextControl::setIgnoreUnusedNavigationEvents(bool ignore)
+{
+ Q_D(QTextControl);
+ d->ignoreUnusedNavigationEvents = ignore;
+}
+
void QTextControl::moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode)
{
Q_D(QTextControl);
@@ -2319,6 +2339,9 @@ void QTextControl::print(QPrinter *printer) const
tempDoc->setUseDesignMetrics(doc->useDesignMetrics());
QTextCursor(tempDoc).insertFragment(d->cursor.selection());
doc = tempDoc;
+
+ // copy the custom object handlers
+ doc->documentLayout()->d_func()->handlers = d->doc->documentLayout()->d_func()->handlers;
}
doc->print(printer);
delete tempDoc;