kopete/libkopete
kopetelistview.cpp
Go to the documentation of this file.
179 ListView::~ListView()
235 else if ( (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) && item && item->isVisible() )
257 // What is this: This hack enables smooth scrolling, and intercepts all events that goes to scrollbar. Unless we do so, scrollbar
258 // will react to the mouse clicks and go _immedietly_ to the target value (i.e. next page) then when the smoothscroll
259 // takes effect the scrollbar slider will start to scroll smoothly, so the first slider movement due to scrollbar
262 // Bugs: * Scroll bar loses it's onMouseOver color when we drag the scroll bar and move the mouse outside of the slider
263 // * Next/Prev page areas don't get mouse clicks, some styles gives some feedback on such an event
264 // and that feedback is unintentionally avoided by this hack. Many many contraints caused this choice.
265 // * Horizontal scroll bar seems to flicker when the scrollbars are being showed in auto-hide mode
281 // If we want to enable smooth scrolling when item has changed with keypresses etc, we need this
282 connect( this, SIGNAL(currentChanged(Q3ListViewItem*)), this, SLOT(slotCurrentChanged(Q3ListViewItem*)) );
301 disconnect( this, SIGNAL(currentChanged(Q3ListViewItem*)), this, SLOT(slotCurrentChanged(Q3ListViewItem*)) );
396 // Find how war we are away from the target scroll bar value and divide it by our constant (it can be both negative/positive)
397 double offset = static_cast<double>( ( d->targetScrollBarValue - d->metaScrollBarCurrentValue ) / d->scrollBarAccelerationConstant );
407 // Wait for X more amount of time after the continuous button press actually begins, the start to accelerate the scrolling linearly
408 double acceleration = static_cast<double>( ( d->smoothScrollContinuousCounter - d->continuousLinePressTimerWait * 2 ) ) /
417 if( d->smoothScrollContinuousCounter++ > d->continuousLinePressTimerWait ) // pressed long enough ?
419 d->targetScrollBarValue -= d->smoothScrollingLineStep * acceleration; // if so start continuous scrolling
421 d->targetScrollBarValue = qMax( d->targetScrollBarValue, ( double ) verticalScrollBar()->minimum() );
426 if( d->smoothScrollContinuousCounter++ > d->continuousLinePressTimerWait ) // pressed long enough ?
428 d->targetScrollBarValue += d->smoothScrollingLineStep * acceleration; // if so start continuous scrolling
430 d->targetScrollBarValue = qMin( d->targetScrollBarValue, ( double )verticalScrollBar()->maximum() );
438 // Wait for X more amount of time after the continuous button press actually begins, the start to accelerate the scrolling linearly
439 double acceleration = static_cast<double>( ( d->smoothScrollContinuousCounter - d->continuousPagePressTimerWait * 2 ) ) /
447 if( d->smoothScrollContinuousCounter++ > d->continuousPagePressTimerWait ) // pressed long enough ?
449 d->targetScrollBarValue -= d->smoothScrollingPageStep + acceleration; // if so start continuous scrolling
450 d->targetScrollBarValue = qMax( d->targetScrollBarValue, ( double )verticalScrollBar()->minimum() );
455 if( d->smoothScrollContinuousCounter++ > d->continuousPagePressTimerWait ) // pressed long enough ?
457 d->targetScrollBarValue += d->smoothScrollingPageStep * acceleration; // if so start continuous scrolling
458 d->targetScrollBarValue = qMin( d->targetScrollBarValue, ( double )verticalScrollBar()->maximum() );
477 // OK, this is a wheel event, let's get our QWheelEvent in an unsafe way, due to a bug in RTTI of QT.
500 QRect sliderRect = style()->subControlRect( QStyle::CC_ScrollBar, &qsos, QStyle::SC_ScrollBarSlider, 0 );
508 // This is masking the previous page, which is between the upper previous line button and the slider
529 // OK, now we can understand which partion of the scroll bar is clicked, and do the requested thing
530 // animated. Then set the step sizes to zero, and pass the event to the slider, so that user can
541 d->targetScrollBarValue = qMax( d->targetScrollBarValue, ( double )verticalScrollBar()->minimum() );
547 d->targetScrollBarValue = qMax( d->targetScrollBarValue, ( double )verticalScrollBar()->minimum() );
552 d->targetScrollBarValue = qMin( d->targetScrollBarValue, ( double )verticalScrollBar()->maximum() );
557 d->targetScrollBarValue = qMin( d->targetScrollBarValue, ( double )verticalScrollBar()->maximum() );
573 // Update the drag start value so in the next MouseMove event we can calculate new movement distance
578 QRect sliderRect = style()->subControlRect( QStyle::CC_ScrollBar, &qsos, QStyle::SC_ScrollBarSlider, 0 );
581 d->targetScrollBarValue += static_cast<int>( static_cast<double>( ( bar->maximum() / scale ) * delta ) );
612 return false; // Pass the release event to the scroll bar, which will put the buttons in off-state
638 d->targetScrollBarValue -= ( d->smoothAutoScrollOffset - event->pos().y() ) * d->scrollBarAccelerationConstant / 3;
642 d->targetScrollBarValue += ( event->pos().y() - visibleHeight() + d->smoothAutoScrollOffset ) * d->scrollBarAccelerationConstant / 3;
645 d->targetScrollBarValue = qMax( d->targetScrollBarValue, ( double )verticalScrollBar()->minimum() );
646 d->targetScrollBarValue = qMin( d->targetScrollBarValue, ( double )verticalScrollBar()->maximum() );
662 d->targetScrollBarValue = ( event->y() - offset ) * ( static_cast<double>(verticalScrollBar()->maximum()) /
670 d->scrollAutoHideCounter = d->scrollAutoHideTimeout; // Mouse left the contact list, hide it after timeout
680 uint leftMargin = this->treeStepSize() * ( item->depth() + ( this->rootIsDecorated() ? 1 : 0 ) ) + itemMargin();
700 // kDebug( 14000 ) << "Unhandled event: [" << o << "][" << o->name() << "][" << o->metaObject()->className() << "][" << e->type() << "]";
710 // If the current item changed due to mouse click then don't center it in the listview. Do this just for key presses.
712 d->targetScrollBarValue = itemPos(item) - static_cast<double>(visibleHeight()/2.0) + item->height();
714 d->targetScrollBarValue = qMax( d->targetScrollBarValue, ( double )verticalScrollBar()->minimum() );
715 d->targetScrollBarValue = qMin( d->targetScrollBarValue, ( double )verticalScrollBar()->maximum() );
bool scrollAutoHide() const
Gets scroll auto hide feature status.
Definition: kopetelistview.cpp:350
int scrollAutoHideTimeout() const
Gets the scroll bar auto-hide timeout value.
Definition: kopetelistview.cpp:360
List-view item composed of Component items.
Definition: kopetelistviewitem.h:396
double smoothScrollingTimerInterval() const
Gets the current update interval.
Definition: kopetelistview.cpp:322
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.