diff options
author | mae <qt-info@nokia.com> | 2010-06-04 09:39:07 (GMT) |
---|---|---|
committer | mae <qt-info@nokia.com> | 2010-06-08 09:32:55 (GMT) |
commit | a46e97c429077022bc7f426a3adec588643abc57 (patch) | |
tree | 5053261acd1567c5ed32d04a40038b6634ba8848 /src/gui/text/qtextdocument_p.h | |
parent | 3e707f559f6f26ab7a5d5623f8e5af9ea9cc317e (diff) | |
download | Qt-a46e97c429077022bc7f426a3adec588643abc57.zip Qt-a46e97c429077022bc7f426a3adec588643abc57.tar.gz Qt-a46e97c429077022bc7f426a3adec588643abc57.tar.bz2 |
Cursor positioning in QTextDocument after undo()
QTextDocument had no way of storing the cursor position from which
a document change was initiated in the undo stack. That means that
any undo operation would reposition the text cursor to the text
position where the actual change happened. This works in many cases,
but not always.
In Qt Creator we have standard IDE shortcuts like e.g.
Ctrl+Return for InsertLineBelowCurrentLine, which insert a newline
at the end of the current line, not at the cursor position. Using
undo there resulted in a surprisingly wrong cursor position.
The problem becomes worse with more advanced refactoring and
productivity tools (like snippets).
The patch creates a synthetic CursorMoved undo item with the position
which was current at the time of calling QTextCursor::beginEditBlock(),
but only if necesary, i.e. only in those cases where the cursor would
be positioned wrongly.
Reviewed-by: Roberto Raggi
Diffstat (limited to 'src/gui/text/qtextdocument_p.h')
-rw-r--r-- | src/gui/text/qtextdocument_p.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index ac5ed3c..d1bd698 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -132,6 +132,7 @@ public: BlockAdded = 6, BlockDeleted = 7, GroupFormatChange = 8, + CursorMoved = 9, Custom = 256 }; enum Operation { @@ -315,6 +316,7 @@ private: bool modified; int editBlock; + int editBlockCursorPosition; int docChangeFrom; int docChangeOldLength; int docChangeLength; |