From f6bdc212f512e679c21a11facf4c31f7b64bb013 Mon Sep 17 00:00:00 2001 From: sln Date: Wed, 23 Apr 2008 15:01:32 +0000 Subject: [PATCH] Searching in Object browser. Key press event is handled to search object by enter key pressing --- src/ObjBrowser/OB_FindDlg.cxx | 21 +++++++++++++++++++++ src/ObjBrowser/OB_FindDlg.h | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/src/ObjBrowser/OB_FindDlg.cxx b/src/ObjBrowser/OB_FindDlg.cxx index 5b07adc03..8242c06ea 100644 --- a/src/ObjBrowser/OB_FindDlg.cxx +++ b/src/ObjBrowser/OB_FindDlg.cxx @@ -31,6 +31,7 @@ OB_FindDlg::OB_FindDlg( QWidget* parent ) myToLast->setMaximumSize( w, h ); myNext->setMaximumSize( w, h ); myPrev->setMaximumSize( w, h ); + myNext->setDefault( true ); QHBoxLayout* l = new QHBoxLayout( btns, 5, 5 ); l->addWidget( myToFirst, 0 ); @@ -90,3 +91,23 @@ void OB_FindDlg::setSearch( OB_ObjSearch* s ) { mySearch = s; } + +void OB_FindDlg::keyPressEvent( QKeyEvent* e ) +{ + if ( e->key() == Key_Enter || e->key() == Key_Return ) + { + mySearch->setPattern( + myData->text(), myIsRegExp->isChecked(), myIsCaseSens->isChecked() ); + OB_ListItem* it = mySearch->findNext(); + if( it ) + { + mySearch->browser()->setSelected( it->dataObject(), false ); + mySearch->browser()->listView()->ensureItemVisible( it ); + } + } + + QGroupBox::keyPressEvent( e ); +} + + + diff --git a/src/ObjBrowser/OB_FindDlg.h b/src/ObjBrowser/OB_FindDlg.h index 4c8230d81..909b9ce34 100644 --- a/src/ObjBrowser/OB_FindDlg.h +++ b/src/ObjBrowser/OB_FindDlg.h @@ -20,6 +20,10 @@ public: OB_ObjSearch* getSearch() const; void setSearch( OB_ObjSearch* ); +protected: + + virtual void keyPressEvent( QKeyEvent* e ); + private slots: void onFind(); void onClose(); -- 2.39.2