summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-01-25 14:53:28 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-01-25 14:53:28 (GMT)
commita67be14c2280065412f00133e8a1d2bed371eac9 (patch)
treedc35f70a98e3e5701d33c9fb7c7304057f5d45df
parenta0e0a9378d10db9c8ab3ba4d59f5c576ee4cbc40 (diff)
parent34c297faca93e1286573b2a01127e4e7af00aff2 (diff)
downloadQt-a67be14c2280065412f00133e8a1d2bed371eac9.zip
Qt-a67be14c2280065412f00133e8a1d2bed371eac9.tar.gz
Qt-a67be14c2280065412f00133e8a1d2bed371eac9.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Fix cursor position adjustment when removing strings
-rw-r--r--src/gui/text/qtextdocument_p.cpp4
-rw-r--r--tests/auto/qtextcursor/tst_qtextcursor.cpp28
2 files changed, 31 insertions, 1 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 498a432..2172f74 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -663,7 +663,8 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O
Q_ASSERT(blocks.length() == fragments.length());
- finishEdit();
+ if (!blockCursorAdjustment)
+ finishEdit();
}
void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operation op)
@@ -678,6 +679,7 @@ void QTextDocumentPrivate::remove(int pos, int length, QTextUndoCommand::Operati
curs->changed = true;
}
}
+ finishEdit();
}
void QTextDocumentPrivate::setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode)
diff --git a/tests/auto/qtextcursor/tst_qtextcursor.cpp b/tests/auto/qtextcursor/tst_qtextcursor.cpp
index ee2baef..4d52dd7 100644
--- a/tests/auto/qtextcursor/tst_qtextcursor.cpp
+++ b/tests/auto/qtextcursor/tst_qtextcursor.cpp
@@ -134,6 +134,7 @@ private slots:
void endOfLine();
void editBlocksDuringRemove();
+ void selectAllDuringRemove();
void update_data();
void update();
@@ -1388,6 +1389,17 @@ public slots:
++recordingCount;
}
+ void selectAllContents()
+ {
+ // Only test the first time
+ if (!recordingCount) {
+ recordingCount++;
+ cursor->select(QTextCursor::Document);
+ lastRecordedPosition = cursor->position();
+ lastRecordedAnchor = cursor->anchor();
+ }
+ }
+
private:
QTextCursor *cursor;
};
@@ -1411,6 +1423,22 @@ void tst_QTextCursor::editBlocksDuringRemove()
QVERIFY(doc->toPlainText().isEmpty());
}
+void tst_QTextCursor::selectAllDuringRemove()
+{
+ CursorListener listener(&cursor);
+
+ cursor.insertText("Hello World");
+ cursor.movePosition(QTextCursor::End);
+
+ connect(doc, SIGNAL(contentsChanged()), &listener, SLOT(selectAllContents()));
+ listener.recordingCount = 0;
+ QTextCursor localCursor = cursor;
+ localCursor.deletePreviousChar();
+
+ QCOMPARE(listener.lastRecordedPosition, 10);
+ QCOMPARE(listener.lastRecordedAnchor, 0);
+}
+
void tst_QTextCursor::update_data()
{
QTest::addColumn<QString>("text");