[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Mousewheel orientation of KIconView in TopToBottom mode
From: Wilco Greven <greven () kde ! org>
Date: 2002-01-18 0:38:25
[Download RAW message or body]
Hi,
I'd like to change the direction in which KIconView scrolls by using the
mousewheel in TopToBottom mode. Because there usually is only a horizontal
scrollbar in TopToBottom mode, it makes sense IMO to make the mousewheel
scroll horizontally instead of vertically by default (only in TopToBottom
mode of course). Examples where this behaviour is very useful are konq's
MultiColumn view, and in the short view of the filedialog.
One needs to reimplement KIconView::wheelEvent to make this work. AFAIKS there
are two possibilities. The simplest one is as follows:
void KIconView::wheelEvent( QWheelEvent *e )
{
if( arrangement() == TopToBottom && e->orientation() == Vertical ) {
QWheelEvent ne( e->pos(), e->delta(), e->state(), Horizontal );
QIconView::wheelEvent( &ne );
}
else
QIconView::wheelEvent( e );
}
The problem with the above reimplementation is that the new wheelevent with
the changed orientation is passed to viewportWheelEvent. This can be avoid by
taking QScrollView::wheelEvent, and switch the orientation after
viewportWheelEvent has been called.
void KIconView::wheelEvent( QWheelEvent *e )
{
QWheelEvent ce( viewport()->mapFromGlobal( e->globalPos() ),
e->globalPos(), e->delta(), e->state());
viewportWheelEvent(&ce);
-- Switch orientation here --
if ( !ce.isAccepted() ) {
if ( e->orientation() == Horizontal && horizontalScrollBar() )
QApplication::sendEvent( horizontalScrollBar(), e);
else if (e->orientation() == Vertical && verticalScrollBar() )
QApplication::sendEvent( verticalScrollBar(), e);
}
}
Greetings,
Wilco
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic