[Okular-devel] Re: About 265002 (Unreachable code in okular/ui/pageview.cpp (related to drag scroll))

Денис Песоцкий denis at kde.ru
Tue Feb 1 02:00:02 CET 2011


There is also hardcoded margin. Here is better code (added margin and
removed stupid check):

                else if ( !d->mouseGrabPos.isNull() )
                {
                    setCursor( Qt::SizeAllCursor );

                    QPoint mousePos = e->globalPos();
                    QPoint delta = d->mouseGrabPos - mousePos;

                    const QRect mouseContainer =
KGlobalSettings::desktopGeometry( this );
                    static const int margin = 5;
                    // wrap mouse from top to bottom
                    if ( mousePos.y() < mouseContainer.top() + margin &&
                         verticalScrollBar()->value() <
verticalScrollBar()->maximum() - 2*margin )
                    {
                        mousePos.setY( mouseContainer.bottom() - margin );
                        QCursor::setPos( mousePos );
                    }
                    // wrap mouse from bottom to top
                    else if ( mousePos.y() > mouseContainer.bottom() - margin &&
                              verticalScrollBar()->value() > 2*margin )
                    {
                        mousePos.setY( mouseContainer.top() + margin );
                        QCursor::setPos( mousePos );
                    }
                    // remember last position
                    d->mouseGrabPos = mousePos;

                    // scroll page by position increment

horizontalScrollBar()->setValue(horizontalScrollBar()->value() +
delta.x());

verticalScrollBar()->setValue(verticalScrollBar()->value() +
delta.y());
                }
            }


More information about the Okular-devel mailing list