summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qdatawidgetmapper
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2012-10-13 13:41:30 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-26 15:24:00 +0200
commit84787d82ee9369b2a83c5b0568ee62ab602a5528 (patch)
tree56ba0976b2a8acc32c334d2918dd150349ffbfc2 /tests/auto/widgets/itemviews/qdatawidgetmapper
parent4fbdb969fb4e446eab01f27eb2c880f8d6cb9106 (diff)
QComboBox: fix use in QDataWidgetMapper/QItemDelegate
QItemDelegate and QDataWidgetMapper use the WRITE method on the USER property to set a value in a widget. This did not work for QComboBox whose USER property currentText lacked a WRITE method. This change adds the missing setter and flags it as the WRITE method. The setter setCurrentText() simply calls setEditText() if the combo box is editable. Otherwise, if there is a matching text in the list, currentIndex is set to the corresponding index. Test included. Follow-up to 816c5540179362500dfc175b77f05abf3ef25233 which restored currentText as the USER property. Task-number: QTBUG-26501 Change-Id: I5f2f999e60b09728ca03ead4e28fe36d1f3ee189 Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'tests/auto/widgets/itemviews/qdatawidgetmapper')
-rw-r--r--tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
index 85ee7144c9..6ef0988f31 100644
--- a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
+++ b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
@@ -362,8 +362,10 @@ void tst_QDataWidgetMapper::comboBox()
mapper.addMapping(&readWriteBox, 1, "currentText");
mapper.toFirst();
+ // setCurrentIndex caused the value at index 0 to be displayed
QCOMPARE(readOnlyBox.currentText(), QString("read only item 0"));
- QCOMPARE(readWriteBox.currentText(), QString("read write item 0"));
+ // setCurrentText set the value in the line edit since the combobox is editable
+ QCOMPARE(readWriteBox.currentText(), QString("item 0 1"));
// set some new values on the boxes
readOnlyBox.setCurrentIndex(1);
@@ -380,7 +382,6 @@ void tst_QDataWidgetMapper::comboBox()
model->setData(model->index(0, 1), QString("read write item z"), Qt::EditRole);
QCOMPARE(readOnlyBox.currentIndex(), 2);
- QEXPECT_FAIL("", "See task 125493 and QTBUG-428", Abort);
QCOMPARE(readWriteBox.currentText(), QString("read write item z"));
}