┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistview.h
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-08-18 23:11:16 +0200
committerPeter Penz <[email protected]>2011-08-18 23:14:30 +0200
commitdbe2152912cc58f1d2bfba187175ec0e4b3e4761 (patch)
tree91d622cc65b72e56082fa5d533dab5b9437403d3 /src/kitemviews/kitemlistview.h
parent63e82a2b3bba25fbfaa3d283264cc0c61d11cfe8 (diff)
Provide basic rubberband functionality
This is just a rough draft: The rubberband gets visible and an automatic scrolling is done if the autoscroll-margins have been reached. However currently no items get selected yet. Currently the autoscrolling has a severe bug if the scrollbars are manually changed before or after a rubberband selection.
Diffstat (limited to 'src/kitemviews/kitemlistview.h')
-rw-r--r--src/kitemviews/kitemlistview.h42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h
index 974a9baaf..e874957de 100644
--- a/src/kitemviews/kitemlistview.h
+++ b/src/kitemviews/kitemlistview.h
@@ -37,6 +37,7 @@ class KItemListWidgetCreatorBase;
class KItemListGroupHeader;
class KItemListGroupHeaderCreatorBase;
class KItemListSizeHintResolver;
+class KItemListRubberBand;
class KItemListViewAnimation;
class KItemListViewLayouter;
class KItemListWidget;
@@ -142,10 +143,15 @@ public:
void endTransaction();
bool isTransactionActive() const;
+ /**
+ * @reimp
+ */
+ virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+
signals:
- void offsetChanged(int current, int previous);
- void maximumOffsetChanged(int current, int previous);
- void scrollTo(int newOffset);
+ void offsetChanged(qreal current, qreal previous);
+ void maximumOffsetChanged(qreal current, qreal previous);
+ void scrollTo(qreal newOffset);
protected:
virtual void initializeItemListWidget(KItemListWidget* item);
@@ -164,6 +170,7 @@ protected:
virtual bool event(QEvent* event);
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
+ virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
QList<KItemListWidget*> visibleItemListWidgets() const;
@@ -180,6 +187,10 @@ private slots:
KItemListViewAnimation::AnimationType type);
void slotLayoutTimerFinished();
+ void slotRubberBandStartPosChanged();
+ void slotRubberBandEndPosChanged();
+ void slotRubberBandActivationChanged(bool active);
+
private:
enum LayoutAnimationHint
{
@@ -196,6 +207,8 @@ private:
void setController(KItemListController* controller);
void setModel(KItemModelBase* model);
+ KItemListRubberBand* rubberBand() const;
+
void updateLayout();
void doLayout(LayoutAnimationHint hint, int changedIndex, int changedCount);
void doGroupHeadersLayout(LayoutAnimationHint hint, int changedIndex, int changedCount);
@@ -241,7 +254,22 @@ private:
*/
void updateWidgetProperties(KItemListWidget* widget, int index);
+ /**
+ * Emits the signal scrollTo() with the corresponding target offset if the current
+ * mouse position is above the autoscroll-margin.
+ */
+ void triggerAutoScrolling();
+
+ /**
+ * Helper function for triggerAutoScrolling(). Returns the scroll increment
+ * that should be added to the offset() based on the available size \a size
+ * and the current mouse position \a pos. As soon as \a pos is inside
+ * the autoscroll-margin a value != 0 will be returned.
+ */
+ static int calculateAutoScrollingIncrement(int pos, int size);
+
private:
+ bool m_autoScrollMarginEnabled;
bool m_grouped;
int m_activeTransactions; // Counter for beginTransaction()/endTransaction()
@@ -263,8 +291,12 @@ private:
KItemListViewAnimation* m_animation;
QTimer* m_layoutTimer; // Triggers an asynchronous doLayout() call.
- int m_oldOffset;
- int m_oldMaximumOffset;
+ qreal m_oldOffset;
+ qreal m_oldMaximumOffset;
+
+ KItemListRubberBand* m_rubberBand;
+
+ QPointF m_mousePos;
friend class KItemListController;
};