summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-12 07:08:45 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-12 07:08:45 (GMT)
commit7f3d351002d4a138860651769309e20d2b593112 (patch)
treef825bde50cfecae52172cb0bee666f42c817c629 /src/gui/text
parent9b83735e073e9f7acb5369d375be7d8a48faf5db (diff)
parentcbc7a0251a727827418707c7a05ea44241a06efb (diff)
downloadQt-7f3d351002d4a138860651769309e20d2b593112.zip
Qt-7f3d351002d4a138860651769309e20d2b593112.tar.gz
Qt-7f3d351002d4a138860651769309e20d2b593112.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: (69 commits) Remove use of SpringFollow and SmoothedFollow in qmlvisual test Fix Mac CI Add copy(), cut() and paste() support to TextInput Fix .pro file after class/test rename. 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 ...
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextcursor.cpp4
-rw-r--r--src/gui/text/qtextcursor_p.h1
-rw-r--r--src/gui/text/qtextdocument.cpp8
-rw-r--r--src/gui/text/qtextdocument_p.cpp51
-rw-r--r--src/gui/text/qtextdocument_p.h6
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;