summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument_p.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-07-01 17:24:01 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-07-01 17:24:01 (GMT)
commit745ecfd8925716d962c97a4415881377faf6bdd5 (patch)
treec4f78b3bd143af52372064cd3ba5c0ae440813c5 /src/gui/text/qtextdocument_p.cpp
parentbda164303570629e44185e8baa52908ced6da301 (diff)
parent8968c79c575755cdb52d5e615ed19e4529047464 (diff)
downloadQt-745ecfd8925716d962c97a4415881377faf6bdd5.zip
Qt-745ecfd8925716d962c97a4415881377faf6bdd5.tar.gz
Qt-745ecfd8925716d962c97a4415881377faf6bdd5.tar.bz2
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts: bin/syncqt src/gui/text/qtextlayout.cpp tools/assistant/tools/assistant/helpviewer_qwv.cpp tools/assistant/tools/assistant/helpviewer_qwv.h tools/configure/configureapp.cpp
Diffstat (limited to 'src/gui/text/qtextdocument_p.cpp')
-rw-r--r--src/gui/text/qtextdocument_p.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index e2bca04..f3cd481 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -192,6 +192,7 @@ QTextDocumentPrivate::QTextDocumentPrivate()
initialBlockCharFormatIndex(-1) // set correctly later in init()
{
editBlock = 0;
+ editBlockCursorPosition = -1;
docChangeFrom = -1;
undoState = 0;
@@ -967,6 +968,10 @@ int QTextDocumentPrivate::undoRedo(bool undo)
editPos = -1;
break;
}
+ case QTextUndoCommand::CursorMoved:
+ editPos = c.pos;
+ editLength = 0;
+ break;
case QTextUndoCommand::Custom:
resetBlockRevision = -1; // ## TODO
if (undo)
@@ -1046,6 +1051,18 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c)
if (undoState < undoStack.size())
clearUndoRedoStacks(QTextDocument::RedoStack);
+ if (editBlock != 0 && editBlockCursorPosition >= 0) { // we had a beginEditBlock() with a cursor position
+ if (c.pos != (quint32) editBlockCursorPosition) { // and that cursor position is different from the command
+ // generate a CursorMoved undo item
+ QT_INIT_TEXTUNDOCOMMAND(cc, QTextUndoCommand::CursorMoved, true, QTextUndoCommand::MoveCursor,
+ 0, 0, editBlockCursorPosition, 0, 0);
+ undoStack.append(cc);
+ undoState++;
+ editBlockCursorPosition = -1;
+ }
+ }
+
+
if (!undoStack.isEmpty() && modified) {
QTextUndoCommand &last = undoStack[undoState - 1];
@@ -1167,6 +1184,8 @@ void QTextDocumentPrivate::endEditBlock()
}
}
+ editBlockCursorPosition = -1;
+
finishEdit();
}