summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlistview/tst_qlistview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qlistview/tst_qlistview.cpp')
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index f5c32cd..330f803 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -124,6 +124,7 @@ private slots:
void taskQTBUG_2678_spacingAndWrappedText();
void taskQTBUG_5877_skippingItemInPageDownUp();
void taskQTBUG_9455_wrongScrollbarRanges();
+ void styleOptionViewItem();
};
// Testing get/set functions
@@ -1971,5 +1972,35 @@ void tst_QListView::taskQTBUG_9455_wrongScrollbarRanges()
QCOMPARE(w.verticalScrollBar()->maximum(), w.contentsSize().height() - w.viewport()->geometry().height());
}
+void tst_QListView::styleOptionViewItem()
+{
+ class MyDelegate : public QStyledItemDelegate
+ {
+ public:
+ void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
+ {
+ QVERIFY(qstyleoption_cast<const QStyleOptionViewItemV4 *>(&option));
+ QStyleOptionViewItemV4 opt(option);
+ initStyleOption(&opt, index);
+
+ QCOMPARE(opt.index, index);
+
+ QStyledItemDelegate::paint(painter, option, index);
+ }
+ };
+
+ QListView view;
+ QStandardItemModel model;
+ view.setModel(&model);
+ MyDelegate delegate;
+ view.setItemDelegate(&delegate);
+ model.appendRow(QList<QStandardItem*>()
+ << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") );
+
+ // Run test
+ view.showMaximized();
+ QApplication::processEvents();
+}
+
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"