summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument_p.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-07-09 05:36:49 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-07-09 05:36:49 (GMT)
commit74a248462ef36f7784fd0816ee08030412459930 (patch)
treeab41c0313467be480446397a8fe5463abee83035 /src/gui/text/qtextdocument_p.cpp
parent49b828102626ba6faa38ea48d9f570283dd7fa9f (diff)
parent31cd8c15c0fdb2f08c2652609a57413a715d1b13 (diff)
downloadQt-74a248462ef36f7784fd0816ee08030412459930.zip
Qt-74a248462ef36f7784fd0816ee08030412459930.tar.gz
Qt-74a248462ef36f7784fd0816ee08030412459930.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/gui/text/qtextdocument_p.cpp')
-rw-r--r--src/gui/text/qtextdocument_p.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 9bcf8b4..7b3f985 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)
@@ -1221,12 +1229,15 @@ void QTextDocumentPrivate::finishEdit()
}
}
+ QList<QTextCursor> changedCursors;
foreach (QTextCursorPrivate *curs, cursors) {
if (curs->changed) {
curs->changed = false;
- emit q->cursorPositionChanged(QTextCursor(curs));
+ changedCursors.append(QTextCursor(curs));
}
}
+ foreach (const QTextCursor &cursor, changedCursors)
+ emit q->cursorPositionChanged(cursor);
contentsChanged();
@@ -1268,9 +1279,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;
+ }
}
}