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>
37 #define VISIBILITY_COLUMN_WIDTH 25
39 HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_DataObject* theRoot, QWidget* theParent )
40 : SUIT_DataBrowser( theRoot, theParent ), myModule( theModule )
42 SUIT_ResourceMgr* resMgr = theModule->getApp()->resourceMgr();
44 setSortMenuEnabled( true );
45 setAutoUpdate( true );
47 if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
48 searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
50 setWindowTitle( tr( "OBJECT_BROWSER" ) );
51 connect( this, SIGNAL( requestUpdate() ), theModule->getApp(), SLOT( onRefresh() ) );
53 QString RefObjCol = tr( "REF_OBJECT_COLUMN" );
54 QString BathymetryCol = tr( "BATHYMETRY_COLUMN" );
55 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( model() );
56 treeModel->setSearcher( theModule->getApp() );
57 treeModel->registerColumn( 0, RefObjCol, HYDROGUI_DataObject::RefObjectId );
58 treeModel->setAppropriate( RefObjCol, Qtx::Toggled );
59 treeModel->registerColumn( 0, BathymetryCol, HYDROGUI_DataObject::BathymetryId );
60 treeModel->setAppropriate( BathymetryCol, Qtx::Toggled );
62 // Mantis issue 0020136: Drag&Drop in OB
63 //RKV: TODO: Uncomment for drag and drop
64 //RKV: SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
65 //RKV: if ( proxyModel ) {
66 //RKV: connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
67 //RKV: theModule->getApp(), SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
70 // temporary commented
72 OB_ListView* ob_list = dynamic_cast<OB_ListView*>( const_cast<QListView*>( listView() ) );
74 ob_list->setColumnMaxWidth( 0, theModule->getApp()->desktop()->width()/4 );
76 setFilter( new LightApp_OBFilter( theModule->getApp()->selectionMgr() ) );
80 new LightApp_OBSelector( this, theModule->getApp()->selectionMgr() );
82 treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
83 treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
84 treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
85 //RKV: connectPopupRequest( theModule->getApp(), SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
88 HYDROGUI_DataBrowser::~HYDROGUI_DataBrowser()