Bug 107803

Summary: No scrolling when selection reaches border
Product: [Applications] kpdf Reporter: Kyryll A Mirnenko aka Mirya <mirya>
Component: generalAssignee: Albert Astals Cid <aacid>
Status: RESOLVED FIXED    
Severity: wishlist CC: philipp.sternberg
Priority: NOR    
Version: 0.4   
Target Milestone: ---   
Platform: unspecified   
OS: FreeBSD   
Latest Commit: Version Fixed In:

Description Kyryll A Mirnenko aka Mirya 2005-06-20 21:35:17 UTC
Version:           0.4 (using KDE 3.4.0, compiled sources)
Compiler:          gcc version 3.4.2 [FreeBSD] 20040728
OS:                FreeBSD (i386) release 5.4-RELEASE-p1

When selecting an image rectange & reaching the border of the view the view should be scrolled in aprop. direction to allow selection expadning beneath this limit.

Some more issues w/ selection:
1) it's not cleared up properly when making a selection (so actions menu popups) and then immediately presses a scrollbar up/down buttons - the menu & selection disapper but leave some garbage on the view

2) would be nice to have "Save/copy the selection w/ scale ...(100%, 200%)" item aded to that menu
Comment 1 Helder Ribeiro 2006-11-10 02:17:16 UTC
I don't know about the other two problems, but I was just going to post something about scrolling myself. I noticed the same problem. You start selecting down a page, reach the end of the screen, and it doesn't scroll naturally to keep selecting, as one would expect. I think that's a very important feature to have. Thanks.
Comment 2 Albert Astals Cid 2006-11-19 23:32:56 UTC
SVN commit 606296 by aacid:

Fix "No scrolling when selection reaches border"
BUGS: 107803


 M  +29 -0     pageview.cpp  
 M  +3 -1      pageview.h  


--- branches/KDE/3.5/kdegraphics/kpdf/ui/pageview.cpp #606295:606296
@@ -97,6 +97,10 @@
     bool blockPixmapsRequest;           // prevent pixmap requests
     PageViewMessage * messageWindow;    // in pageviewutils.h
 
+    // drag scroll
+    QPoint dragScrollVector;
+    QTimer dragScrollTimer;
+
     // actions
     KToggleAction * aMouseNormal;
     KToggleAction * aMouseSelect;
@@ -158,6 +162,7 @@
 
     // conntect the padding of the viewport to pixmaps requests
     connect( this, SIGNAL(contentsMoving(int, int)), this, SLOT(slotRequestVisiblePixmaps(int, int)) );
+    connect( &d->dragScrollTimer, SIGNAL(timeout()), this, SLOT(slotDragScroll()) );
 
     // set a corner button to resize the view to the page size
 //    QPushButton * resizeButton = new QPushButton( viewport() );
@@ -897,6 +902,9 @@
 
 void PageView::contentsMouseReleaseEvent( QMouseEvent * e )
 {
+    // stop the drag scrolling
+    d->dragScrollTimer.stop();
+
     // don't perform any mouse action when no document is shown
     if ( d->items.isEmpty() )
     {
@@ -1377,6 +1385,20 @@
 
 void PageView::selectionEndPoint( int x, int y )
 {
+    if (x < contentsX()) d->dragScrollVector.setX(x - contentsX());
+    else if (contentsX() + viewport()->width() < x) d->dragScrollVector.setX(x - contentsX() - viewport()->width());
+    else d->dragScrollVector.setX(0);
+
+    if (y < contentsY()) d->dragScrollVector.setY(y - contentsY());
+    else if (contentsY() + viewport()->height() < y) d->dragScrollVector.setY(y - contentsY() - viewport()->height());
+    else d->dragScrollVector.setY(0);
+
+    if (d->dragScrollVector != QPoint(0, 0))
+    {
+       if (!d->dragScrollTimer.isActive()) d->dragScrollTimer.start(100);
+    }
+    else d->dragScrollTimer.stop();
+
     // clip selection to the viewport
     QRect viewportRect( contentsX(), contentsY(), visibleWidth(), visibleHeight() );
     x = QMAX( QMIN( x, viewportRect.right() ), viewportRect.left() );
@@ -1910,6 +1932,13 @@
     scrollBy( 0, d->scrollIncrement > 0 ? scrollOffset[ index ] : -scrollOffset[ index ] );
 }
 
+void PageView::slotDragScroll()
+{
+    scrollBy(d->dragScrollVector.x(), d->dragScrollVector.y());
+    QPoint p = viewportToContents( mapFromGlobal( QCursor::pos() ) );
+    selectionEndPoint( p.x(), p.y() );
+}
+
 void PageView::findAheadStop()
 {
     d->typeAheadActive = false;
--- branches/KDE/3.5/kdegraphics/kpdf/ui/pageview.h #606295:606296
@@ -118,9 +118,11 @@
         void slotMoveViewport();
         // activated by the autoscroll timer (Shift+Up/Down keys)
         void slotAutoScoll();
+        // activated by the dragScroll timer
+        void slotDragScroll();
         // type-ahead find timeout
         void findAheadStop();
-        // sow the welcome message
+        // show the welcome message
         void slotShowWelcome();
 
         // connected to local actions (toolbar, menu, ..)