diff options
author | mae <qt-info@nokia.com> | 2010-07-08 06:41:45 (GMT) |
---|---|---|
committer | mae <qt-info@nokia.com> | 2010-07-08 06:41:45 (GMT) |
commit | 0ba1b4d05629643131c0c7461b2a483d8a56ed39 (patch) | |
tree | 9ef82e8324a7790dde94c991a8d106024a8bff2d /src/gui | |
parent | 5cd72b07d202b487ca42486dfefc99ba2fff0045 (diff) | |
download | Qt-0ba1b4d05629643131c0c7461b2a483d8a56ed39.zip Qt-0ba1b4d05629643131c0c7461b2a483d8a56ed39.tar.gz Qt-0ba1b4d05629643131c0c7461b2a483d8a56ed39.tar.bz2 |
Fix exponential behavior of QTextCursor::removeSelectedText
This is an improved version of 62db6c18c7f1f60819783ed5e1340e9fc09e072e
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qtextdocument_p.cpp | 18 | ||||
-rw-r--r-- | src/gui/text/qtextdocument_p.h | 1 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 9bcf8b4..54bf36b 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -205,6 +205,7 @@ QTextDocumentPrivate::QTextDocumentPrivate() undoEnabled = true; inContentsChange = false; + blockCursorAdjustment = false; defaultTextOption.setTabStop(80); // same as in qtextengine.cpp defaultTextOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); @@ -669,7 +670,14 @@ void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operati { if (length == 0) return; + blockCursorAdjustment = true; move(pos, -1, length, op); + blockCursorAdjustment = false; + foreach (QTextCursorPrivate *curs, cursors) { + if (curs->adjustPosition(pos, -length, op) == QTextCursorPrivate::CursorMoved) { + curs->changed = true; + } + } } void QTextDocumentPrivate::setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode) @@ -1268,9 +1276,13 @@ void QTextDocumentPrivate::adjustDocumentChangesAndCursors(int from, int addedOr if (!editBlock) ++revision; - foreach (QTextCursorPrivate *curs, cursors) { - if (curs->adjustPosition(from, addedOrRemoved, op) == QTextCursorPrivate::CursorMoved) { - curs->changed = true; + if (blockCursorAdjustment) { + ; // postpone, will be called again from QTextDocumentPrivate::remove() + } else { + foreach (QTextCursorPrivate *curs, cursors) { + if (curs->adjustPosition(from, addedOrRemoved, op) == QTextCursorPrivate::CursorMoved) { + curs->changed = true; + } } } diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index b9d5f5a..b46d01c 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -345,6 +345,7 @@ public: int maximumBlockCount; uint needsEnsureMaximumBlockCount : 1; uint inContentsChange : 1; + uint blockCursorAdjustment : 1; QSizeF pageSize; QString title; QString url; |