1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_DataBrowser.h"
24 #include "HYDROGUI_Module.h"
25 #include "HYDROGUI_DataObject.h"
27 #include <LightApp_Application.h>
28 #include <LightApp_OBSelector.h>
29 #include <LightApp_SelectionMgr.h>
30 #include <QHeaderView>
31 #include <QtxSearchTool.h>
32 #include <QtxTreeView.h>
33 #include <SUIT_DataObject.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SUIT_SelectionMgr.h>
36 #include <SUIT_DataObjectIterator.h>
38 #define VISIBILITY_COLUMN_WIDTH 25
40 HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_DataObject* theRoot, QWidget* theParent )
41 : SUIT_DataBrowser( theRoot, theParent ), myModule( theModule )
43 SUIT_ResourceMgr* resMgr = theModule->getApp()->resourceMgr();
45 setSortMenuEnabled( true );
46 setAutoUpdate( true );
48 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
49 searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
51 setWindowTitle( tr( "OBJECT_BROWSER" ) );
52 connect( this, SIGNAL( requestUpdate() ), theModule->getApp(), SLOT( onRefresh() ) );
54 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
55 QString RefObjCol = tr( "REF_OBJECT_COLUMN" );
56 QString BathymetryCol = tr( "BATHYMETRY_COLUMN" );
57 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( model() );
58 //RKV: treeModel->setSearcher( theModule->getApp() );
59 treeModel->setSearcher( this ); //RKV
60 treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
61 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
62 treeModel->registerColumn( 0, RefObjCol, HYDROGUI_DataObject::RefObjectId );
63 treeModel->setAppropriate( RefObjCol, Qtx::Toggled );
64 treeModel->registerColumn( 0, BathymetryCol, HYDROGUI_DataObject::BathymetryId );
65 treeModel->setAppropriate( BathymetryCol, Qtx::Toggled );
67 // Mantis issue 0020136: Drag&Drop in OB
68 SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
71 SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
72 SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
75 // temporary commented
77 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( listView() ) );
79 ob_list->setColumnMaxWidth( 0, theModule->getApp()->desktop()->width()/4 );
81 setFilter( new LightApp_OBFilter( theModule->getApp()->selectionMgr() ) );
85 new LightApp_OBSelector( this, theModule->getApp()->selectionMgr() );
87 treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
88 treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
89 treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
90 treeView()->hideColumn( SUIT_DataObject::VisibilityId );
91 treeView()->hideColumn( LightApp_DataObject::EntryId );
92 //RKV: connectPopupRequest( theModule->getApp(), SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
95 HYDROGUI_DataBrowser::~HYDROGUI_DataBrowser()
99 SUIT_DataObject* HYDROGUI_DataBrowser::findObject( const QString& theEntry ) const
101 LightApp_DataObject* aCurObj;
102 for ( SUIT_DataObjectIterator it( root(), SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it ) {
103 aCurObj = dynamic_cast<LightApp_DataObject*>( it.current() );
104 if ( aCurObj && aCurObj->entry() == theEntry )