From eb0aa6166eb966e3f3d41b75311e67cfcb364aee Mon Sep 17 00:00:00 2001 From: mzn Date: Tue, 9 Jun 2015 14:59:53 +0300 Subject: [PATCH] refs #559: Zones in Object Browser have not 'eyes' to show/hide them. --- src/HYDROGUI/HYDROGUI_DataModel.cxx | 38 ++++++++++++++++++----------- src/HYDROGUI/HYDROGUI_DataModel.h | 9 +++++++ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 44c63cd2..956015e6 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -699,18 +699,7 @@ LightApp_DataObject* HYDROGUI_DataModel::createObject( SUIT_DataObject* if ( visibility ) { - SUIT_AbstractModel* treeModel = 0; - LightApp_Application* app = dynamic_cast( module()->application() ); - if ( app ) - treeModel = dynamic_cast( app->objectBrowser()->model() ); - - if ( treeModel ) - { - HYDROGUI_Module* aModule = dynamic_cast( module() ); - bool isVisible = aModule->isObjectVisible( -1, theModelObject ); - Qtx::VisibilityState aVisState = isVisible ? Qtx::ShownState : Qtx::HiddenState; - treeModel->setVisibilityState( aResObj->text( aResObj->customData( Qtx::IdType ).toInt() ), aVisState, false ); - } + setObjectVisibilityState( theModelObject, aResObj ); } if ( theIsBuildTree ) @@ -740,8 +729,12 @@ LightApp_DataObject* HYDROGUI_DataModel::createZone( SUIT_DataObject* theP const bool theIsBuildTree, const bool theIsInOperation ) { - return buildObject( theParent, new HYDROGUI_Zone( theParent, theModelObject, theParentEntry, theIsInOperation ), - theParentEntry, theIsBuildTree, theIsInOperation ); + HYDROGUI_Zone* aZone = new HYDROGUI_Zone( theParent, theModelObject, theParentEntry, theIsInOperation ); + LightApp_DataObject* aDataObj = buildObject( theParent, aZone, theParentEntry, theIsBuildTree, theIsInOperation ); + + setObjectVisibilityState( theModelObject, aZone ); + + return aDataObj; } LightApp_DataObject* HYDROGUI_DataModel::createRegion( SUIT_DataObject* theParent, @@ -1139,3 +1132,20 @@ bool HYDROGUI_DataModel::rename( Handle(HYDROData_Entity) theEntity, const QStri } return true; } + +void HYDROGUI_DataModel::setObjectVisibilityState( Handle(HYDROData_Entity) theModelObject, + HYDROGUI_DataObject* theObject ) +{ + SUIT_AbstractModel* treeModel = 0; + LightApp_Application* app = dynamic_cast( module()->application() ); + if ( app ) + treeModel = dynamic_cast( app->objectBrowser()->model() ); + + if ( treeModel ) + { + HYDROGUI_Module* aModule = dynamic_cast( module() ); + bool isVisible = aModule->isObjectVisible( -1, theModelObject ); + Qtx::VisibilityState aVisState = isVisible ? Qtx::ShownState : Qtx::HiddenState; + treeModel->setVisibilityState( theObject->text( theObject->customData( Qtx::IdType ).toInt() ), aVisState, false ); + } +} \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_DataModel.h b/src/HYDROGUI/HYDROGUI_DataModel.h index 473a71fb..def86430 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.h +++ b/src/HYDROGUI/HYDROGUI_DataModel.h @@ -358,6 +358,15 @@ protected: static SUIT_DataObject* findChildByName( const SUIT_DataObject* theFather, const QString& theName ); + /** + * Set object visibility state. + * \param theModelObject the data model object + * \param theDataObject the GUI object + */ + void setObjectVisibilityState( Handle(HYDROData_Entity) theModelObject, + HYDROGUI_DataObject* theObject ); + + protected: QString myStudyURL; ///< the saved/opened document URL QByteArray myStates; -- 2.39.2