Commit 1b7bbaf9 authored by Dirk Wilden's avatar Dirk Wilden

moved deleteObject to LoadSaveInterface

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5384 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 46462207
......@@ -88,15 +88,24 @@ class LoadSaveInterface {
/** \brief Emit this signal if an empty object has been created
* @param _id Id of the added object
*/
*/
virtual void emptyObjectAdded( int /*_id*/ ) {};
/** \brief get a list of all Filters
* request a list of all Filters
/** \brief get a list of all Filters
*
* request a list of all Filters
*
* @param _list StringList where the filters should be put into
*/
*/
virtual void getAllFilters( QStringList& /*_list*/ ) {};
/** \brief Delete an object
*
* @param _id Id of the object
*/
virtual void deleteObject( int /*_id*/ ){};
private slots :
/** \brief A file has been opened
......@@ -113,6 +122,12 @@ class LoadSaveInterface {
*/
virtual void addedEmptyObject( int /*_id*/ ) {};
/** \brief An object was deleted
*
* @param _id Id of the object
*/
virtual void objectDeleted( int /*_id*/ ){};
};
Q_DECLARE_INTERFACE(LoadSaveInterface,"OpenFlipper.LoadSaveInterface/1.0")
......
......@@ -177,36 +177,6 @@ bool getObject( const int _identifier , BaseObjectData*& _object ) {
// ===============================================================================
// ===============================================================================
bool deleteObject( const int _id ) {
if ( _id == -1 )
return false;
// get the node
BaseObject* object = objectRoot_->childExists(_id);
if ( !object || object == objectRoot() ) {
std::cerr << "Error while deleting object, does not exist!!" << std::endl;
return false;
}
// remove the whole subtree below this item
object->deleteSubtree();
// remove the item itself from the parent
object->parent()->removeChild(object);
// delete it
delete object;
return true;
}
void deleteAll( ) {
objectRoot()->deleteSubtree();
}
int copyObject( const int _id ) {
if ( _id == -1 )
return -1;
......
......@@ -73,21 +73,6 @@ namespace PluginFunctions {
DLLEXPORT
bool getPickedObject(const unsigned int _node_idx , BaseObjectData*& _object);
/** \brief Delete the object with the given id
*
* Deletes the given object ( you have to emit the right signals yourself)\n
* updateView , objectListUpdate ... )
* @return successful?
* */
DLLEXPORT
bool deleteObject( const int _id );
/** \brief Delete all objects
*
* */
DLLEXPORT
void deleteAll( );
/** \brief Create a copy of the object with the given id
*
* Creates a copy of an object. All scenegraph nodes will be created. The object will
......
......@@ -1179,6 +1179,33 @@ void Core::addToolbox(QString _name ,QWidget* _widget) {
}
void Core::slotDeleteObject( int _id ){
if ( _id == -1 )
return;
// get the node
BaseObject* object = objectRoot_->childExists(_id);
if ( !object || object == objectRoot_ ) {
std::cerr << "Error while deleting object, does not exist!!" << std::endl;
return;
}
// remove the whole subtree below this item
object->deleteSubtree();
// remove the item itself from the parent
object->parent()->removeChild(object);
// delete it
delete object;
emit objectDeleted(_id);
slotObjectUpdated(-1);
}
// //-----------------------------------------------------------------------------
//
// void Core::slotGetPlugin(QString _name, QObject* & _plugin ){
......
......@@ -203,6 +203,9 @@ signals:
/// Tell plugins that object properties such as object names have been changed
void objectPropertiesChanged( int _id );
/// Called after an object has been deleted
void objectDeleted( int );
/** @} */
//===========================================================================
......@@ -264,6 +267,9 @@ signals:
/// Called when a plugin requests a list of file-filters
void slotGetAllFilters ( QStringList& _list);
/// Called when a plugin wants to delete an object
void slotDeleteObject( int _id );
/// Get a Pointer to the Plugin with given _name (if it is loaded)
// void slotGetPlugin(QString _name, QObject* & _plugin );
......
......@@ -879,6 +879,14 @@ void Core::loadPlugin(QString filename, bool silent){
connect(plugin , SIGNAL( getAllFilters( QStringList& ) ) ,
this , SLOT( slotGetAllFilters ( QStringList& ) ),Qt::DirectConnection);
if ( checkSignal(plugin,"deleteObject(int)" ) )
connect(plugin , SIGNAL( deleteObject( int ) ) ,
this , SLOT( slotDeleteObject( int ) ),Qt::DirectConnection);
if ( checkSlot(plugin,"objectDeleted(int)" ) )
connect(this , SIGNAL( objectDeleted( int ) ) ,
plugin , SLOT( objectDeleted( int ) ),Qt::DirectConnection);
}
//Check if the plugin supports View-Interface
......
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