mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
LocationCompleterView: Completely remove the hovered index tracking logic
This commit is contained in:
parent
6bceef43e2
commit
c3bead5ed7
@ -185,7 +185,7 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event)
|
|||||||
|
|
||||||
case Qt::Key_Shift:
|
case Qt::Key_Shift:
|
||||||
// don't switch if there is no hovered or selected index to not disturb typing
|
// 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);
|
m_delegate->setShowSwitchToTab(false);
|
||||||
viewport()->update();
|
viewport()->update();
|
||||||
return true;
|
return true;
|
||||||
@ -251,54 +251,34 @@ void LocationCompleterView::close()
|
|||||||
QListView::hide();
|
QListView::hide();
|
||||||
verticalScrollBar()->setValue(0);
|
verticalScrollBar()->setValue(0);
|
||||||
|
|
||||||
m_hoveredIndex = QPersistentModelIndex();
|
|
||||||
m_delegate->setShowSwitchToTab(true);
|
m_delegate->setShowSwitchToTab(true);
|
||||||
|
|
||||||
emit closed();
|
emit closed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationCompleterView::mouseMoveEvent(QMouseEvent* event)
|
void LocationCompleterView::mouseReleaseEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
if (m_ignoreNextMouseMove || !isVisible()) {
|
QModelIndex idx = indexAt(event->pos());
|
||||||
m_ignoreNextMouseMove = false;
|
if (!idx.isValid()) {
|
||||||
QListView::mouseMoveEvent(event);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex last = m_hoveredIndex;
|
Qt::MouseButton button = event->button();
|
||||||
QModelIndex atCursor = indexAt(mapFromGlobal(QCursor::pos()));
|
Qt::KeyboardModifiers modifiers = event->modifiers();
|
||||||
|
|
||||||
if (atCursor.isValid()) {
|
if (button == Qt::LeftButton && modifiers == Qt::NoModifier) {
|
||||||
m_hoveredIndex = atCursor;
|
emit indexActivated(idx);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last != atCursor) {
|
if (button == Qt::MiddleButton || (button == Qt::LeftButton && modifiers == Qt::ControlModifier)) {
|
||||||
viewport()->update();
|
emit indexCtrlActivated(idx);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QListView::mouseMoveEvent(event);
|
if (button == Qt::LeftButton && modifiers == Qt::ShiftModifier) {
|
||||||
}
|
emit indexShiftActivated(idx);
|
||||||
|
return;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QListView::mouseReleaseEvent(event);
|
QListView::mouseReleaseEvent(event);
|
||||||
|
@ -48,14 +48,12 @@ public slots:
|
|||||||
void close();
|
void close();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseMoveEvent(QMouseEvent* event);
|
|
||||||
void mouseReleaseEvent(QMouseEvent* event);
|
void mouseReleaseEvent(QMouseEvent* event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_ignoreNextMouseMove;
|
bool m_ignoreNextMouseMove;
|
||||||
|
|
||||||
LocationCompleterDelegate* m_delegate;
|
LocationCompleterDelegate* m_delegate;
|
||||||
QPersistentModelIndex m_hoveredIndex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LOCATIONCOMPLETERVIEW_H
|
#endif // LOCATIONCOMPLETERVIEW_H
|
||||||
|
Loading…
Reference in New Issue
Block a user