#include <QMouseEvent>
#include <QScrollBar>
#include <QTimer>
+#include <math.h>
DolphinViewAutoScroller::DolphinViewAutoScroller(QAbstractItemView* parent) :
QObject(parent),
m_horizontalScrollInc(0),
m_verticalScrollInc(0),
m_itemView(parent),
- m_timer()
+ m_timer(0)
{
m_itemView->setAutoScroll(false);
m_itemView->viewport()->installEventFilter(this);
{
}
+bool DolphinViewAutoScroller::isActive() const
+{
+ return m_timer->isActive();
+}
+
bool DolphinViewAutoScroller::eventFilter(QObject* watched, QEvent* event)
{
if (watched == m_itemView->viewport()) {
{
int inc = 0;
- const int minSpeed = 2;
- const int maxSpeed = 32;
- const int speedLimiter = 8;
- const int autoScrollBorder = 32;
+ const int minSpeed = 4;
+ const int maxSpeed = 768;
+ const int speedLimiter = 48;
+ const int autoScrollBorder = 64;
if (cursorPos < autoScrollBorder) {
- inc = -minSpeed + (cursorPos - autoScrollBorder) / speedLimiter;
+ inc = -minSpeed + qAbs(cursorPos - autoScrollBorder) * (cursorPos - autoScrollBorder) / speedLimiter;
if (inc < -maxSpeed) {
inc = -maxSpeed;
}
} else if (cursorPos > rangeSize - autoScrollBorder) {
- inc = minSpeed + (cursorPos - rangeSize + autoScrollBorder) / speedLimiter;
+ inc = minSpeed + qAbs(cursorPos - rangeSize + autoScrollBorder) * (cursorPos - rangeSize + autoScrollBorder) / speedLimiter;
if (inc > maxSpeed) {
inc = maxSpeed;
}