diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-23 09:54:19 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-23 09:54:19 (GMT) |
commit | cde4ad3db7c673ca8ba5457c12a8b04dfbbf99aa (patch) | |
tree | b530e5438838731e44805c619003a8efa434371b | |
parent | aeeb83806daaa2ddb4b6c87162c929d61cf1350c (diff) | |
parent | e34b0cc2766ce403a8d12964039957f45e35e451 (diff) | |
download | Qt-cde4ad3db7c673ca8ba5457c12a8b04dfbbf99aa.zip Qt-cde4ad3db7c673ca8ba5457c12a8b04dfbbf99aa.tar.gz Qt-cde4ad3db7c673ca8ba5457c12a8b04dfbbf99aa.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
tst_qlineedit: add contains(QT_CONFIG,qt3support) to the .pro file to make it compile
Fix regression: auto completion text cursor problem in Q3FileDialog
-rw-r--r-- | src/gui/widgets/qlineedit.cpp | 10 | ||||
-rw-r--r-- | tests/auto/qlineedit/qlineedit.pro | 1 | ||||
-rw-r--r-- | tests/auto/qlineedit/tst_qlineedit.cpp | 33 |
3 files changed, 42 insertions, 2 deletions
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 2d2df92..f041a36 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -738,8 +738,14 @@ bool QLineEdit::validateAndSet(const QString &newText, int newPos, setText(oldText); return false; } - setCursorPosition(newPos); - setSelection(qMin(newMarkAnchor, newMarkDrag), qAbs(newMarkAnchor - newMarkDrag)); + int selstart = qMin(newMarkAnchor, newMarkDrag); + int sellength = qAbs(newMarkAnchor - newMarkDrag); + if (selstart == newPos) { + selstart = qMax(newMarkAnchor, newMarkDrag); + sellength = -sellength; + } + //setSelection also set the position + setSelection(selstart, sellength); return true; } #endif //QT3_SUPPORT diff --git a/tests/auto/qlineedit/qlineedit.pro b/tests/auto/qlineedit/qlineedit.pro index f00a2d8..1f862b4 100644 --- a/tests/auto/qlineedit/qlineedit.pro +++ b/tests/auto/qlineedit/qlineedit.pro @@ -1,4 +1,5 @@ load(qttest_p4) +contains(QT_CONFIG,qt3support) QT += qt3support SOURCES += tst_qlineedit.cpp diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp index ca84b38..592c1cb 100644 --- a/tests/auto/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/qlineedit/tst_qlineedit.cpp @@ -273,6 +273,11 @@ private slots: void taskQTBUG_4679_selectToStartEndOfBlock(); void taskQTBUG_7395_readOnlyShortcut(); +#ifdef QT3_SUPPORT + void validateAndSet_data(); + void validateAndSet(); +#endif + protected slots: #ifdef QT3_SUPPORT void lostFocus(); @@ -1488,6 +1493,34 @@ void tst_QLineEdit::lostFocus() { editingFinished(); } + +void tst_QLineEdit::validateAndSet_data() +{ + QTest::addColumn<QString>("newText"); + QTest::addColumn<int>("newPos"); + QTest::addColumn<int>("newMarkAnchor"); + QTest::addColumn<int>("newMarkDrag"); + + QTest::newRow("1") << QString("Hello World") << 3 << 3 << 5; + QTest::newRow("2") << QString("Hello World") << 5 << 3 << 5; +} + +void tst_QLineEdit::validateAndSet() +{ + QFETCH(QString, newText); + QFETCH(int, newPos); + QFETCH(int, newMarkAnchor); + QFETCH(int, newMarkDrag); + + QLineEdit e; + e.validateAndSet(newText, newPos, newMarkAnchor, newMarkDrag); + QCOMPARE(e.text(), newText); + QCOMPARE(e.cursorPosition(), newPos); + QCOMPARE(e.selectedText(), newText.mid(newMarkAnchor, newMarkDrag-newMarkAnchor)); +} + + + #endif void tst_QLineEdit::editingFinished() { |