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()
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 ||