#include <QObject>
class QAbstractItemView;
+class QModelIndex;
class QTimer;
/**
public:
DolphinViewAutoScroller(QAbstractItemView* parent);
virtual ~DolphinViewAutoScroller();
-
+ bool isActive() const;
+
+ /**
+ * Must be invoked by the parent item view, when QAbstractItemView::currentChanged()
+ * has been called. Assures that the current item stays visible when it has been
+ * changed by the keyboard.
+ */
+ void handleCurrentIndexChange(const QModelIndex& current, const QModelIndex& previous);
+
protected:
virtual bool eventFilter(QObject* watched, QEvent* event);
private slots:
void scrollViewport();
- void scrollToCurrentIndex();
-
+
private:
void triggerAutoScroll();
void stopAutoScroll();
-
+
/**
- * Calculates the scroll increment m_scrollInc dependent from
+ * Calculates the scroll increment dependent from
* the cursor position \a cursorPos and the range 0 - \a rangeSize - 1.
*/
- void calculateScrollIncrement(int cursorPos, int rangeSize);
-
+ int calculateScrollIncrement(int cursorPos, int rangeSize) const;
+
private:
bool m_rubberBandSelection;
- int m_scrollInc;
+ bool m_keyPressed;
+ int m_horizontalScrollInc;
+ int m_verticalScrollInc;
QAbstractItemView* m_itemView;
QTimer* m_timer;
};