From ef8c85325b2a55f4da6699b2e1add9dbff8794db Mon Sep 17 00:00:00 2001 From: Szymon Tomasz Stefanek Date: Mon, 31 May 2010 02:59:54 +0000 Subject: Fix for bug #488 git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4402 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/kvirc/ui/kvi_windowlist_tree.cpp | 26 +++++++++++++++++++++++++- src/kvirc/ui/kvi_windowlist_tree.h | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/kvirc/ui/kvi_windowlist_tree.cpp b/src/kvirc/ui/kvi_windowlist_tree.cpp index 613f6728f..8efbb6270 100644 --- a/src/kvirc/ui/kvi_windowlist_tree.cpp +++ b/src/kvirc/ui/kvi_windowlist_tree.cpp @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -176,9 +177,32 @@ KviTreeWindowListTreeWidget::~KviTreeWindowListTreeWidget() void KviTreeWindowListTreeWidget::mouseMoveEvent(QMouseEvent *) { - //dummy just to avoid bug #581 + // dummy just to avoid bug #581: + // Clicking on item A and moving the mouse to item B selects item A first and then item B + // Hovewer item A remains current } +void KviTreeWindowListTreeWidget::wheelEvent(QWheelEvent *e) +{ + // Mitigate bug #488: + // When there is a scroll bar the wheel scrolls up and down + // When there is no scroll bar the wheel changes selection in the tree + QScrollBar * pBar = verticalScrollBar(); + + if(!pBar) + return; + if(!pBar->isVisible()) + return; + if( + ((e->delta() < 0) && (pBar->value() < pBar->maximum())) || + ((e->delta() > 0) && (pBar->value() > pBar->minimum())) + ) + QApplication::sendEvent(pBar,e); + else + e->accept(); // eat it +} + + void KviTreeWindowListTreeWidget::mousePressEvent(QMouseEvent *e) { KviTreeWindowListItem * it = (KviTreeWindowListItem *)itemAt(e->pos()); diff --git a/src/kvirc/ui/kvi_windowlist_tree.h b/src/kvirc/ui/kvi_windowlist_tree.h index 5813f63a5..30e6b06cd 100644 --- a/src/kvirc/ui/kvi_windowlist_tree.h +++ b/src/kvirc/ui/kvi_windowlist_tree.h @@ -67,6 +67,7 @@ public: protected: virtual void mousePressEvent(QMouseEvent * e); virtual void mouseMoveEvent(QMouseEvent * e); + virtual void wheelEvent(QWheelEvent * e); virtual void mouseDoubleClickEvent(QMouseEvent * e); virtual void paintEvent(QPaintEvent * event); private: -- cgit v1.3.1-10-gc9f91