Full-text search: Handle "Enter" key in headwords list

and focus dialog on Ctrl+Shift+F
This commit is contained in:
Abs62 2014-04-23 17:47:56 +04:00
parent 88c40141d0
commit 948db01572
3 changed files with 23 additions and 1 deletions

View file

@ -189,6 +189,8 @@ FullTextSearchDialog::FullTextSearchDialog( QWidget * parent,
connect( ui.OKButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( ui.cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
ui.headwordsView->installEventFilter( this );
delegate = new WordListItemDelegate( ui.headwordsView->itemDelegate() );
if( delegate )
ui.headwordsView->setItemDelegate( delegate );
@ -455,6 +457,20 @@ void FullTextSearchDialog::updateDictionaries()
showDictNumbers();
}
bool FullTextSearchDialog::eventFilter( QObject * obj, QEvent * ev )
{
if( obj == ui.headwordsView && ev->type() == QEvent::KeyPress )
{
QKeyEvent * kev = static_cast< QKeyEvent * >( ev );
if( kev->key() == Qt::Key_Return || kev->key() == Qt::Key_Enter )
{
itemClicked( ui.headwordsView->currentIndex() );
return true;
}
}
return QDialog::eventFilter( obj, ev );
}
/// HeadwordsListModel
int HeadwordsListModel::rowCount( QModelIndex const & ) const

View file

@ -192,6 +192,9 @@ public:
void stopSearch();
protected:
bool eventFilter( QObject * obj, QEvent * ev );
private:
Ui::FullTextSearchDialog ui;
QList< FtsHeadword > results;

View file

@ -4001,7 +4001,10 @@ void MainWindow::showFullTextSearchDialog()
: groupInstances[ groupList->currentIndex() ].id;
ftsDlg->setCurrentGroup( group );
ftsDlg->show();
if( !ftsDlg ->isVisible() )
ftsDlg->show();
else
ftsDlg->activateWindow();
}
void MainWindow::closeFullTextSearchDialog()