summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2010-02-03 10:30:20 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2010-02-03 10:41:10 (GMT)
commitd53315d30b38352db11063096ee3867a40bdc234 (patch)
tree6ccfe9142099d627b2b7acd5458477a2cecb1477
parent7d4ef9167249df5f00831dc07e57705eb1ddd22a (diff)
downloadQt-d53315d30b38352db11063096ee3867a40bdc234.zip
Qt-d53315d30b38352db11063096ee3867a40bdc234.tar.gz
Qt-d53315d30b38352db11063096ee3867a40bdc234.tar.bz2
Revert "QAbstractScrollArea: Wheel over a scrollarea that has only one horizontal scrollbar"
This reverts commit 46a3e518b3070cf7cb4cbbb2cb58254454cf169d. This shown to cause more problem than it solved Also update the changelog Reviewed-by: Thierry
-rw-r--r--dist/changes-4.6.23
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp11
-rw-r--r--src/gui/widgets/qabstractslider.cpp2
-rw-r--r--tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp97
4 files changed, 11 insertions, 102 deletions
diff --git a/dist/changes-4.6.2 b/dist/changes-4.6.2
index 292b3ef..4127e13 100644
--- a/dist/changes-4.6.2
+++ b/dist/changes-4.6.2
@@ -46,6 +46,9 @@ QtCore
QtGui
-----
+ - QAbstractScrollArea
+ * [QTBUG-1760] Reverted horizontal scrolling with mouse wheel when vertical scrollbar is hidden
+
- QBmpHandler
* [QTBUG-7530] Fixed an infinite loop that could occur when reading invalid BMP images.
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index 87f6c83..1d496d5 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -1134,13 +1134,10 @@ void QAbstractScrollArea::mouseMoveEvent(QMouseEvent *e)
void QAbstractScrollArea::wheelEvent(QWheelEvent *e)
{
Q_D(QAbstractScrollArea);
- QScrollBar *const bars[2] = { d->hbar, d->vbar };
- int idx = (e->orientation() == Qt::Vertical) ? 1 : 0;
- int other = (idx + 1) % 2;
- if (!bars[idx]->isVisible() && bars[other]->isVisible())
- idx = other; // If the scrollbar of the event orientation is hidden, fallback to the other.
-
- QApplication::sendEvent(bars[idx], e);
+ if (static_cast<QWheelEvent*>(e)->orientation() == Qt::Horizontal)
+ QApplication::sendEvent(d->hbar, e);
+ else
+ QApplication::sendEvent(d->vbar, e);
}
#endif
diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp
index 2874647..77c5a01 100644
--- a/src/gui/widgets/qabstractslider.cpp
+++ b/src/gui/widgets/qabstractslider.cpp
@@ -697,6 +697,8 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e)
{
Q_D(QAbstractSlider);
e->ignore();
+ if (e->orientation() != d->orientation && !rect().contains(e->pos()))
+ return;
int stepsToScroll = 0;
qreal offset = qreal(e->delta()) / 120;
diff --git a/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp
index 3e062b8..da83826 100644
--- a/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp
+++ b/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp
@@ -71,8 +71,6 @@ private slots:
void viewportCrash();
void task214488_layoutDirection_data();
void task214488_layoutDirection();
- void wheelEvent_data();
- void wheelEvent();
};
tst_QAbstractScrollArea::tst_QAbstractScrollArea()
@@ -298,10 +296,10 @@ public:
setAttribute(Qt::WA_DropSiteRegistered, true);
- startTimer(200);
+ startTimer(2000);
}
- void timerEvent(QTimerEvent *)
+ void timerEvent(QTimerEvent *event)
{
// should not crash.
(void)new QScrollArea(this);
@@ -387,96 +385,5 @@ void tst_QAbstractScrollArea::patternBackground()
QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::red).rgb());
}
-Q_DECLARE_METATYPE(QWheelEvent *);
-
-void tst_QAbstractScrollArea::wheelEvent_data()
-{
- QTest::addColumn<QSize>("widgetSize");
- QTest::addColumn<QPoint>("initialOffset");
- QTest::addColumn<QWheelEvent *>("event");
- QTest::addColumn<int>("movedX"); // -1 , 0 , or 1
- QTest::addColumn<int>("movedY");
-
- QPoint pos(100,100);
- int delta =-120;
-
- QTest::newRow("1") << QSize(600,600) << QPoint(50,50)
- << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 1 << 0;
-
- QTest::newRow("2") << QSize(600,600) << QPoint(50,50)
- << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 0 << 1;
-
- QTest::newRow("3") << QSize(600,600) << QPoint(50,50)
- << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << -1 << 0;
-
- QTest::newRow("4") << QSize(600,600) << QPoint(50,50)
- << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << 0 << -1;
-
- QTest::newRow("5") << QSize(20,600) << QPoint(0,50)
- << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 0 << 1;
-
- QTest::newRow("6") << QSize(20,600) << QPoint(0,50)
- << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 0 << 1;
-
- QTest::newRow("7") << QSize(20,600) << QPoint(0,50)
- << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << 0 << -1;
-
- QTest::newRow("8") << QSize(20,600) << QPoint(0,50)
- << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << 0 << -1;
-
- QTest::newRow("9") << QSize(600,20) << QPoint(50,0)
- << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 1 << 0;
-
- QTest::newRow("a") << QSize(600,20) << QPoint(50,0)
- << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 1 << 0;
-
- QTest::newRow("b") << QSize(600,20) << QPoint(50,0)
- << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << -1 << 0;
-
- QTest::newRow("c") << QSize(600,20) << QPoint(50,0)
- << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << -1 << 0;
-}
-
-
-
-
-void tst_QAbstractScrollArea::wheelEvent()
-{
- QFETCH(QSize, widgetSize);
- QFETCH(QPoint, initialOffset);
- QFETCH(QWheelEvent *, event);
- QFETCH(int, movedX);
- QFETCH(int, movedY);
-
- QScrollArea scrollArea;
- scrollArea.resize(200, 200);
- QLabel widget("H e l l o");
- widget.resize(widgetSize);
- scrollArea.setWidget(&widget);
- scrollArea.show();
- QTest::qWait(20);
-
- scrollArea.verticalScrollBar()->setValue(initialOffset.y());
- scrollArea.horizontalScrollBar()->setValue(initialOffset.x());
-
- QCOMPARE(scrollArea.verticalScrollBar()->value(), initialOffset.y());
- QCOMPARE(scrollArea.horizontalScrollBar()->value(), initialOffset.x());
-
- QApplication::sendEvent(scrollArea.viewport(), event);
-
- if(movedX == 0)
- QCOMPARE(scrollArea.horizontalScrollBar()->value(), initialOffset.x());
- else
- QVERIFY(movedX * scrollArea.horizontalScrollBar()->value() > movedX * initialOffset.x());
-
- if(movedY == 0)
- QCOMPARE(scrollArea.verticalScrollBar()->value(), initialOffset.y());
- else
- QVERIFY(movedY * scrollArea.verticalScrollBar()->value() > movedY * initialOffset.y());
-
- delete event;
-}
-
-
QTEST_MAIN(tst_QAbstractScrollArea)
#include "tst_qabstractscrollarea.moc"