From: mzn Date: Thu, 26 Dec 2013 07:42:15 +0000 (+0000) Subject: Bug #282: Strange behavior during copypaste operation. X-Git-Tag: BR_hydro_v_0_7~51 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f7604dea602863f2c24c81519f4d6b2ed2ebcba2;p=modules%2Fhydro.git Bug #282: Strange behavior during copypaste operation. Allow multiple objects copy/paste. --- diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 9f6a00d1..16feb209 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -547,20 +547,25 @@ bool HYDROGUI_DataModel::redo() bool HYDROGUI_DataModel::canCopy() { HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( (HYDROGUI_Module*)module() ); - if( aSeq.Length() != 1 ) - return false; - - Handle(HYDROData_Entity) anObject = aSeq.First(); - if( anObject.IsNull() ) - return false; + bool isCanCopy = !aSeq.IsEmpty(); - ObjectKind aKind = anObject->GetKind(); - if( aKind > KIND_UNKNOWN && aKind <= KIND_LAST && - aKind != KIND_DUMMY_3D && aKind != KIND_ZONE && - aKind != KIND_SHAPES_GROUP && aKind != KIND_SPLITTED_GROUP ) - return true; - - return false; + for ( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) { + Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex ); + if( !anObject.IsNull() ) { + ObjectKind aKind = anObject->GetKind(); + bool isUnrecognized = aKind <= KIND_UNKNOWN || aKind > KIND_LAST; + bool isChildObject = aKind == KIND_DUMMY_3D || + aKind == KIND_ZONE || + aKind == KIND_SHAPES_GROUP || + aKind == KIND_SPLITTED_GROUP; + if ( isUnrecognized || isChildObject ) { + isCanCopy = false; + break; + } + } + } + + return isCanCopy; } bool HYDROGUI_DataModel::canPaste() diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index ea883c19..fb192aff 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -610,19 +610,22 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( SetColorId ) ); theMenu->addSeparator(); } - - // Add copy action - if( aModel->canCopy() ) { - theMenu->addAction( action( CopyId ) ); - theMenu->addSeparator(); - } } else if ( anAllAreProfiles ) { theMenu->addAction( action( SelectedGeoreferencementId ) ); theMenu->addSeparator(); } + // Add copy action + QAction* aCopyAction = action( CopyId ); + if( aCopyAction && aCopyAction->isEnabled() ) { + theMenu->addAction( action( CopyId ) ); + theMenu->addSeparator(); + } + + // Add delete action if( !anIsDummyObject3D ) theMenu->addAction( action( DeleteId ) ); + theMenu->addSeparator(); if( anIsImage || anIsPolyline || anIsPolyline3D ||