summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument_p.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-06 23:12:09 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-06 23:12:09 (GMT)
commitcc70c67b13063e789e874a54ab24048428e19dac (patch)
tree05b897ab6cf46df165f4a5ef157125c640a4b59b /src/gui/text/qtextdocument_p.cpp
parent9aef5ac9fd2452657ca018325db54e374bdeb164 (diff)
parent17889fb808c5450f4e3d19855e5656fc1188e067 (diff)
downloadQt-cc70c67b13063e789e874a54ab24048428e19dac.zip
Qt-cc70c67b13063e789e874a54ab24048428e19dac.tar.gz
Qt-cc70c67b13063e789e874a54ab24048428e19dac.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: (31 commits) Prevent a recursive debug output loop when writing to the logger widget. Fix performance of QTextDocumentPrivate::adjustDocumentChangesAndCursors Convert QtDeclarative def files to use LF line endings Update QtDeclarative def files doc improvements Changing currentIndex shouldn't cancel a flick unnecessarily. Fix input methods for TextInput elements with key handlers Document the QML enumeration basic type Fix TextEdit with no color property defined is drawn with wrong color Export QDeclarativePixmap doc Fix inconsistent reporting of module import errors when using versions. Make declarative pixmap cache easier to use Prepare for QTest persistent store for visual tests. Loosen font-sensitive test. Set correct license header. Work around QTBUG-11929 <br/> shouldn't trigger a new format range in QDeclarativeStyledText. Add styled text layout benchmark. Optimize QDeclarativeStyledText. ...
Diffstat (limited to 'src/gui/text/qtextdocument_p.cpp')
-rw-r--r--src/gui/text/qtextdocument_p.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index f3cd481..9849317 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;
+ inRemove = 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,10 @@ void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operati
{
if (length == 0)
return;
+ inRemove = true;
move(pos, -1, length, op);
+ inRemove = false;
+ adjustDocumentChangesAndCursors(pos, -length, op);
}
void QTextDocumentPrivate::setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode)
@@ -1221,9 +1225,11 @@ void QTextDocumentPrivate::finishEdit()
}
}
- while (!changedCursors.isEmpty()) {
- QTextCursorPrivate *curs = changedCursors.takeFirst();
- emit q->cursorPositionChanged(QTextCursor(curs));
+ foreach (QTextCursorPrivate *curs, cursors) {
+ if (curs->changed) {
+ curs->changed = false;
+ emit q->cursorPositionChanged(QTextCursor(curs));
+ }
}
contentsChanged();
@@ -1263,14 +1269,15 @@ void QTextDocumentPrivate::documentChange(int from, int length)
*/
void QTextDocumentPrivate::adjustDocumentChangesAndCursors(int from, int addedOrRemoved, QTextUndoCommand::Operation op)
{
+ if (inRemove) // postpone, will be called again from QTextDocumentPrivate::remove()
+ return;
+
if (!editBlock)
++revision;
- for (int i = 0; i < cursors.size(); ++i) {
- QTextCursorPrivate *curs = cursors.at(i);
+ foreach (QTextCursorPrivate *curs, cursors) {
if (curs->adjustPosition(from, addedOrRemoved, op) == QTextCursorPrivate::CursorMoved) {
- if (!changedCursors.contains(curs))
- changedCursors.append(curs);
+ curs->changed = true;
}
}
@@ -1693,8 +1700,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