summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
diff options
context:
space:
mode:
authorThorbjørn Lund Martsum <tmartsum@gmail.com>2012-11-07 19:06:01 +0100
committerThorbjørn Lund Martsum <tmartsum@gmail.com>2015-12-09 17:53:59 +0000
commit410aa20f073b5e45e73366773b7d173f840a9cfe (patch)
tree910574ee38d07c02b43283833f86c21f8431182d /tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
parent49568df95450733dc4c273945e5ced218132c123 (diff)
QAIV - allow users to control single step in ScrollPerPixel mode
The documentation says that we scroll one pixel, but changing the behavior in 934f06220391eb0e0ebf66a2eb037f48adb4c43c to do that was not well received. People were relying on the undocumented behavior - and the new behavior was considered to be a regression. (Nobody called setSingleStep since Qt in many cases provide a reasonable singleStep - which implied that their programs scrolled with 1 pixel which was quite slow). Furthermore getting the old behavior (auto set of single step) was nearly impossible. However the revert (done in 0e69230d02813f0b7a050645fb7e443bd504ab6a) gets us back to QScrollbar::setSingleStep not working in pixel scroll mode (even without it being documented - but we should also have a working API rather than documenting that it is not working) The previous approach was directly prevented Qt from changing single step (on e.g resize) at all. This patch only prevents Qt from changing when a user explicitly has called the function QScrollBar::setSingleStep (in pixel scroll mode). That is we expect that calls to setSingleStep means that the user actually wants to set the singleStep and doesn't want Qt to control that value. Furthermore it is possible to switch back to the automatically adjusted singlestep with QScrollBar::setSingleStep(-1). [ChangeLog][QtWidgets][QAbstractItemView] QTBUG-7232 - In ItemViews when scrollMode is set to scrollPerPixel, it is now possible to change the single step. Qt will automatically adjust the single step until setSingleStep is called. When setSingleStep is called it will however respect the set and stop doing automatic changes of the value. Calling setSingleStep(-1) will switch mode back to automatic adjust. Task-number: QTBUG-7232 Change-Id: Ibfe0caa9751d3bcc11bfc6e0654a3d1ac35ac8ae Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp')
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index 45dab3f2c1..432c03a2df 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -214,6 +214,8 @@ private slots:
void changeHeaderData();
void viewOptions();
+
+ void taskQTBUG_7232_AllowUserToControlSingleStep();
};
// Testing get/set functions
@@ -4483,5 +4485,41 @@ void tst_QTableView::taskQTBUG_30653_doItemsLayout()
QCOMPARE(scrollToBottomOffset, doItemsLayoutOffset);
}
+void tst_QTableView::taskQTBUG_7232_AllowUserToControlSingleStep()
+{
+ // When we set the scrollMode to ScrollPerPixel it will adjust the scrollbars singleStep automatically
+ // Setting a singlestep on a scrollbar should however imply that the user takes control (and it is not changed by geometry updates).
+ // Setting a singlestep to -1 return to an automatic control of the singleStep.
+ QTableView t;
+ t.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ t.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ QStandardItemModel model(200, 200);
+ t.setModel(&model);
+ t.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&t));
+ t.setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
+ t.setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
+
+ t.setGeometry(200, 200, 200, 200);
+ int vStep1 = t.verticalScrollBar()->singleStep();
+ int hStep1 = t.horizontalScrollBar()->singleStep();
+ QVERIFY(vStep1 > 1);
+ QVERIFY(hStep1 > 1);
+
+ t.verticalScrollBar()->setSingleStep(1);
+ t.setGeometry(300, 300, 300, 300);
+ QCOMPARE(t.verticalScrollBar()->singleStep(), 1);
+
+ t.horizontalScrollBar()->setSingleStep(1);
+ t.setGeometry(400, 400, 400, 400);
+ QCOMPARE(t.horizontalScrollBar()->singleStep(), 1);
+
+ t.setGeometry(200, 200, 200, 200);
+ t.verticalScrollBar()->setSingleStep(-1);
+ t.horizontalScrollBar()->setSingleStep(-1);
+ QCOMPARE(vStep1, t.verticalScrollBar()->singleStep());
+ QCOMPARE(hStep1, t.horizontalScrollBar()->singleStep());
+}
+
QTEST_MAIN(tst_QTableView)
#include "tst_qtableview.moc"