#include <LogWindow.h>
#include <OB_Browser.h>
#include <OB_ListView.h>
+#include <OB_ObjSearch.h>
#ifndef DISABLE_GLVIEWER
#include <GLViewer_Viewer.h>
if ( flag == WT_ObjectBrowser )
{
OB_Browser* ob = new OB_Browser( desktop() );
+ ob->setSearch( new OB_ObjSearch( ob ) );
ob->setAutoUpdate( true );
//ob->setAutoOpenLevel( 1 ); // commented by ASV as a fix to bug IPAL10107
ob->setCaption( tr( "OBJECT_BROWSER" ) );
thePopup->insertSeparator();
thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
+ thePopup->insertItem( tr( "MEN_FIND" ), this, SLOT( onFind() ) );
}
/*!
return false;
}
+
+void LightApp_Application::onFind()
+{
+ objectBrowser()->enableSearch( true );
+}
private slots:
void onSelection();
void onRefresh();
+ void onFind();
void onPreferences();
void onMRUActivated( QString );
void onPreferenceChanged( QString&, QString&, QString& );
msgid "LightApp_Application::MEN_REFRESH"
msgstr "Refresh"
+msgid "LightApp_Application::MEN_FIND"
+msgstr "Find"
+
msgid "LightApp_Application::PREF_GROUP_SUPERV"
msgstr "Graph Supervisor"
OB_Browser.h \
OB_ListItem.h \
OB_ListView.h \
- OB_Filter.h
+ OB_Filter.h \
+ OB_FindDlg.h \
+ OB_ObjSearch.h
dist_libObjBrowser_la_SOURCES= \
OB_Browser.cxx \
OB_ListItem.cxx \
OB_ListView.cxx \
- OB_Filter.cxx
+ OB_Filter.cxx \
+ OB_FindDlg.cxx \
+ OB_ObjSearch.cxx
MOC_FILES= \
OB_Browser_moc.cxx \
- OB_ListView_moc.cxx
+ OB_ListView_moc.cxx \
+ OB_FindDlg_moc.cxx
nodist_libObjBrowser_la_SOURCES= $(MOC_FILES)
nodist_salomeres_DATA = OB_msg_en.qm
#include "OB_Filter.h"
#include "OB_ListItem.h"
#include "OB_ListView.h"
+#include "OB_FindDlg.h"
#include <SUIT_DataObjectIterator.h>
#include <SUIT_TreeSync.h>
myView->installEventFilter( this );
myView->viewport()->installEventFilter( this );
+ myFindDlg = new OB_FindDlg( this );
+ myFindDlg->hide();
+
QVBoxLayout* main = new QVBoxLayout( this );
- main->addWidget( myView );
+ main->addWidget( myView, 1 );
+ main->addWidget( myFindDlg, 0 );
myShowToolTips = true;
myTooltip = new ToolTip( this, myView->viewport() );
myModifiedTime = clock();
}
+OB_ObjSearch* OB_Browser::getSearch() const
+{
+ return myFindDlg->getSearch();
+}
+
+void OB_Browser::setSearch( OB_ObjSearch* s )
+{
+ myFindDlg->setSearch( s );
+}
+
+void OB_Browser::enableSearch( const bool on )
+{
+ myFindDlg->setShown( on );
+}
class OB_Filter;
class OB_ListView;
class OB_ListItem;
+class OB_ObjSearch;
+class OB_FindDlg;
class OB_Updater
{
OB_Updater* getUpdater() const;
virtual void setUpdater( OB_Updater* theUpdate = 0 );
+ OB_ObjSearch* getSearch() const;
+ void setSearch( OB_ObjSearch* );
+ void enableSearch( const bool );
+
signals:
void selectionChanged();
void doubleClicked( SUIT_DataObject* );
bool myShowToolTips;
bool myRootDecorated;
int myAutoOpenLevel;
+ OB_FindDlg *myFindDlg;
friend class OB_Browser::ToolTip;
--- /dev/null
+
+#include <OB_FindDlg.h>
+#include <OB_ObjSearch.h>
+#include <OB_Browser.h>
+#include <OB_ListItem.h>
+
+#include <SUIT_DataObject.h>
+#include <SUIT_MessageBox.h>
+
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+
+OB_FindDlg::OB_FindDlg( QWidget* parent )
+: QGroupBox( 1, Qt::Horizontal, tr( "FIND" ), parent ),
+ mySearch( 0 )
+{
+ QFrame *btns = new QFrame( this ), *checks = new QFrame( this );
+
+ 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, 5, 5 );
+ 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, 5, 5 );
+ c->addWidget( myIsCaseSens, 0 );
+ c->addWidget( myIsRegExp, 0 );
+ 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()
+{
+ OB_ListItem* it = 0;
+ mySearch->setPattern( myData->text(), myIsRegExp->isChecked(), myIsCaseSens->isChecked() );
+ if( sender()==myToFirst )
+ it = mySearch->findFirst();
+ else if( sender()==myNext )
+ it = mySearch->findNext();
+ else if( sender()==myPrev )
+ it = mySearch->findPrev();
+ else if( sender()==myToLast )
+ it = mySearch->findLast();
+ if( it )
+ {
+ mySearch->browser()->setSelected( it->dataObject(), false );
+ mySearch->browser()->listView()->ensureItemVisible( it );
+ }
+ else
+ SUIT_MessageBox::info1( this, tr( "FIND" ), tr( "NOT_FOUND" ), tr( "OK" ) );
+}
+
+OB_ObjSearch* OB_FindDlg::getSearch() const
+{
+ return mySearch;
+}
+
+void OB_FindDlg::setSearch( OB_ObjSearch* s )
+{
+ mySearch = s;
+}
--- /dev/null
+
+#ifndef OBJECT_BROWSER_FIND_DIALOG_HEADER
+#define OBJECT_BROWSER_FIND_DIALOG_HEADER
+
+#include <qgroupbox.h>
+
+class OB_ObjSearch;
+class QLineEdit;
+class QPushButton;
+class QCheckBox;
+
+class OB_FindDlg : public QGroupBox
+{
+ Q_OBJECT
+
+public:
+ OB_FindDlg( QWidget* = 0 );
+ virtual ~OB_FindDlg();
+
+ OB_ObjSearch* getSearch() const;
+ void setSearch( OB_ObjSearch* );
+
+private slots:
+ void onFind();
+ void onClose();
+
+private:
+ QLineEdit* myData;
+ QPushButton *myToFirst, *myToLast, *myNext, *myPrev, *myClose;
+ QCheckBox *myIsCaseSens, *myIsRegExp;
+ OB_ObjSearch* mySearch;
+};
+
+#endif
--- /dev/null
+
+#include <OB_ObjSearch.h>
+#include <OB_ListItem.h>
+#include <OB_Browser.h>
+
+#include <qregexp.h>
+
+OB_ObjSearch::OB_ObjSearch( OB_Browser* b )
+: myBrowser( b )
+{
+}
+
+OB_ObjSearch::~OB_ObjSearch()
+{
+}
+
+OB_ListItem* OB_ObjSearch::tail( const bool first ) const
+{
+ QListView* lv = myBrowser->listView();
+ return dynamic_cast<OB_ListItem*>( first ? lv->firstChild() : lv->lastItem() );
+}
+
+OB_ListItem* OB_ObjSearch::next( OB_ListItem* i, const bool forward ) const
+{
+ QListViewItemIterator it( i );
+ if( forward )
+ it++;
+ else
+ it--;
+ return dynamic_cast<OB_ListItem*>( *it );
+}
+
+SUIT_DataObject* OB_ObjSearch::data( OB_ListItem* i ) const
+{
+ return i ? i->dataObject() : 0;
+}
+
+void OB_ObjSearch::setPattern( const QString& data, const bool is_reg_exp, const bool is_case_sens )
+{
+ myData = data;
+ myIsRegExp = is_reg_exp;
+ myIsCaseSens = is_case_sens;
+}
+
+bool OB_ObjSearch::matches( SUIT_DataObject* obj ) const
+{
+ if( !obj )
+ return false;
+
+ QString txt = obj->name();
+ if( myIsRegExp )
+ {
+ QRegExp re( myData );
+ re.setCaseSensitive( myIsCaseSens );
+ return txt.contains( re );
+ }
+ else
+ return txt.contains( myData, myIsCaseSens );
+}
+
+OB_Browser* OB_ObjSearch::browser() const
+{
+ return myBrowser;
+}
+
+OB_ListItem* OB_ObjSearch::findFirst() const
+{
+ return find( tail( true ), true, false, false );
+}
+
+OB_ListItem* OB_ObjSearch::findLast() const
+{
+ return find( tail( false ), false, false, false );
+}
+
+OB_ListItem* OB_ObjSearch::findNext() const
+{
+ return find( current(), true, true, true );
+}
+
+OB_ListItem* OB_ObjSearch::findPrev() const
+{
+ return find( current(), false, true, true );
+}
+
+OB_ListItem* OB_ObjSearch::find( OB_ListItem* i, const bool forward,
+ const bool ignore_first, const bool cyclic ) const
+{
+ if( !i )
+ i = tail( forward );
+
+ if( ignore_first )
+ i = next( i, forward );
+
+ while( i && !matches( data( i ) ) )
+ i = next( i, forward );
+
+ if( !i && cyclic )
+ return find( tail( forward ), forward, false, false );
+
+ return i;
+}
+
+OB_ListItem* OB_ObjSearch::current() const
+{
+ return dynamic_cast<OB_ListItem*>( myBrowser->listView()->currentItem() );
+}
--- /dev/null
+
+#ifndef OBJECT_BROWSER_OBJECT_SEARCH_HEADER
+#define OBJECT_BROWSER_OBJECT_SEARCH_HEADER
+
+#include <qstring.h>
+
+class OB_ListItem;
+class OB_Browser;
+class SUIT_DataObject;
+
+class OB_ObjSearch
+{
+public:
+ OB_ObjSearch( OB_Browser* );
+ virtual ~OB_ObjSearch();
+
+ void setPattern( const QString&, const bool, const bool );
+ OB_Browser* browser() const;
+
+ OB_ListItem* findFirst() const;
+ OB_ListItem* findLast() const;
+ OB_ListItem* findNext() const;
+ OB_ListItem* findPrev() const;
+
+protected:
+ virtual OB_ListItem* current() const;
+ virtual OB_ListItem* tail( const bool ) const;
+ virtual OB_ListItem* next( OB_ListItem*, const bool ) const;
+ virtual SUIT_DataObject* data( OB_ListItem* ) const;
+ virtual bool matches( SUIT_DataObject* ) const;
+ OB_ListItem* find( OB_ListItem*, const bool, const bool, const bool ) const;
+
+private:
+ OB_Browser* myBrowser;
+ QString myData;
+ bool myIsRegExp, myIsCaseSens;
+};
+
+#endif
msgid "MEN_EXPAND_ALL"
msgstr "Expand All"
+msgid "OB_FindDlg::FIND"
+msgstr "Find"
+
+msgid "OB_FindDlg::CLOSE"
+msgstr "Close"
+
+msgid "OB_FindDlg::CASE_SENSITIVE"
+msgstr "Case sensitive"
+
+msgid "OB_FindDlg::IS_REG_EXP"
+msgstr "Regular expression"
+
+msgid "OB_FindDlg::NOT_FOUND"
+msgstr "There is no object is found"