mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-02-05 11:08:27 -06:00
Improve focusing the filter line with keyboard shortcut
See issue #3439
This commit is contained in:
@@ -137,3 +137,9 @@ QString FilterTableHeader::filterValue(size_t column) const
|
||||
{
|
||||
return filterWidgets[column]->text();
|
||||
}
|
||||
|
||||
void FilterTableHeader::setFocusColumn(size_t column)
|
||||
{
|
||||
if(column < filterWidgets.size())
|
||||
filterWidgets.at(column)->setFocus();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ public:
|
||||
QSize sizeHint() const override;
|
||||
bool hasFilters() const {return (filterWidgets.size() > 0);}
|
||||
QString filterValue(size_t column) const;
|
||||
|
||||
void setFocusColumn(size_t column);
|
||||
|
||||
public slots:
|
||||
void generateFilters(size_t number, size_t number_of_hidden_filters = 1);
|
||||
void adjustPositions();
|
||||
|
||||
@@ -363,7 +363,22 @@ TableBrowser::TableBrowser(DBBrowserDB* _db, QWidget* parent) :
|
||||
// Restore cursor because in the ExtendedTableWidget it is changed to a hand when Ctrl+Shift
|
||||
// is pressed.
|
||||
QApplication::restoreOverrideCursor();
|
||||
ui->dataTable->horizontalHeader()->setFocus();
|
||||
FilterTableHeader* header = qobject_cast<FilterTableHeader*>(ui->dataTable->horizontalHeader());
|
||||
// Set the focus to the current column if valid, otherwise, set focus to the first visible
|
||||
// column.
|
||||
if(!header) {
|
||||
ui->dataTable->horizontalHeader()->setFocus();
|
||||
} else if(currentIndex().isValid()) {
|
||||
header->setFocusColumn(static_cast<size_t>(currentIndex().column()));
|
||||
} else {
|
||||
for(int col = 0; col < ui->dataTable->model()->columnCount(); col++)
|
||||
{
|
||||
if(!ui->dataTable->isColumnHidden(col)) {
|
||||
header->setFocusColumn(static_cast<size_t>(col));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
QShortcut* shortcutActionGlobalFilter = new QShortcut(QKeySequence("Ctrl+Alt+F"), this, nullptr, nullptr, Qt::WidgetWithChildrenShortcut);
|
||||
|
||||
Reference in New Issue
Block a user