From 36583eee26a301c064e1c729ceb49057fdc737e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 15 Dec 2009 12:56:55 +0000 Subject: [PATCH] objectProperties changed is now handled internally from core git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7933 383ad7c9-94d9-4d36-a494-682f7c89f535 --- OpenFlipper/BasePlugin/BaseInterface.hh | 10 +--------- OpenFlipper/Core/PluginCommunication.cc | 14 ++++++++++++-- OpenFlipper/Core/PluginLoader.cc | 8 ++++++-- OpenFlipper/common/BaseObject.cc | 15 +++++++++++++++ OpenFlipper/common/BaseObject.hh | 15 ++++++++++++++- 5 files changed, 48 insertions(+), 14 deletions(-) diff --git a/OpenFlipper/BasePlugin/BaseInterface.hh b/OpenFlipper/BasePlugin/BaseInterface.hh index 0dd324198..3852a81f7 100644 --- a/OpenFlipper/BasePlugin/BaseInterface.hh +++ b/OpenFlipper/BasePlugin/BaseInterface.hh @@ -131,15 +131,7 @@ class BaseInterface { * */ virtual void nodeVisibilityChanged( int /*_identifier*/ ) {}; - - /** \brief Object properties have been changed - * - * This signal is used to tell the other plugins that the object properties (e.g. name ) have changed - * - */ - virtual void objectPropertiesChanged( int /*_identifier*/ ) {}; - - + private slots: /** \brief An object has been updated by another plugin diff --git a/OpenFlipper/Core/PluginCommunication.cc b/OpenFlipper/Core/PluginCommunication.cc index ea52f8436..ffc35870c 100644 --- a/OpenFlipper/Core/PluginCommunication.cc +++ b/OpenFlipper/Core/PluginCommunication.cc @@ -136,6 +136,15 @@ void Core::slotObjectSelectionChanged( int _id ) void Core::slotObjectPropertiesChanged( int _id ) { +// std::cerr << "Object Properties changed " << _id << std::endl; +// +// BaseObject* baseObject = 0; +// PluginFunctions::getObject(_id,baseObject); +// +// if ( baseObject ) { +// baseObject->dumpTree(); +// } +// emit objectPropertiesChanged(_id); } @@ -282,8 +291,9 @@ void Core::newObject(int _objectId) { PluginFunctions::getObject(_objectId,baseObject); if ( baseObject ) { - connect( baseObject, SIGNAL(visibilityChanged(int)), this, SLOT(slotVisibilityChanged(int)), Qt::DirectConnection) ; - connect( baseObject, SIGNAL(objectSelectionChanged(int)),this, SLOT(slotObjectSelectionChanged(int)), Qt::DirectConnection ); + connect( baseObject, SIGNAL(visibilityChanged(int)), this, SLOT(slotVisibilityChanged(int)), Qt::DirectConnection) ; + connect( baseObject, SIGNAL(objectSelectionChanged(int)), this, SLOT(slotObjectSelectionChanged(int)), Qt::DirectConnection ); + connect( baseObject, SIGNAL(objectPropertiesChanged(int)), this, SLOT(slotObjectPropertiesChanged(int)), Qt::DirectConnection ); } else { emit log(LOGERR,tr("newObject received from objectManager with invalid id! This should not happen. The new Object will not work correctly!")); } diff --git a/OpenFlipper/Core/PluginLoader.cc b/OpenFlipper/Core/PluginLoader.cc index 203c5df0e..8268aee02 100644 --- a/OpenFlipper/Core/PluginLoader.cc +++ b/OpenFlipper/Core/PluginLoader.cc @@ -489,8 +489,12 @@ void Core::loadPlugin(QString filename, bool silent){ connect(this,SIGNAL(signalObjectUpdated(int)),plugin,SLOT(slotObjectUpdated(int)), Qt::DirectConnection); - if ( checkSignal(plugin,"objectPropertiesChanged(int)")) - connect(plugin,SIGNAL(objectPropertiesChanged(int)),this,SLOT(slotObjectPropertiesChanged(int)), Qt::DirectConnection); + if ( checkSignal(plugin,"objectPropertiesChanged(int)")) { + emit log (LOGERR,tr("Signal objectPropertiesChanged(int) is deprecated. " )); + emit log (LOGERR,tr("The signal will be automatically emitted by the object that has been changed and the core will deliver it to the plugins!. ")); + emit log (LOGERR,tr("Please remove this signal from your plugins!. ")); +// connect(plugin,SIGNAL(objectPropertiesChanged(int)),this,SLOT(slotObjectPropertiesChanged(int)), Qt::DirectConnection); + } if ( checkSlot( plugin , "slotViewChanged()" ) ) connect(this,SIGNAL(pluginViewChanged()),plugin,SLOT(slotViewChanged()), Qt::DirectConnection); diff --git a/OpenFlipper/common/BaseObject.cc b/OpenFlipper/common/BaseObject.cc index c724c57f7..a380f39a1 100644 --- a/OpenFlipper/common/BaseObject.cc +++ b/OpenFlipper/common/BaseObject.cc @@ -411,7 +411,19 @@ BaseObject* BaseObject::parent() /// Set the parent pointer void BaseObject::setParent(BaseObject* _parent) { + // remove this child from the old parents list + if ( parentItem_ != 0 ) + parentItem_->removeChild(this); + + // Add as child of new parent + if ( _parent != 0 ) + _parent->appendChild(this); + + // Store new parent parentItem_ = _parent; + + // Tell other plugins about this change + emit objectPropertiesChanged(id()); } @@ -650,6 +662,9 @@ QString BaseObject::name() { void BaseObject::setName(QString _name ) { name_ = _name; + + // Tell plugins about the name change + emit objectPropertiesChanged(id()); } // =============================================================================== diff --git a/OpenFlipper/common/BaseObject.hh b/OpenFlipper/common/BaseObject.hh index 643790b9f..7ab070262 100644 --- a/OpenFlipper/common/BaseObject.hh +++ b/OpenFlipper/common/BaseObject.hh @@ -325,6 +325,8 @@ class DLLEXPORTONLY BaseObject : public QObject { * @{ */ //=========================================================================== + public: + /// get the row of this item from the parent int row() const; @@ -340,7 +342,9 @@ class DLLEXPORTONLY BaseObject : public QObject { /** @name Tree : Children * @{ */ //=========================================================================== - + + public: + /// Check if the element exists in the subtree of this element BaseObject* childExists(int _objectId); @@ -372,6 +376,8 @@ class DLLEXPORTONLY BaseObject : public QObject { * @{ */ //=========================================================================== + public: + /** Return the primary group of this object or -1 if ungrouped. * As this is a tree structure this returns the first group of this object. * Groups of groups are only suppurted via the other functions. @@ -410,6 +416,13 @@ class DLLEXPORTONLY BaseObject : public QObject { * @{ */ //=========================================================================== + signals: + /** This signal is emitted when properties of the object have been changed like its name + * or the parent changed + */ + void objectPropertiesChanged(int _objectId); + + public: /// return the name of the object. The name defaults to NONAME if unset. QString name( ); -- GitLab