summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-04-12 05:59:01 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-04-12 05:59:01 (GMT)
commit9eab27889b1e14385f9428417e048da960ca06de (patch)
tree9de48fdfac4cf0129520922cb9b1660dde29d65c /src/gui/text
parent27f8facfea87d7c4669852e7aa0fe5d9ca828eb3 (diff)
parent3769a716e1e472bb1ab00d5f67268f001ab8645e (diff)
downloadQt-9eab27889b1e14385f9428417e048da960ca06de.zip
Qt-9eab27889b1e14385f9428417e048da960ca06de.tar.gz
Qt-9eab27889b1e14385f9428417e048da960ca06de.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (54 commits) Apply f176759fc41abc4cb901c2cbaa15264f2a9ac85b to stdout too. Autotest: add some debugging, just in case there's something wrong Autotest: fix the fix for the rounding error. Fix compile error with QT_NO_LIBRARY in QtMultimedia the _setmode() prototype is different on win ce qdoc: Changed qdoc to output the new doc format. Doc: update 'developing on mac' fcntl.h doesn't seem to exist, either - contrary to an example on msdn Autotest: fix paths on the test server after update. Force the repaint during a window resize. fix compile on wince remove CONFIG += ordered again Assistant: Check namespace and virtual folder syntax of help projects. QtHelp: Fix auto tests. Fix a crash when unloading libQtCore Introduce a qconfig feature for QtDBus Fix build after MR 543 merged. Compile on 10.4. revert "Fix the Qt build on Mac OS X/Cocoa 64-bit" Remove expected failures after JavaScriptCore bug fix ...
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextdocument_p.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 302a349..e2bca04 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -870,6 +870,7 @@ int QTextDocumentPrivate::undoRedo(bool undo)
undoEnabled = false;
beginEditBlock();
int editPos = -1;
+ int editLength = -1;
while (1) {
if (undo)
--undoState;
@@ -882,12 +883,16 @@ int QTextDocumentPrivate::undoRedo(bool undo)
PMDEBUG(" erase: from %d, length %d", c.pos, c.length);
c.command = QTextUndoCommand::Removed;
editPos = c.pos;
+ editLength = 0;
break;
case QTextUndoCommand::Removed:
PMDEBUG(" insert: format %d (from %d, length %d, strpos=%d)", c.format, c.pos, c.length, c.strPos);
insert_string(c.pos, c.strPos, c.length, c.format, (QTextUndoCommand::Operation)c.operation);
c.command = QTextUndoCommand::Inserted;
- editPos = c.pos + c.length;
+ if (editPos != (int)c.pos)
+ editLength = 0;
+ editPos = c.pos;
+ editLength += c.length;
break;
case QTextUndoCommand::BlockInserted:
case QTextUndoCommand::BlockAdded:
@@ -898,6 +903,7 @@ int QTextDocumentPrivate::undoRedo(bool undo)
else
c.command = QTextUndoCommand::BlockDeleted;
editPos = c.pos;
+ editLength = 0;
break;
case QTextUndoCommand::BlockRemoved:
case QTextUndoCommand::BlockDeleted:
@@ -908,7 +914,10 @@ int QTextDocumentPrivate::undoRedo(bool undo)
c.command = QTextUndoCommand::BlockInserted;
else
c.command = QTextUndoCommand::BlockAdded;
- editPos = c.pos + 1;
+ if (editPos != (int)c.pos)
+ editLength = 0;
+ editPos = c.pos;
+ editLength += 1;
break;
case QTextUndoCommand::CharFormatChanged: {
resetBlockRevision = -1; // ## TODO
@@ -919,7 +928,10 @@ int QTextDocumentPrivate::undoRedo(bool undo)
int oldFormat = it.value()->format;
setCharFormat(c.pos, c.length, formats.charFormat(c.format));
c.format = oldFormat;
- editPos = c.pos + c.length;
+ if (editPos != (int)c.pos)
+ editLength = 0;
+ editPos = c.pos;
+ editLength += c.length;
break;
}
case QTextUndoCommand::BlockFormatChanged: {
@@ -987,13 +999,19 @@ int QTextDocumentPrivate::undoRedo(bool undo)
break;
}
undoEnabled = true;
- if (editPos < 0 && docChangeFrom >= 0) {
- editPos = qMin(docChangeFrom + docChangeLength, length() - 1);
- }
+
+ int newCursorPos = -1;
+
+ if (editPos >=0)
+ newCursorPos = editPos + editLength;
+ else if (docChangeFrom >= 0)
+ newCursorPos= qMin(docChangeFrom + docChangeLength, length() - 1);
+
endEditBlock();
emitUndoAvailable(isUndoAvailable());
emitRedoAvailable(isRedoAvailable());
- return editPos;
+
+ return newCursorPos;
}
/*!