From kde-commits Mon May 02 03:00:43 2005 From: Thomas Nagy Date: Mon, 02 May 2005 03:00:43 +0000 To: kde-commits Subject: kdeplayground-edu/kdissert/src/kdissert/canvasview Message-Id: <20050502030043.248F64A6 () office ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=111500285305468 CVS commit by tnagy: Fixed the scroll motion for zoom values inferior to 100% M +17 -5 DCanvasView.cpp 1.5 M +7 -1 DCanvasView.h 1.3 --- kdeplayground-edu/kdissert/src/kdissert/canvasview/DCanvasView.cpp #1.4:1.5 @@ -384,4 +384,5 @@ void DCanvasView::contentsMousePressEven } } + me->ignore(); } @@ -512,9 +513,6 @@ void DCanvasView::contentsMouseMoveEvent } - // in scroll mode .. well, scroll :) - if (m_currentAction == act_scroll) - { - scrollBy( m_moveStart.x() - p.x(), m_moveStart.y() - p.y() ); - } + // scrolling is done in mouseMoveEvent instead due to a loss of accuracy + me->ignore(); } @@ -613,4 +611,18 @@ void DCanvasView::contentsMouseReleaseEv } +void DCanvasView::mousePressEvent(QMouseEvent* me) +{ + m_scrollStart = me->pos() + QPoint( contentsX(), contentsY() ); +} + +void DCanvasView::mouseMoveEvent(QMouseEvent* me) +{ + if (m_currentAction == act_scroll) + { + QPoint newpoint = m_scrollStart - me->pos(); + setContentsPos( newpoint.x(), newpoint.y() ); + } +} + void DCanvasView::contentsWheelEvent( QWheelEvent* e ) { --- kdeplayground-edu/kdissert/src/kdissert/canvasview/DCanvasView.h #1.2:1.3 @@ -113,4 +113,8 @@ class DCanvasView : public QCanvasView, void keyReleaseEvent( QKeyEvent* ); + // used for scrolling + void mousePressEvent(QMouseEvent*); + void mouseMoveEvent(QMouseEvent*); + void drawContents( QPainter*, int, int, int, int); void dragEnterEvent(QDragEnterEvent *event); @@ -140,4 +144,6 @@ class DCanvasView : public QCanvasView, QPoint m_moveStart; + /// start of a scroll drag (more accurate) + QPoint m_scrollStart; /// popup menu for item properties