From d99d5fbea76a79346761c0d8ce98a0719e5790d2 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 27 Aug 2011 20:12:03 +0200 Subject: Improve the autoscrolling for the rubberband selection This modifications will also allow to do an autoscrolling in an easy way for drag and drop operations (not fully implemented yet). --- src/kitemviews/kitemlistview.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/kitemviews/kitemlistview.h') diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h index 344221e40..9977e3639 100644 --- a/src/kitemviews/kitemlistview.h +++ b/src/kitemviews/kitemlistview.h @@ -89,6 +89,14 @@ public: void setVisibleRoles(const QHash& roles); QHash visibleRoles() const; + /** + * If set to true an automatic scrolling is done as soon as the + * mouse is moved near the borders of the view. Per default + * the automatic scrolling is turned off. + */ + void setAutoScroll(bool enabled); + bool autoScroll() const; + /** * @return Controller of the item-list. The controller gets * initialized by KItemListController::setView() and will @@ -124,6 +132,7 @@ public: void setStyleOption(const KItemListStyleOption& option); const KItemListStyleOption& styleOption() const; + /** @reimp */ virtual void setGeometry(const QRectF& rect); int itemAt(const QPointF& pos) const; @@ -207,13 +216,13 @@ private slots: KItemListViewAnimation::AnimationType type); void slotLayoutTimerFinished(); - void slotRubberBandStartPosChanged(); - void slotRubberBandEndPosChanged(); + void slotRubberBandPosChanged(); void slotRubberBandActivationChanged(bool active); /** - * Emits the signal scrollTo() with the corresponding target offset if the current - * mouse position is above the autoscroll-margin. + * Triggers the autoscrolling if autoScroll() is enabled by checking the + * current mouse position. If the mouse position is within the autoscroll + * margins a timer will be started that periodically triggers the autoscrolling. */ void triggerAutoScrolling(); @@ -289,7 +298,6 @@ private: static int calculateAutoScrollingIncrement(int pos, int size); private: - bool m_autoScrollMarginEnabled; bool m_grouped; int m_activeTransactions; // Counter for beginTransaction()/endTransaction() @@ -314,9 +322,11 @@ private: qreal m_oldOffset; qreal m_oldMaximumOffset; + bool m_skipAutoScrollForRubberBand; KItemListRubberBand* m_rubberBand; QPointF m_mousePos; + QTimer* m_autoScrollTimer; friend class KItemListController; }; -- cgit v1.3.1