From 2a60b64134c262a23cd0e9bb150118299e7e2035 Mon Sep 17 00:00:00 2001 From: Lukas Waslowski Date: Sun, 19 May 2024 12:37:59 +0000 Subject: [PATCH] WLibrarySidebar/LongHover: [DEBUG] Track and log mouse hover times --- src/widget/wlibrarysidebar.cpp | 6 ++++++ src/widget/wlibrarysidebar.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/widget/wlibrarysidebar.cpp b/src/widget/wlibrarysidebar.cpp index c62f4907f4e..09fc86335e7 100644 --- a/src/widget/wlibrarysidebar.cpp +++ b/src/widget/wlibrarysidebar.cpp @@ -93,6 +93,10 @@ void WLibrarySidebar::dragMoveEvent(QDragMoveEvent * event) { m_longHover.hoveringOnItem(index, pos); if (m_autoExpandIndex != index) { + if (m_activationTimer.isValid()) { + qDebug() << "Last timer" << m_activationTimer.elapsed() << m_autoExpandIndex; + } + m_activationTimer.start(); m_autoExpandIndex = index; if (isExpanded(index)) { setAutoExpandDelay(collapse_time); @@ -138,6 +142,8 @@ void WLibrarySidebar::dropEvent(QDropEvent* event) { auto pos = event->position().toPoint(); auto index = indexAt(pos); auto probableTarget = m_longHover.tryGuessIntendedTarget(index, pos); + qDebug() << "Dropping after" << m_activationTimer.elapsed() << index << probableTarget.item; + m_activationTimer.invalidate(); if (probableTarget.item != index) { // Use the target item that the user likely intended to hit, diff --git a/src/widget/wlibrarysidebar.h b/src/widget/wlibrarysidebar.h index 42203eb4dc5..18169358367 100644 --- a/src/widget/wlibrarysidebar.h +++ b/src/widget/wlibrarysidebar.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -48,6 +49,8 @@ class WLibrarySidebar : public QTreeView, public WBaseWidget { void focusSelectedIndex(); QModelIndex selectedIndex(); + QElapsedTimer m_activationTimer; + QElapsedTimer m_expirationTimer; QModelIndex m_autoExpandIndex; WLongHoverTracker m_longHover;