m_scrollerIsScrolling(false),
m_pinchGestureInProgress(false),
m_mousePress(false),
+ m_isTouchEvent(false),
m_selectionBehavior(NoSelection),
m_autoActivationBehavior(ActivationAndExpansion),
m_mouseDoubleClickAction(ActivateItemOnly),
m_autoActivationTimer(nullptr),
m_swipeGesture(Qt::CustomGesture),
m_twoFingerTapGesture(Qt::CustomGesture),
- m_lastSource(Qt::MouseEventNotSynthesized),
m_oldSelection(),
m_keyboardAnchorIndex(-1),
m_keyboardAnchorPos(0)
bool KItemListController::mousePressEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform)
{
m_mousePress = true;
- m_lastSource = event->source();
- if (event->source() == Qt::MouseEventSynthesizedByQt) {
+ if (event->source() == Qt::MouseEventSynthesizedByQt && m_isTouchEvent) {
return false;
}
m_view->m_tapAndHoldIndicator->setActive(false);
}
- if (event->source() == Qt::MouseEventSynthesizedByQt && !m_dragActionOrRightClick) {
+ if (event->source() == Qt::MouseEventSynthesizedByQt && !m_dragActionOrRightClick && m_isTouchEvent) {
return false;
}
bool KItemListController::mouseReleaseEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform)
{
m_mousePress = false;
+ m_isTouchEvent = false;
if (!m_view) {
return false;
}
KItemListRubberBand* rubberBand = m_view->rubberBand();
- if (event->source() == Qt::MouseEventSynthesizedByQt && !rubberBand->isActive()) {
+ if (event->source() == Qt::MouseEventSynthesizedByQt && !rubberBand->isActive() && m_isTouchEvent) {
return false;
}
Q_UNUSED(transform)
m_mousePress = false;
+ m_isTouchEvent = false;
if (!m_model || !m_view) {
return false;
return accepted;
}
+bool KItemListController::touchBeginEvent(QGestureEvent* event, const QTransform& transform)
+{
+ Q_UNUSED(event)
+ Q_UNUSED(transform)
+
+ m_isTouchEvent = true;
+ return false;
+}
+
void KItemListController::tapTriggered(QTapGesture* tap, const QTransform& transform)
{
static bool scrollerWasActive = false;
m_dragActionOrRightClick = false;
m_isSwipeGesture = false;
m_pinchGestureInProgress = false;
- m_lastSource = Qt::MouseEventSynthesizedByQt;
scrollerWasActive = m_scrollerIsScrolling;
}
onPress(tap->hotSpot().toPoint(), tap->position().toPoint(), Qt::NoModifier, Qt::LeftButton);
onRelease(transform.map(tap->position()), Qt::NoModifier, Qt::LeftButton, true);
}
+ m_isTouchEvent = false;
}
}
{
//the Qt TabAndHold gesture is triggerable with a mouse click, we don't want this
- if (m_lastSource == Qt::MouseEventNotSynthesized) {
+ if (!m_isTouchEvent) {
return;
}
return resizeEvent(static_cast<QGraphicsSceneResizeEvent*>(event), transform);
case QEvent::Gesture:
return gestureEvent(static_cast<QGestureEvent*>(event), transform);
+ case QEvent::TouchBegin:
+ return touchBeginEvent();
default:
break;
}
bool wheelEvent(QGraphicsSceneWheelEvent* event, const QTransform& transform);
bool resizeEvent(QGraphicsSceneResizeEvent* event, const QTransform& transform);
bool gestureEvent(QGestureEvent* event, const QTransform& transform);
+ bool touchBeginEvent(QGestureEvent* event, const QTransform& transform);
void tapTriggered(QTapGesture* tap, const QTransform& transform);
void tapAndHoldTriggered(QGestureEvent* event, const QTransform& transform);
void pinchTriggered(QGestureEvent* event, const QTransform& transform);
bool m_scrollerIsScrolling;
bool m_pinchGestureInProgress;
bool m_mousePress;
+ bool m_isTouchEvent;
SelectionBehavior m_selectionBehavior;
AutoActivationBehavior m_autoActivationBehavior;
MouseDoubleClickAction m_mouseDoubleClickAction;
Qt::GestureType m_swipeGesture;
Qt::GestureType m_twoFingerTapGesture;
- Qt::MouseEventSource m_lastSource;
/**
* When starting a rubberband selection during a Shift- or Control-key has been