summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-07 07:58:29 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-07 09:40:28 (GMT)
commit8c621378e79a417fc7512691bf07023c1496aac0 (patch)
treeb7e465714cd87be1ea492c617c70659f29f10b89
parent93c883b5388a5ed6e9dbd01ca6b314163576ede5 (diff)
downloadQt-8c621378e79a417fc7512691bf07023c1496aac0.zip
Qt-8c621378e79a417fc7512691bf07023c1496aac0.tar.gz
Qt-8c621378e79a417fc7512691bf07023c1496aac0.tar.bz2
Fixes: QComboBox keyboard search not working properly when current index is -1
If the current index is invalid, start would be (0,0) but would be skiped Task-number: 220195 Reviewed-by: thierry
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp2
-rw-r--r--tests/auto/qcombobox/tst_qcombobox.cpp36
2 files changed, 37 insertions, 1 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index d929590..421d511 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -2650,7 +2650,7 @@ void QAbstractItemView::keyboardSearch(const QString &search)
if (search.isEmpty()
|| (d->keyboardInputTime.msecsTo(now) > QApplication::keyboardInputInterval())) {
d->keyboardInput = search;
- skipRow = true;
+ skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0)
} else {
d->keyboardInput += search;
}
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp
index bd11fa4..4797698 100644
--- a/tests/auto/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/qcombobox/tst_qcombobox.cpp
@@ -139,6 +139,7 @@ private slots:
void task190205_setModelAdjustToContents();
void task248169_popupWithMinimalSize();
void task247863_keyBoardSelection();
+ void task220195_keyBoardSelection2();
void setModelColumn();
void noScrollbar_data();
void noScrollbar();
@@ -2138,6 +2139,40 @@ void tst_QComboBox::task247863_keyBoardSelection()
QCOMPARE(spy.count(), 1);
}
+void tst_QComboBox::task220195_keyBoardSelection2()
+{
+ QComboBox combo;
+ combo.setEditable(false);
+ combo.addItem( QLatin1String("foo1"));
+ combo.addItem( QLatin1String("foo2"));
+ combo.addItem( QLatin1String("foo3"));
+ combo.show();
+ QApplication::setActiveWindow(&combo);
+ QTest::qWait(100);
+
+ combo.setCurrentIndex(-1);
+ QVERIFY(combo.currentText().isNull());
+
+ QTest::keyClick(&combo, 'f');
+ QCOMPARE(combo.currentText(), QLatin1String("foo1"));
+ QTest::qWait(QApplication::keyboardInputInterval() + 30);
+ QTest::keyClick(&combo, 'f');
+ QCOMPARE(combo.currentText(), QLatin1String("foo2"));
+ QTest::qWait(QApplication::keyboardInputInterval() + 30);
+ QTest::keyClick(&combo, 'f');
+ QCOMPARE(combo.currentText(), QLatin1String("foo3"));
+ QTest::qWait(QApplication::keyboardInputInterval() + 30);
+ QTest::keyClick(&combo, 'f');
+ QCOMPARE(combo.currentText(), QLatin1String("foo1"));
+ QTest::qWait(QApplication::keyboardInputInterval() + 30);
+
+ combo.setCurrentIndex(1);
+ QCOMPARE(combo.currentText(), QLatin1String("foo2"));
+ QTest::keyClick(&combo, 'f');
+ QCOMPARE(combo.currentText(), QLatin1String("foo3"));
+}
+
+
void tst_QComboBox::setModelColumn()
{
QStandardItemModel model(5,3);
@@ -2238,5 +2273,6 @@ void tst_QComboBox::task253944_itemDelegateIsReset()
QCOMPARE(comboBox.itemDelegate(), itemDelegate);
}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"