summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2012-10-02 13:01:30 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-19 00:44:54 +0200
commitd84f449bcde56fd2df12f82dd2ba2e1f0a4ae7c7 (patch)
tree0d982beb7be025b695e57b707b51eec1e048414c /tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
parent8bed283f137c14a7be1fb9027eae5eae3ce796be (diff)
Make sure uints remain uints when editing in itemviews.
Task-number: QTBUG-22974 Change-Id: I07428862c4dffc629f868f3010f663eb655922d0 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp')
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index bed1d52f94..06964bac0d 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -224,6 +224,7 @@ private slots:
void dateTimeEditor_data();
void dateTimeEditor();
void dateAndTimeEditorTest2();
+ void uintEdit();
void decoration_data();
void decoration();
void editorEvent_data();
@@ -939,6 +940,66 @@ void tst_QItemDelegate::dateAndTimeEditorTest2()
w.doCloseEditor(dateEdit);
}
+void tst_QItemDelegate::uintEdit()
+{
+ QListView view;
+ QStandardItemModel model;
+
+ {
+ QStandardItem *data=new QStandardItem;
+ data->setEditable(true);
+ data->setData(QVariant((uint)1), Qt::DisplayRole);
+ model.setItem(0, 0, data);
+ }
+ {
+ QStandardItem *data=new QStandardItem;
+ data->setEditable(true);
+ data->setData(QVariant((uint)1), Qt::DisplayRole);
+ model.setItem(1, 0, data);
+ }
+
+ view.setModel(&model);
+ view.setEditTriggers(QAbstractItemView::AllEditTriggers);
+
+ const QModelIndex firstCell = model.index(0, 0);
+
+ QCOMPARE(firstCell.data(Qt::DisplayRole).userType(), static_cast<int>(QMetaType::UInt));
+
+ view.selectionModel()->setCurrentIndex(model.index(0, 0), QItemSelectionModel::Select);
+ view.edit(firstCell);
+
+ QSpinBox *sb = view.findChild<QSpinBox*>();
+ QVERIFY(sb);
+
+ sb->stepUp();
+
+ // Select another index to trigger the end of editing.
+ const QModelIndex secondCell = model.index(1, 0);
+ view.selectionModel()->setCurrentIndex(secondCell, QItemSelectionModel::Select);
+
+ QCOMPARE(firstCell.data(Qt::DisplayRole).userType(), static_cast<int>(QMetaType::UInt));
+ QCOMPARE(firstCell.data(Qt::DisplayRole).toUInt(), static_cast<uint>(2));
+
+
+ view.edit(secondCell);
+
+ // The first spinbox is deleted with deleteLater, so it is still there.
+ QList<QSpinBox*> sbList = view.findChildren<QSpinBox*>();
+ QCOMPARE(sbList.size(), 2);
+
+ sb = sbList.at(1);
+
+ sb->stepDown(); // 1 -> 0
+ sb->stepDown(); // 0 (no effect)
+ sb->stepDown(); // 0 (no effect)
+
+ // Select another index to trigger the end of editing.
+ view.selectionModel()->setCurrentIndex(firstCell, QItemSelectionModel::Select);
+
+ QCOMPARE(secondCell.data(Qt::DisplayRole).userType(), static_cast<int>(QMetaType::UInt));
+ QCOMPARE(secondCell.data(Qt::DisplayRole).toUInt(), static_cast<uint>(0));
+}
+
void tst_QItemDelegate::decoration_data()
{
QTest::addColumn<int>("type");