}
}
- if (event->type() == QEvent::TouchBegin && _lastTouchStart < QDateTime::currentMSecsSinceEpoch() - 1000) { //(slow) double tab = normal behaviour = select text. 1000 ok?
+ if (event->type() == QEvent::TouchBegin) {
setDragMode(QGraphicsView::ScrollHandDrag);
setInteractive(false);
- _lastTouchStart = QDateTime::currentMSecsSinceEpoch();
if (verticalScrollBar()->isVisible()) return true; //if scrollbar is not visible we need to request backlog below
}
#endif
setDragMode(QGraphicsView::NoDrag);
setInteractive(true);
+ _firstTouchUpdateHappened = false;
return true;
}
+ if (event->type() == QEvent::TouchUpdate) {
+ if (!_firstTouchUpdateHappened) {
+ QTouchEvent::TouchPoint p = ((QTouchEvent*)event)->touchPoints().at(0);
+ double dx = abs (p.lastPos().x() - p.pos().x());
+ double dy = abs (p.lastPos().y() - p.pos().y());
+ if (dx > dy) {
+ setDragMode(QGraphicsView::NoDrag);
+ setInteractive(true);
+ }
+ _firstTouchUpdateHappened = true;
+ }
+ }
+
if (event->type() == QEvent::Wheel || event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate) {
if (!verticalScrollBar()->isVisible()) {
scene()->requestBacklog();
int _scrollOffset;
bool _invalidateFilter;
QSet<ChatLine *> _linesWithCache;
- qint64 _lastTouchStart = 0;
+ bool _firstTouchUpdateHappened = false;
};
bool TreeViewTouch::event(QEvent *event) {
- if (event->type() == QEvent::TouchBegin && _lastTouchStart < QDateTime::currentMSecsSinceEpoch() - 1000) { //(slow) double tab = normal behaviour = select multiple. 1000 ok?
+ if (event->type() == QEvent::TouchBegin) {
_touchScrollInProgress = true;
- _lastTouchStart = QDateTime::currentMSecsSinceEpoch();
setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
return true;
}
if (event->type() == QEvent::TouchUpdate && _touchScrollInProgress) {
QTouchEvent::TouchPoint p = ((QTouchEvent*)event)->touchPoints().at(0);
+ if (!_firstTouchUpdateHappened) {
+ double dx = abs(p.lastPos().x() - p.pos().x());
+ double dy = abs(p.lastPos().y() - p.pos().y());
+ if (dx > dy) {
+ _touchScrollInProgress = false;
+ }
+ _firstTouchUpdateHappened = true;
+ }
verticalScrollBar()->setValue(verticalScrollBar()->value() - (p.pos().y() - p.lastPos().y()));
return true;
}
if (event->type() == QEvent::TouchEnd) {
#endif
_touchScrollInProgress = false;
+ _firstTouchUpdateHappened = false;
return true;
}
virtual void mousePressEvent(QMouseEvent *event);
private:
- qint64 _lastTouchStart = 0;
bool _touchScrollInProgress = false;
+ bool _firstTouchUpdateHappened = false;
};
#endif
\ No newline at end of file