From 8710f1ab96864b12a3f902eb44b72b5d9dda90a1 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 27 May 2015 16:39:17 +0300 Subject: [PATCH] refs #534: not to show "New region" item on the empty or not-zone selection --- src/HYDROGUI/HYDROGUI_DataBrowser.cxx | 30 ++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/HYDROGUI/HYDROGUI_DataBrowser.cxx b/src/HYDROGUI/HYDROGUI_DataBrowser.cxx index 4a553e04..57d868a1 100644 --- a/src/HYDROGUI/HYDROGUI_DataBrowser.cxx +++ b/src/HYDROGUI/HYDROGUI_DataBrowser.cxx @@ -322,5 +322,33 @@ void HYDROGUI_DataBrowser::setReadOnly( const bool theIsReadOnly ) void HYDROGUI_DataBrowser::createPopupMenu( QMenu* theMenu ) { theMenu->clear(); - theMenu->addAction( tr( "ZONE_TO_NEW_REGION" ), this, SIGNAL( newRegion() ) ); + DataObjectList aSelection = getSelected(); + bool isOnlyZones = aSelection.size() > 0; + foreach( SUIT_DataObject* anObj, aSelection ) + { + HYDROGUI_DataObject* aHydroObj = dynamic_cast( anObj ); + if( aHydroObj ) + { + Handle(HYDROData_Entity) aModelObj = aHydroObj->modelObject(); + if( !aModelObj.IsNull() ) + { + isOnlyZones = aModelObj->GetKind()==KIND_ZONE; + if( !isOnlyZones ) + break; + } + else + { + isOnlyZones = false; + break; + } + } + else + { + isOnlyZones = false; + break; + } + } + + if( isOnlyZones ) + theMenu->addAction( tr( "ZONE_TO_NEW_REGION" ), this, SIGNAL( newRegion() ) ); } -- 2.39.2