mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
LocationCompleterView: Make PageUp/Down skip over 5 entries
Instead of default behavior (one screen = 12 entries) which is too much.
This commit is contained in:
parent
a0472177c2
commit
486b6b9463
@ -273,6 +273,11 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
|
case Qt::Key_PageUp: {
|
||||||
|
if (keyEvent->modifiers() != Qt::NoModifier) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const int step = keyEvent->key() == Qt::Key_PageUp ? 5 : 1;
|
||||||
if (!idx.isValid() || idx == visitSearchIdx) {
|
if (!idx.isValid() || idx == visitSearchIdx) {
|
||||||
int rowCount = model()->rowCount();
|
int rowCount = model()->rowCount();
|
||||||
QModelIndex lastIndex = model()->index(rowCount - 1, 0);
|
QModelIndex lastIndex = model()->index(rowCount - 1, 0);
|
||||||
@ -280,11 +285,17 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event)
|
|||||||
} else if (idx.row() == 0) {
|
} else if (idx.row() == 0) {
|
||||||
m_view->setCurrentIndex(QModelIndex());
|
m_view->setCurrentIndex(QModelIndex());
|
||||||
} else {
|
} else {
|
||||||
m_view->setCurrentIndex(model()->index(idx.row() - 1, 0));
|
m_view->setCurrentIndex(model()->index(qMax(0, idx.row() - step), 0));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Down:
|
||||||
|
case Qt::Key_PageDown: {
|
||||||
|
if (keyEvent->modifiers() != Qt::NoModifier) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const int step = keyEvent->key() == Qt::Key_PageDown ? 5 : 1;
|
||||||
if (!idx.isValid()) {
|
if (!idx.isValid()) {
|
||||||
QModelIndex firstIndex = model()->index(0, 0);
|
QModelIndex firstIndex = model()->index(0, 0);
|
||||||
m_view->setCurrentIndex(firstIndex);
|
m_view->setCurrentIndex(firstIndex);
|
||||||
@ -292,9 +303,10 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event)
|
|||||||
m_view->setCurrentIndex(visitSearchIdx);
|
m_view->setCurrentIndex(visitSearchIdx);
|
||||||
m_view->scrollToTop();
|
m_view->scrollToTop();
|
||||||
} else {
|
} else {
|
||||||
m_view->setCurrentIndex(model()->index(idx.row() + 1, 0));
|
m_view->setCurrentIndex(model()->index(qMin(model()->rowCount() - 1, idx.row() + step), 0));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
case Qt::Key_Delete:
|
case Qt::Key_Delete:
|
||||||
if (idx != visitSearchIdx && m_view->viewport()->rect().contains(m_view->visualRect(idx))) {
|
if (idx != visitSearchIdx && m_view->viewport()->rect().contains(m_view->visualRect(idx))) {
|
||||||
@ -303,14 +315,6 @@ bool LocationCompleterView::eventFilter(QObject* object, QEvent* event)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_PageUp:
|
|
||||||
case Qt::Key_PageDown:
|
|
||||||
if (keyEvent->modifiers() != Qt::NoModifier) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
QApplication::sendEvent(m_view, event);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
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 || underMouse()) {
|
if (idx != visitSearchIdx || underMouse()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user