Improve focusing the filter line with keyboard shortcut II

- Focus the filter line when setting something as filter.
- Instead of stopping focus cycling at the end of the filter header, pass
  the focus up to the table.
- Change keyReleaseEvent to comply with documentation.

See issue #3439
This commit is contained in:
mgrojo
2023-08-19 20:36:56 +02:00
parent 506463860c
commit 85e6c13056
2 changed files with 13 additions and 2 deletions

View File

@@ -880,6 +880,7 @@ void ExtendedTableWidget::useAsFilter(const QString& filterOperator, bool binary
m_tableHeader->setFilter(column, value + filterOperator);
else
m_tableHeader->setFilter(column, filterOperator + value + operatorSuffix);
m_tableHeader->setFocusColumn(column);
}
void ExtendedTableWidget::duplicateUpperCell()

View File

@@ -67,20 +67,30 @@ void FilterLineEdit::delayedSignalTimerTriggered()
void FilterLineEdit::keyReleaseEvent(QKeyEvent* event)
{
bool actedUponKey = false;
if(event->key() == Qt::Key_Tab)
{
if(filterList && columnNumber < filterList->size() - 1)
{
filterList->at(columnNumber + 1)->setFocus();
event->accept();
} else {
QWidget* grandParent = parentWidget()->parentWidget();
// Pass focus to the table (grandparent).
// Parent would be the table header, which would cycle back to the first
// column (due to proxying).
if(grandParent)
grandParent->setFocus();
}
actedUponKey = true;
} else if(event->key() == Qt::Key_Backtab) {
if(filterList && columnNumber > 0)
{
filterList->at(columnNumber - 1)->setFocus();
event->accept();
actedUponKey = true;
}
}
if(!actedUponKey)
QLineEdit::keyReleaseEvent(event);
}
void FilterLineEdit::focusInEvent(QFocusEvent* event)