diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-10 07:00:04 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-10 07:00:04 (GMT) |
commit | 89052de56c660baccaeae3ed83615a1dbd0494f5 (patch) | |
tree | a6718a096bedc6b9c86e1c780b7b6f3d89ef9c85 /src/gui/text | |
parent | 4cf3730c65b28f3e895a1a4c8f7db509e11c71c0 (diff) | |
parent | 6f6c25b61f6d83e86e93c5f82e2d699619d00d5e (diff) | |
download | Qt-89052de56c660baccaeae3ed83615a1dbd0494f5.zip Qt-89052de56c660baccaeae3ed83615a1dbd0494f5.tar.gz Qt-89052de56c660baccaeae3ed83615a1dbd0494f5.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: (65 commits)
Fix QTextDocument::markContentsDirty()
Replace 4.6 in all .qdocconf files
Resetting bindings through debugger interface
Fix crash with invalid role indexes
Make test pass and fix docs following removal of SpringFollow
Remove autotests of depracted element SmoothedFollow
doc improvements
Clean up at the end of each test.
Improve test reliability.
Fix crash
Follow -> Behavior
Added some documentation to spring animation
Fix spring animation
Update QtDeclarative def files
Fix exponential behavior of QTextCursor::removeSelectedText
Optimization: change signal/slot to function call
Don't show warning for attempts to load pixmaps asynchronously
Remove Image::pixmap property. QML applications should use
Update QmlChanges.txt
Don't double delete cancelled pixmap cache requests
...
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qtextcursor.cpp | 4 | ||||
-rw-r--r-- | src/gui/text/qtextcursor_p.h | 1 | ||||
-rw-r--r-- | src/gui/text/qtextdocument.cpp | 8 | ||||
-rw-r--r-- | src/gui/text/qtextdocument_p.cpp | 51 | ||||
-rw-r--r-- | src/gui/text/qtextdocument_p.h | 6 |
5 files changed, 44 insertions, 26 deletions
diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index a9caa6b..daa40a1 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -64,7 +64,8 @@ enum { QTextCursorPrivate::QTextCursorPrivate(QTextDocumentPrivate *p) : priv(p), x(0), position(0), anchor(0), adjusted_anchor(0), - currentCharFormat(-1), visualNavigation(false), keepPositionOnInsert(false) + currentCharFormat(-1), visualNavigation(false), keepPositionOnInsert(false), + changed(false) { priv->addCursor(this); } @@ -80,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/qtextcursor_p.h b/src/gui/text/qtextcursor_p.h index 4e36b95..4b3262f 100644 --- a/src/gui/text/qtextcursor_p.h +++ b/src/gui/text/qtextcursor_p.h @@ -114,6 +114,7 @@ public: int currentCharFormat; uint visualNavigation : 1; uint keepPositionOnInsert : 1; + uint changed : 1; }; QT_END_NAMESPACE diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index e0386f1..195dc28 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -583,11 +583,11 @@ void QTextDocument::setDefaultTextOption(const QTextOption &option) void QTextDocument::markContentsDirty(int from, int length) { Q_D(QTextDocument); - if (!d->inContentsChange) - d->beginEditBlock(); d->documentChange(from, length); - if (!d->inContentsChange) - d->endEditBlock(); + if (!d->inContentsChange) { + d->lout->documentChanged(d->docChangeFrom, d->docChangeOldLength, d->docChangeLength); + d->docChangeFrom = -1; + } } /*! diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index f3cd481..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); @@ -234,17 +235,17 @@ void QTextDocumentPrivate::init() void QTextDocumentPrivate::clear() { Q_Q(QTextDocument); - for (int i = 0; i < cursors.count(); ++i) { - cursors.at(i)->setPosition(0); - cursors.at(i)->currentCharFormat = -1; - cursors.at(i)->anchor = 0; - cursors.at(i)->adjusted_anchor = 0; + + foreach (QTextCursorPrivate *curs, cursors) { + curs->setPosition(0); + curs->currentCharFormat = -1; + curs->anchor = 0; + curs->adjusted_anchor = 0; } QList<QTextCursorPrivate *>oldCursors = cursors; QT_TRY{ cursors.clear(); - changedCursors.clear(); QMap<int, QTextObject *>::Iterator objectIt = objects.begin(); while (objectIt != objects.end()) { @@ -287,8 +288,8 @@ void QTextDocumentPrivate::clear() QTextDocumentPrivate::~QTextDocumentPrivate() { - for (int i = 0; i < cursors.count(); ++i) - cursors.at(i)->priv = 0; + foreach (QTextCursorPrivate *curs, cursors) + curs->priv = 0; cursors.clear(); undoState = 0; undoEnabled = true; @@ -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,10 +1229,15 @@ void QTextDocumentPrivate::finishEdit() } } - while (!changedCursors.isEmpty()) { - QTextCursorPrivate *curs = changedCursors.takeFirst(); - emit q->cursorPositionChanged(QTextCursor(curs)); + QList<QTextCursor> changedCursors; + foreach (QTextCursorPrivate *curs, cursors) { + if (curs->changed) { + curs->changed = false; + changedCursors.append(QTextCursor(curs)); + } } + foreach (const QTextCursor &cursor, changedCursors) + emit q->cursorPositionChanged(cursor); contentsChanged(); @@ -1266,11 +1279,13 @@ void QTextDocumentPrivate::adjustDocumentChangesAndCursors(int from, int addedOr if (!editBlock) ++revision; - for (int i = 0; i < cursors.size(); ++i) { - QTextCursorPrivate *curs = cursors.at(i); - if (curs->adjustPosition(from, addedOrRemoved, op) == QTextCursorPrivate::CursorMoved) { - if (!changedCursors.contains(curs)) - changedCursors.append(curs); + 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; + } } } @@ -1693,8 +1708,8 @@ bool QTextDocumentPrivate::ensureMaximumBlockCount() void QTextDocumentPrivate::aboutToRemoveCell(int from, int to) { Q_ASSERT(from <= to); - for (int i = 0; i < cursors.size(); ++i) - cursors.at(i)->aboutToRemoveCell(from, to); + foreach (QTextCursorPrivate *curs, cursors) + curs->aboutToRemoveCell(from, to); } QT_END_NAMESPACE diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index d1bd698..b46d01c 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -277,7 +277,7 @@ public: void documentChange(int from, int length); inline void addCursor(QTextCursorPrivate *c) { cursors.append(c); } - inline void removeCursor(QTextCursorPrivate *c) { cursors.removeAll(c); changedCursors.removeAll(c); } + inline void removeCursor(QTextCursorPrivate *c) { cursors.removeAll(c); } QTextFrame *frameAt(int pos) const; QTextFrame *rootFrame() const; @@ -329,8 +329,7 @@ private: BlockMap blocks; int initialBlockCharFormatIndex; - QList<QTextCursorPrivate*> cursors; - QList<QTextCursorPrivate*> changedCursors; + QList<QTextCursorPrivate *> cursors; QMap<int, QTextObject *> objects; QMap<QUrl, QVariant> resources; QMap<QUrl, QVariant> cachedResources; @@ -346,6 +345,7 @@ public: int maximumBlockCount; uint needsEnsureMaximumBlockCount : 1; uint inContentsChange : 1; + uint blockCursorAdjustment : 1; QSizeF pageSize; QString title; QString url; |