summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qlistview
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2016-02-05 16:41:20 -0800
committerGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2016-02-11 04:50:36 +0000
commit9e8c84aa14ee26c04ab04ff28f0bab22e04887d6 (patch)
tree5136a2afb0bdcdfa5e0e27adebe5c02f4fa3d411 /tests/auto/widgets/itemviews/qlistview
parentcc2938b5b6aa07210b04bd48ad8a2830701a06e5 (diff)
Add SH_ItemView_ScrollMode style hint and use it in QMacStyle
On OS X, the default scrolling mode of item views should be per pixel instead of per item. We enforce this through a new style hint. On all other platforms, the behavior remains the same. It's still possible to override the style hint by using the regular scroll mode setters. Any subsequent style change will result in a no-op once the setters have been called and until the properties are reset. Some auto-tests had to be update to to take the new behavior into account. [ChangeLog][QtWidgets][Styles] Added SH_ItemView_ScrollMode style hint. [ChangeLog][QtWidgets][Item Views] Item views scroll per pixel on OS X now. [ChangeLog][QtWidgets][Item Views] QAbstractItemView::verticalScrollMode and QAbstractItemView::horizontalScrollMode are now resettable. Change-Id: I3f923275c99aa4389323b52fc1c5455fe71f8d73 Task-number: QTBUG-50102 Reviewed-by: Jake Petroules <jake.petroules@theqtcompany.com>
Diffstat (limited to 'tests/auto/widgets/itemviews/qlistview')
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index ea9f20d5ba..5058dd2a81 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -279,6 +279,18 @@ public:
mutable bool wrongIndex;
};
+class ScrollPerItemListView : public QListView
+{
+public:
+ explicit ScrollPerItemListView(QWidget *parent = Q_NULLPTR)
+ : QListView(parent)
+ {
+ // Force per item scroll mode since it comes from the style by default
+ setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
+ setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
+ }
+};
+
void tst_QListView::initTestCase()
{
#ifdef Q_OS_WINCE //disable magic for WindowsCE
@@ -823,7 +835,7 @@ void tst_QListView::setCurrentIndex()
{
QStringListModel model(generateList(QLatin1String("item "), 20));
- QListView view;
+ ScrollPerItemListView view;
view.setModel(&model);
view.resize(220,182);
@@ -1153,7 +1165,7 @@ void tst_QListView::scrollTo()
{
QWidget topLevel;
setFrameless(&topLevel);
- QListView lv(&topLevel);
+ ScrollPerItemListView lv(&topLevel);
QStringListModel model(&lv);
QStringList list;
list << "Short item 1";
@@ -1189,6 +1201,7 @@ void tst_QListView::scrollTo()
model.setStringList(list);
lv.setModel(&model);
lv.setFixedSize(110, 200);
+
topLevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
@@ -1262,7 +1275,7 @@ void tst_QListView::scrollBarRanges()
const int rowHeight = 20;
QWidget topLevel;
- QListView lv(&topLevel);
+ ScrollPerItemListView lv(&topLevel);
QStringListModel model(&lv);
QStringList list;
for (int i = 0; i < rowCount; ++i)
@@ -1271,6 +1284,7 @@ void tst_QListView::scrollBarRanges()
model.setStringList(list);
lv.setModel(&model);
lv.resize(250, 130);
+
TestDelegate *delegate = new TestDelegate(&lv);
delegate->m_sizeHint = QSize(100, rowHeight);
lv.setItemDelegate(delegate);
@@ -1814,7 +1828,7 @@ void tst_QListView::taskQTBUG_2233_scrollHiddenItems()
QWidget topLevel;
setFrameless(&topLevel);
- QListView view(&topLevel);
+ ScrollPerItemListView view(&topLevel);
QStringListModel model(&view);
QStringList list;
for (int i = 0; i < rowCount; ++i)
@@ -2060,7 +2074,7 @@ void tst_QListView::taskQTBUG_21115_scrollToAndHiddenItems()
{
QFETCH(int, flow);
- QListView lv;
+ ScrollPerItemListView lv;
lv.setUniformItemSizes(true);
lv.setFlow(static_cast<QListView::Flow>(flow));
@@ -2155,7 +2169,7 @@ void tst_QListView::taskQTBUG_21804_hiddenItemsAndScrollingWithKeys()
model.setStringList(list);
// create listview
- QListView lv;
+ ScrollPerItemListView lv;
lv.setFlow(static_cast<QListView::Flow>(flow));
lv.setSpacing(spacing);
lv.setModel(&model);
@@ -2227,7 +2241,7 @@ void tst_QListView::spacing()
model.setStringList(list);
// create listview
- QListView lv;
+ ScrollPerItemListView lv;
lv.setFlow(static_cast<QListView::Flow>(flow));
lv.setModel(&model);
lv.setSpacing(spacing);