Commit c37c44a7 authored by Jan Möbius's avatar Jan Möbius

Implemented copyObject in core

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5841 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 814542ee
......@@ -182,10 +182,39 @@ void Core::slotAddEmptyObject( DataType _type , int& _id ) {
}
/// Slot creating a copy of an existing object
void slotCopyObject( int _oldId , int& _newId ) {
std::cerr << "slotCopyObject" << std::endl;
void Core::slotCopyObject( int _oldId , int& _newId ) {
_newId = 99;
if ( _oldId == -1 ) {
emit log(LOGERR,"Requested copy for illegal Object id : " + QString::number(_oldId) );
_newId = -1;
return;
}
// get the node
BaseObject* object = objectRoot_->childExists(_oldId);
if ( !object ) {
emit log(LOGERR,"Requested copy for unknown Object id : " + QString::number(_oldId) );
_newId = -1;
return ;
}
// Copy the item
BaseObject* copy = object->copy();
if ( copy == 0 ) {
emit log(LOGERR,"Unable to create a copy of the object.");
return;
}
// Integrate into object tree
copy->setParent( object->parent() );
if ( object->parent() )
object->parent()->appendChild(copy);
else
std::cerr << "Unable to add copy to object list" << std::endl;
_newId = copy->id();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment