diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-06-08 17:08:33 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-06-08 17:08:33 (GMT) |
commit | 00b157dc4aad203e78b8e4d821470a1d01a195c0 (patch) | |
tree | e7756c85df4a4dd4dbac715173c44da4e71f39f3 /src/gui | |
parent | 2ae808a23ce05bf9768ad9df107c16bb0c555ee7 (diff) | |
parent | e5567b2e0513f5a03987f78df2d565c0e6c6a951 (diff) | |
download | Qt-00b157dc4aad203e78b8e4d821470a1d01a195c0.zip Qt-00b157dc4aad203e78b8e4d821470a1d01a195c0.tar.gz Qt-00b157dc4aad203e78b8e4d821470a1d01a195c0.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (25 commits)
Fix snake demo
Add qmlmethod Item::childAt() to delarative item
Cursor positioning in QTextDocument after undo()
Fix slow network access in qmlviewer (Windows)
Don't layout multiple times when an ancestor becomes (in)visible.
Add an example of animated item add/remove in ListView
Add test for PropertyChanges with attached properties.
Make declarative autotests compile on Symbian abld build system
Accept enter key in the webbrower demo url input.
Keep reported point/pixel size in sync.
Remove unnecessary CloseSoftwareInputPanel events after TextEdit or TextInput has lost focus
Ensure state operations assigned to the default state are triggered
Add image example.
Fix regression in input panel autotests
Improve docs about Qml component case sensitivity.
Add some performance tips to QML docs.
Move QListModelInterface into util.
Ensure ParticleMotionGravity always pulls in the right direction.
Remove version ifdefs from Particles; only 4.7 is supported.
Update docs for the runtime.orientation values
...
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/text/qtextcursor.cpp | 3 | ||||
-rw-r--r-- | src/gui/text/qtextdocument_p.cpp | 19 | ||||
-rw-r--r-- | src/gui/text/qtextdocument_p.h | 2 |
3 files changed, 24 insertions, 0 deletions
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index d6ac3aa..3db66ce 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -2437,6 +2437,9 @@ void QTextCursor::beginEditBlock() if (!d || !d->priv) return; + if (d->priv->editBlock == 0) // we are the initial edit block, store current cursor position for undo + d->priv->editBlockCursorPosition = d->position; + d->priv->beginEditBlock(); } 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(); } 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; |