App: add API PropertyContainer::onEarlyChange()

Also add DocumentObject::signalEarlyChanged, triggered before
Document::signalChangedObject
This commit is contained in:
Zheng, Lei
2022-09-03 00:36:31 +05:00
committed by Uwe
parent 75acf045a6
commit 6ce250ddf8
4 changed files with 29 additions and 5 deletions
+10 -2
View File
@@ -755,8 +755,7 @@ void DocumentObject::onBeforeChange(const Property* prop)
signalBeforeChange(*this,*prop);
}
/// get called by the container when a Property was changed
void DocumentObject::onChanged(const Property* prop)
void DocumentObject::onEarlyChange(const Property *prop)
{
if(GetApplication().isClosingAll())
return;
@@ -774,6 +773,15 @@ void DocumentObject::onChanged(const Property* prop)
}
}
signalEarlyChanged(*this, *prop);
}
/// get called by the container when a Property was changed
void DocumentObject::onChanged(const Property* prop)
{
if(GetApplication().isClosingAll())
return;
// Delay signaling view provider until the document object has handled the
// change
// if (_pDoc)
+4
View File
@@ -110,6 +110,8 @@ public:
boost::signals2::signal<void (const App::DocumentObject&, const App::Property&)> signalBeforeChange;
/// signal on changed property of this object
boost::signals2::signal<void (const App::DocumentObject&, const App::Property&)> signalChanged;
/// signal on changed property of this object before document scoped signalChangedObject
boost::signals2::signal<void (const App::DocumentObject&, const App::Property&)> signalEarlyChanged;
/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
@@ -601,6 +603,8 @@ protected:
virtual void onBeforeChange(const Property* prop) override;
/// get called by the container when a property was changed
virtual void onChanged(const Property* prop) override;
/// get called by the container when a property was changed
virtual void onEarlyChange(const Property* prop) override;
/// get called after a document has been fully restored
virtual void onDocumentRestored();
/// get called after an undo/redo transaction is finished
+10 -3
View File
@@ -28,15 +28,17 @@
#endif
#include <atomic>
#include <Base/Exception.h>
#include <Base/Tools.h>
#include <Base/Writer.h>
#include <CXX/Objects.hxx>
#include "Application.h"
#include "DocumentObject.h"
#include "Property.h"
#include "ObjectIdentifier.h"
#include "PropertyContainer.h"
using namespace App;
@@ -230,10 +232,15 @@ void Property::destroy(Property *p) {
void Property::touch()
{
if(GetApplication().isClosingAll())
return;
PropertyCleaner guard(this);
if (father)
father->onChanged(this);
StatusBits.set(Touched);
if (getName() && father) {
father->onEarlyChange(this);
father->onChanged(this);
}
}
void Property::setReadOnly(bool readOnly)
+5
View File
@@ -249,6 +249,11 @@ public:
protected:
/** get called by the container when a property has changed
*
* This function is called before onChanged()
*/
virtual void onEarlyChange(const Property* /*prop*/){}
/// get called by the container when a property has changed
virtual void onChanged(const Property* /*prop*/){}
/// get called before the value is changed