From e4d0b3e80a2039d77c723ea3c00c539c58e76fa2 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 26 Dec 2007 15:13:15 +0000 Subject: [PATCH] *** empty log message *** --- src/LightApp/LightApp_Application.cxx | 2 +- src/ObjBrowser/Makefile.am | 9 +-- src/ObjBrowser/OB_Browser.cxx | 65 ++++++++++----- src/ObjBrowser/OB_Browser.h | 9 ++- src/ObjBrowser/OB_FindDlg.cxx | 110 -------------------------- src/ObjBrowser/OB_FindDlg.h | 31 -------- 6 files changed, 57 insertions(+), 169 deletions(-) delete mode 100644 src/ObjBrowser/OB_FindDlg.cxx delete mode 100644 src/ObjBrowser/OB_FindDlg.h diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 39bcd0008..d9be2ca58 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -437,7 +437,7 @@ void LightApp_Application::createActions() //! Preferences createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(), tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ), - Qt::CTRL+Qt::Key_F, desk, false, this, SLOT( onPreferences() ) ); + 0, desk, false, this, SLOT( onPreferences() ) ); //! Help for modules int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 ); diff --git a/src/ObjBrowser/Makefile.am b/src/ObjBrowser/Makefile.am index 609e842f9..9d427d9c7 100755 --- a/src/ObjBrowser/Makefile.am +++ b/src/ObjBrowser/Makefile.am @@ -27,16 +27,14 @@ lib_LTLIBRARIES = libObjBrowser.la salomeinclude_HEADERS= \ OB.h \ - OB_Browser.h \ - OB_FindDlg.h + OB_Browser.h # OB_ListItem.h \ OB_ListView.h OB_Filter.h dist_libObjBrowser_la_SOURCES= \ - OB_Browser.cxx \ - OB_FindDlg.cxx + OB_Browser.cxx # OB_ListView.cxx OB_ListItem.cxx \ @@ -44,8 +42,7 @@ dist_libObjBrowser_la_SOURCES= \ OB_Filter.cxx MOC_FILES= \ - OB_Browser_moc.cxx \ - OB_FindDlg_moc.cxx + OB_Browser_moc.cxx # OB_ListView_moc.cxx diff --git a/src/ObjBrowser/OB_Browser.cxx b/src/ObjBrowser/OB_Browser.cxx index 95733fe01..af5b48288 100755 --- a/src/ObjBrowser/OB_Browser.cxx +++ b/src/ObjBrowser/OB_Browser.cxx @@ -21,13 +21,13 @@ // #include "OB_Browser.h" -#include "OB_FindDlg.h" //#include "OB_Filter.h" //#include "OB_ListItem.h" //#include "OB_ListView.h" #include +#include //#include #include @@ -138,13 +138,16 @@ OB_Browser::OB_Browser( QWidget* parent, QAbstractItemModel* model ) myView->setSelectionMode( QAbstractItemView::ExtendedSelection ); myView->setAllColumnsShowFocus( true ); - myFindDlg = new OB_FindDlg( this ); - myFindDlg->hide(); + mySearchTool = new QtxSearchTool( this, myView ); + mySearchTool->setFrameStyle( QFrame::NoFrame | QFrame::Plain ); + mySearchTool->setActivators( QtxSearchTool::StandardKey | QtxSearchTool::SlashKey ); + mySearchTool->setSearcher( new QtxTreeViewSearcher( myView ) ); QVBoxLayout* main = new QVBoxLayout( this ); main->addWidget( myView ); - main->addWidget( myFindDlg ); + main->addWidget( mySearchTool ); main->setMargin( 0 ); + main->setSpacing( 3 ); // TODO: decide what to do with tooltip //myShowToolTips = true; @@ -256,6 +259,41 @@ void OB_Browser::setSortMenuEnabled( const bool enabled ) myView->setSortMenuEnabled( enabled ); } +/*! + \brief Get search tool widget. + \return search tool widget + \sa isSearchToolEnabled(), setSearchToolEnabled() +*/ +QtxSearchTool* OB_Browser::searchTool() const +{ + return mySearchTool; +} + +/*! + \brief Check if search tool is enabled. + \return \c true if search tool is enabled + \sa setSearchToolEnabled(), searchTool() +*/ +bool OB_Browser::isSearchToolEnabled() const +{ + return mySearchTool->isEnabled(); +} + +/*! + \brief Enable/disable search tool. + \param enable pass \c true to enable search tool + \sa isSearchToolEnabled(), searchTool() +*/ +void OB_Browser::setSearchToolEnabled( const bool enable ) +{ + if ( mySearchTool->isEnabled() == enable ) + return; + + mySearchTool->setEnabled( enable ); + if ( !mySearchTool->isEnabled() ) + mySearchTool->hide(); +} + /*! \brief Get number of levels which should be automatically expanded when updating the data tree. @@ -820,16 +858,6 @@ void OB_Browser::onCollapseAll() } } -/*! - \brief Called when "Find" popup menu command is activated. - - Activates the find properties frame -*/ -void OB_Browser::onFind() -{ - myFindDlg->show(); -} - /*! SLOT: called if SUIT object is destroyed */ @@ -950,10 +978,11 @@ void OB_Browser::createPopupMenu( QMenu* menu ) if ( opened ) menu->addAction( tr( "MEN_COLLAPSE_ALL" ), this, SLOT( onCollapseAll() ) ); - menu->addSeparator(); - menu->addAction( tr( "MEN_FIND" ), this, SLOT( onFind() ) ); - - menu->addSeparator(); + if ( isSearchToolEnabled() ) { + menu->addSeparator(); + menu->addAction( tr( "MEN_FIND" ), searchTool(), SLOT( find() ) ); + menu->addSeparator(); + } } /*! diff --git a/src/ObjBrowser/OB_Browser.h b/src/ObjBrowser/OB_Browser.h index 28dcc9fb3..1979c8100 100755 --- a/src/ObjBrowser/OB_Browser.h +++ b/src/ObjBrowser/OB_Browser.h @@ -39,7 +39,7 @@ class QAbstractItemDelegate; class QToolTip; class QMenu; class QtxTreeView; -class OB_FindDlg; +class QtxSearchTool; class OB_EXPORT OB_Browser : public QWidget { @@ -64,6 +64,10 @@ public: bool sortMenuEnabled() const; void setSortMenuEnabled( const bool ); + QtxSearchTool* searchTool() const; + bool isSearchToolEnabled() const; + void setSearchToolEnabled( const bool ); + int autoOpenLevel() const; void setAutoOpenLevel( const int ); void openLevels( const int = -1 ); @@ -111,7 +115,6 @@ signals: private slots: void onExpandAll(); void onCollapseAll(); - void onFind(); //void onDestroyed( SUIT_DataObject* ); //void onDoubleClicked ( QListViewItem* ); //void onDropped( QPtrList, QListViewItem*, int ); @@ -157,7 +160,7 @@ private: private: QtxTreeView* myView; - OB_FindDlg* myFindDlg; + QtxSearchTool* mySearchTool; // TODO: decide what to do with tooltip //QToolTip* myTooltip; //QMap myColumnIds; diff --git a/src/ObjBrowser/OB_FindDlg.cxx b/src/ObjBrowser/OB_FindDlg.cxx deleted file mode 100644 index 83f23e7d7..000000000 --- a/src/ObjBrowser/OB_FindDlg.cxx +++ /dev/null @@ -1,110 +0,0 @@ - -#include -#include - -#include - -#include -#include -#include -#include - -OB_FindDlg::OB_FindDlg( OB_Browser* b ) -: QGroupBox( tr( "FIND" ), b ), - myBrowser( b ) -{ - QVBoxLayout *vbox = new QVBoxLayout(); - - QFrame *btns = new QFrame( this ), *checks = new QFrame( this ); - vbox->addWidget( btns ); - vbox->addWidget( checks ); - setLayout( vbox ); - - myData = new QLineEdit( btns ); - myToFirst = new QPushButton( "|<<", btns ); - myToLast = new QPushButton( ">>|", btns ); - myNext = new QPushButton( ">>", btns ); - myPrev = new QPushButton( "<<", btns ); - myClose = new QPushButton( tr( "CLOSE" ), checks ); - myIsCaseSens = new QCheckBox( tr( "CASE_SENSITIVE" ), checks ); - myIsRegExp = new QCheckBox( tr( "IS_REG_EXP" ), checks ); - int w = 30, h = myToFirst->height(); - myToFirst->setMaximumSize( w, h ); - myToLast->setMaximumSize( w, h ); - myNext->setMaximumSize( w, h ); - myPrev->setMaximumSize( w, h ); - - QHBoxLayout* l = new QHBoxLayout( btns ); - l->addWidget( myToFirst, 0 ); - l->addWidget( myPrev, 0 ); - l->addWidget( myData, 1 ); - l->addWidget( myNext, 0 ); - l->addWidget( myToLast, 0 ); - - QHBoxLayout* c = new QHBoxLayout( checks ); - c->addWidget( myIsCaseSens, 0 ); - //c->addWidget( myIsRegExp, 0 ); - myIsRegExp->hide();//temporary hidden - - c->addWidget( myClose, 0 ); - - connect( myToFirst, SIGNAL( clicked() ), this, SLOT( onFind() ) ); - connect( myToLast, SIGNAL( clicked() ), this, SLOT( onFind() ) ); - connect( myNext, SIGNAL( clicked() ), this, SLOT( onFind() ) ); - connect( myPrev, SIGNAL( clicked() ), this, SLOT( onFind() ) ); - connect( myClose, SIGNAL( clicked() ), this, SLOT( onClose() ) ); -} - -OB_FindDlg::~OB_FindDlg() -{ -} - -void OB_FindDlg::onClose() -{ - hide(); -} - -void OB_FindDlg::onFind() -{ - const QModelIndexList& l = myBrowser->selectedIndexes(); - QModelIndex current; - if( l.count()>0 ) - current = l.first(); - - Qt::MatchFlags fl = Qt::MatchContains | Qt::MatchRecursive; - if( myIsCaseSens->isChecked() ) - fl = fl | Qt::MatchCaseSensitive; - if( myIsRegExp->isChecked() ) - fl = fl | Qt::MatchRegExp; - - QModelIndexList found = myBrowser->model()->match( myBrowser->model()->index( 0, 0 ), - 0, myData->text(), -1, fl ); - QModelIndex f; - if( found.count()>0 ) - if( sender()==myToFirst ) - f = found.first(); - else if( sender()==myToLast ) - f = found.last(); - else - { - int ind = found.indexOf( current ); - if( ind<0 ) - ind = 0; - if( sender()==myNext ) - { - ind++; - if( ind>=found.count() ) - ind = 0; - f = found[ ind ]; - } - else if( sender()==myPrev ) - { - ind--; - if( ind<0 ) - ind = found.count()-1; - f = found[ ind ]; - } - } - myBrowser->select( f, true, false ); - myBrowser->treeView()->scrollTo( f ); -} diff --git a/src/ObjBrowser/OB_FindDlg.h b/src/ObjBrowser/OB_FindDlg.h deleted file mode 100644 index adb00bc93..000000000 --- a/src/ObjBrowser/OB_FindDlg.h +++ /dev/null @@ -1,31 +0,0 @@ - -#ifndef OBJECT_BROWSER_FIND_DIALOG_HEADER -#define OBJECT_BROWSER_FIND_DIALOG_HEADER - -#include - -class OB_Browser; -class QLineEdit; -class QPushButton; -class QCheckBox; - -class OB_FindDlg : public QGroupBox -{ - Q_OBJECT - -public: - OB_FindDlg( OB_Browser* ); - virtual ~OB_FindDlg(); - -private slots: - void onFind(); - void onClose(); - -private: - QLineEdit* myData; - QPushButton *myToFirst, *myToLast, *myNext, *myPrev, *myClose; - QCheckBox *myIsCaseSens, *myIsRegExp; - OB_Browser* myBrowser; -}; - -#endif -- 2.39.2