Skip to content

Commit

Permalink
WLibrarySidebar/LongHover: [DEBUG] Track and log mouse hover times
Browse files Browse the repository at this point in the history
  • Loading branch information
cr7pt0gr4ph7 committed Oct 17, 2024
1 parent a6c2d1b commit 2a60b64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/widget/wlibrarysidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/widget/wlibrarysidebar.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <QBasicTimer>
#include <QElapsedTimer>
#include <QModelIndex>
#include <QTreeView>

Expand Down Expand Up @@ -48,6 +49,8 @@ class WLibrarySidebar : public QTreeView, public WBaseWidget {
void focusSelectedIndex();
QModelIndex selectedIndex();

QElapsedTimer m_activationTimer;
QElapsedTimer m_expirationTimer;
QModelIndex m_autoExpandIndex;

WLongHoverTracker<QModelIndex> m_longHover;
Expand Down

0 comments on commit 2a60b64

Please sign in to comment.