summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextcursor.cpp1
-rw-r--r--src/gui/text/qtextdocument_p.cpp23
-rw-r--r--src/gui/text/qtextdocument_p.h1
3 files changed, 21 insertions, 4 deletions
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp
index 63aa946..daa40a1 100644
--- a/src/gui/text/qtextcursor.cpp
+++ b/src/gui/text/qtextcursor.cpp
@@ -81,6 +81,7 @@ QTextCursorPrivate::QTextCursorPrivate(const QTextCursorPrivate &rhs)
currentCharFormat = rhs.currentCharFormat;
visualNavigation = rhs.visualNavigation;
keepPositionOnInsert = rhs.keepPositionOnInsert;
+ changed = rhs.changed;
priv->addCursor(this);
}
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;
+ }
}
}
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;