X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_DataBrowser.cxx;h=2c16b0c6383c3efdc03373dc493ce0ad033d9aab;hb=f34b90e9e4e02ba65419134d5d37a2e42aecfabf;hp=b6cdedb224516b134715593cbfc522844e113e1a;hpb=abe63c42525c9299302649cdb5dcff4f83368c26;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_DataBrowser.cxx b/src/HYDROGUI/HYDROGUI_DataBrowser.cxx index b6cdedb2..2c16b0c6 100644 --- a/src/HYDROGUI/HYDROGUI_DataBrowser.cxx +++ b/src/HYDROGUI/HYDROGUI_DataBrowser.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #define VISIBILITY_COLUMN_WIDTH 25 @@ -41,8 +42,15 @@ HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_Dat { SUIT_ResourceMgr* resMgr = theModule->getApp()->resourceMgr(); + if ( ( !theRoot ) && theModule ) + { + // Initialize the root with the module data model + setRoot( new CAM_ModuleObject( theModule->dataModel(), NULL ) ); + } + setSortMenuEnabled( true ); setAutoUpdate( true ); + setUpdateModified( true ); if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) ) searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) ); @@ -50,22 +58,54 @@ HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_Dat setWindowTitle( tr( "OBJECT_BROWSER" ) ); connect( this, SIGNAL( requestUpdate() ), theModule->getApp(), SLOT( onRefresh() ) ); + QString EntryCol = QObject::tr( "ENTRY_COLUMN" ); QString RefObjCol = tr( "REF_OBJECT_COLUMN" ); - QString BathymetryCol = tr( "BATHYMETRY_COLUMN" ); + QString AltitudeCol = tr( "ALTITUDE_COLUMN" ); + SUIT_AbstractModel* treeModel = dynamic_cast( model() ); - treeModel->setSearcher( theModule->getApp() ); + //RKV: treeModel->setSearcher( theModule->getApp() ); + treeModel->setSearcher( this ); //RKV + treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId ); + treeModel->setAppropriate( EntryCol, Qtx::Toggled ); treeModel->registerColumn( 0, RefObjCol, HYDROGUI_DataObject::RefObjectId ); treeModel->setAppropriate( RefObjCol, Qtx::Toggled ); - treeModel->registerColumn( 0, BathymetryCol, HYDROGUI_DataObject::BathymetryId ); - treeModel->setAppropriate( BathymetryCol, Qtx::Toggled ); + treeModel->registerColumn( 0, AltitudeCol, HYDROGUI_DataObject::AltitudeObjId ); + treeModel->setAppropriate( AltitudeCol, Qtx::Toggled ); // Mantis issue 0020136: Drag&Drop in OB - //RKV: TODO: Uncomment for drag and drop - //RKV: SUIT_ProxyModel* proxyModel = dynamic_cast(treeModel); - //RKV: if ( proxyModel ) { - //RKV: connect( proxyModel, SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ), - //RKV: theModule->getApp(), SLOT( onDropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ) ); - //RKV: } + SUIT_ProxyModel* proxyModel = dynamic_cast(treeModel); + if ( proxyModel ) { + connect( proxyModel, + SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ), + SIGNAL( dropped( const QList&, SUIT_DataObject*, int, Qt::DropAction ) ) ); + + //// Connect signal emitted after editing for updating after objects renaming + SUIT_TreeModel* aMiniModel = dynamic_cast( proxyModel->sourceModel() ); + if ( aMiniModel ) + { + connect( aMiniModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ), + SIGNAL( dataChanged() ) ); + } + + // Do updating also in the module's main object browser. + if ( theModule ) + { + SUIT_DataBrowser* aModulBrowser = theModule->getApp()->objectBrowser(); + if ( aModulBrowser ) + { + SUIT_ProxyModel* aPModel = dynamic_cast(aModulBrowser->model()); + if ( aPModel ) + { + SUIT_TreeModel* aModel = dynamic_cast(aPModel->sourceModel()); + //connect( proxyModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ), + // aPModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ) ); + //connect( proxyModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ), + // aModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ) ); + connect( proxyModel, SIGNAL( modelUpdated() ), aModel, SIGNAL( modelUpdated() ) ); + } + } + } + } // temporary commented /* @@ -82,9 +122,22 @@ HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_Dat treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed); treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId); treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH); + treeView()->hideColumn( SUIT_DataObject::VisibilityId ); + treeView()->hideColumn( LightApp_DataObject::EntryId ); //RKV: connectPopupRequest( theModule->getApp(), SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); } HYDROGUI_DataBrowser::~HYDROGUI_DataBrowser() { } + +SUIT_DataObject* HYDROGUI_DataBrowser::findObject( const QString& theEntry ) const +{ + LightApp_DataObject* aCurObj; + for ( SUIT_DataObjectIterator it( root(), SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it ) { + aCurObj = dynamic_cast( it.current() ); + if ( aCurObj && aCurObj->entry() == theEntry ) + return aCurObj; + } + return NULL; +}