121 void taskQTBUG_2233_scrollHiddenItems(); |
121 void taskQTBUG_2233_scrollHiddenItems(); |
122 void taskQTBUG_633_changeModelData(); |
122 void taskQTBUG_633_changeModelData(); |
123 void taskQTBUG_435_deselectOnViewportClick(); |
123 void taskQTBUG_435_deselectOnViewportClick(); |
124 void taskQTBUG_2678_spacingAndWrappedText(); |
124 void taskQTBUG_2678_spacingAndWrappedText(); |
125 void taskQTBUG_5877_skippingItemInPageDownUp(); |
125 void taskQTBUG_5877_skippingItemInPageDownUp(); |
|
126 void taskQTBUG_9455_wrongScrollbarRanges(); |
|
127 void styleOptionViewItem(); |
126 }; |
128 }; |
127 |
129 |
128 // Testing get/set functions |
130 // Testing get/set functions |
129 void tst_QListView::getSetCheck() |
131 void tst_QListView::getSetCheck() |
130 { |
132 { |
1939 newCurrent = qMax(currentItemIndexes[i] - scrolledRowCount, 0); |
1941 newCurrent = qMax(currentItemIndexes[i] - scrolledRowCount, 0); |
1940 QCOMPARE(idx, model.index(newCurrent, 0)); |
1942 QCOMPARE(idx, model.index(newCurrent, 0)); |
1941 } |
1943 } |
1942 } |
1944 } |
1943 |
1945 |
|
1946 class ListView_9455 : public QListView |
|
1947 { |
|
1948 public: |
|
1949 QSize contentsSize() const |
|
1950 { |
|
1951 return QListView::contentsSize(); |
|
1952 } |
|
1953 }; |
|
1954 |
|
1955 void tst_QListView::taskQTBUG_9455_wrongScrollbarRanges() |
|
1956 { |
|
1957 QStringList list; |
|
1958 const int nrItems = 8; |
|
1959 for (int i = 0; i < nrItems; i++) |
|
1960 list << QString().sprintf("item %d", i); |
|
1961 |
|
1962 QStringListModel model(list); |
|
1963 ListView_9455 w; |
|
1964 w.setModel(&model); |
|
1965 w.setViewMode(QListView::IconMode); |
|
1966 w.resize(116, 132); |
|
1967 w.setMovement(QListView::Static); |
|
1968 const int spacing = 40; |
|
1969 w.setSpacing(spacing); |
|
1970 w.show(); |
|
1971 QTest::qWaitForWindowShown(&w); |
|
1972 QCOMPARE(w.verticalScrollBar()->maximum(), w.contentsSize().height() - w.viewport()->geometry().height()); |
|
1973 } |
|
1974 |
|
1975 void tst_QListView::styleOptionViewItem() |
|
1976 { |
|
1977 class MyDelegate : public QStyledItemDelegate |
|
1978 { |
|
1979 public: |
|
1980 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const |
|
1981 { |
|
1982 QVERIFY(qstyleoption_cast<const QStyleOptionViewItemV4 *>(&option)); |
|
1983 QStyleOptionViewItemV4 opt(option); |
|
1984 initStyleOption(&opt, index); |
|
1985 |
|
1986 QCOMPARE(opt.index, index); |
|
1987 |
|
1988 QStyledItemDelegate::paint(painter, option, index); |
|
1989 } |
|
1990 }; |
|
1991 |
|
1992 QListView view; |
|
1993 QStandardItemModel model; |
|
1994 view.setModel(&model); |
|
1995 MyDelegate delegate; |
|
1996 view.setItemDelegate(&delegate); |
|
1997 model.appendRow(QList<QStandardItem*>() |
|
1998 << new QStandardItem("Beginning") << new QStandardItem("Middle") << new QStandardItem("Middle") << new QStandardItem("End") ); |
|
1999 |
|
2000 // Run test |
|
2001 view.showMaximized(); |
|
2002 QApplication::processEvents(); |
|
2003 } |
|
2004 |
1944 QTEST_MAIN(tst_QListView) |
2005 QTEST_MAIN(tst_QListView) |
1945 #include "tst_qlistview.moc" |
2006 #include "tst_qlistview.moc" |