diff --git a/src/lib/navigation/completer/locationcompleterview.cpp b/src/lib/navigation/completer/locationcompleterview.cpp index 58e6e7c8b..549cf67c8 100644 --- a/src/lib/navigation/completer/locationcompleterview.cpp +++ b/src/lib/navigation/completer/locationcompleterview.cpp @@ -185,7 +185,7 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event) case Qt::Key_Shift: // don't switch if there is no hovered or selected index to not disturb typing - if (idx != visitSearchIdx || m_hoveredIndex.isValid()) { + if (idx != visitSearchIdx || underMouse()) { m_delegate->setShowSwitchToTab(false); viewport()->update(); return true; @@ -251,54 +251,34 @@ void LocationCompleterView::close() QListView::hide(); verticalScrollBar()->setValue(0); - m_hoveredIndex = QPersistentModelIndex(); m_delegate->setShowSwitchToTab(true); emit closed(); } -void LocationCompleterView::mouseMoveEvent(QMouseEvent* event) +void LocationCompleterView::mouseReleaseEvent(QMouseEvent* event) { - if (m_ignoreNextMouseMove || !isVisible()) { - m_ignoreNextMouseMove = false; - QListView::mouseMoveEvent(event); + QModelIndex idx = indexAt(event->pos()); + if (!idx.isValid()) { return; } - QModelIndex last = m_hoveredIndex; - QModelIndex atCursor = indexAt(mapFromGlobal(QCursor::pos())); + Qt::MouseButton button = event->button(); + Qt::KeyboardModifiers modifiers = event->modifiers(); - if (atCursor.isValid()) { - m_hoveredIndex = atCursor; + if (button == Qt::LeftButton && modifiers == Qt::NoModifier) { + emit indexActivated(idx); + return; } - if (last != atCursor) { - viewport()->update(); + if (button == Qt::MiddleButton || (button == Qt::LeftButton && modifiers == Qt::ControlModifier)) { + emit indexCtrlActivated(idx); + return; } - QListView::mouseMoveEvent(event); -} - -void LocationCompleterView::mouseReleaseEvent(QMouseEvent* event) -{ - if (m_hoveredIndex.isValid()) { - Qt::MouseButton button = event->button(); - Qt::KeyboardModifiers modifiers = event->modifiers(); - - if (button == Qt::LeftButton && modifiers == Qt::NoModifier) { - emit indexActivated(m_hoveredIndex); - return; - } - - if (button == Qt::MiddleButton || (button == Qt::LeftButton && modifiers == Qt::ControlModifier)) { - emit indexCtrlActivated(m_hoveredIndex); - return; - } - - if (button == Qt::LeftButton && modifiers == Qt::ShiftModifier) { - emit indexShiftActivated(m_hoveredIndex); - return; - } + if (button == Qt::LeftButton && modifiers == Qt::ShiftModifier) { + emit indexShiftActivated(idx); + return; } QListView::mouseReleaseEvent(event); diff --git a/src/lib/navigation/completer/locationcompleterview.h b/src/lib/navigation/completer/locationcompleterview.h index c17691c36..67dfa8889 100644 --- a/src/lib/navigation/completer/locationcompleterview.h +++ b/src/lib/navigation/completer/locationcompleterview.h @@ -48,14 +48,12 @@ public slots: void close(); protected: - void mouseMoveEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event); private: bool m_ignoreNextMouseMove; LocationCompleterDelegate* m_delegate; - QPersistentModelIndex m_hoveredIndex; }; #endif // LOCATIONCOMPLETERVIEW_H