App: add a function to document observer to be notified if the active document changes
This commit is contained in:
@@ -656,15 +656,13 @@ DocumentObserver::DocumentObserver() : _document(nullptr)
|
||||
(&DocumentObserver::slotCreatedDocument, this, sp::_1));
|
||||
this->connectApplicationDeletedDocument = App::GetApplication().signalDeleteDocument.connect(std::bind
|
||||
(&DocumentObserver::slotDeletedDocument, this, sp::_1));
|
||||
this->connectApplicationActivateDocument = App::GetApplication().signalActiveDocument.connect(std::bind
|
||||
(&DocumentObserver::slotActivateDocument, this, sp::_1));
|
||||
}
|
||||
|
||||
DocumentObserver::DocumentObserver(Document* doc) : _document(nullptr)
|
||||
DocumentObserver::DocumentObserver(Document* doc) : DocumentObserver()
|
||||
{
|
||||
// Connect to application and given document
|
||||
this->connectApplicationCreatedDocument = App::GetApplication().signalNewDocument.connect(std::bind
|
||||
(&DocumentObserver::slotCreatedDocument, this, sp::_1));
|
||||
this->connectApplicationDeletedDocument = App::GetApplication().signalDeleteDocument.connect(std::bind
|
||||
(&DocumentObserver::slotDeletedDocument, this, sp::_1));
|
||||
attachDocument(doc);
|
||||
}
|
||||
|
||||
@@ -673,6 +671,7 @@ DocumentObserver::~DocumentObserver()
|
||||
// disconnect from application and document
|
||||
this->connectApplicationCreatedDocument.disconnect();
|
||||
this->connectApplicationDeletedDocument.disconnect();
|
||||
this->connectApplicationActivateDocument.disconnect();
|
||||
detachDocument();
|
||||
}
|
||||
|
||||
@@ -720,6 +719,10 @@ void DocumentObserver::slotDeletedDocument(const App::Document& /*Doc*/)
|
||||
{
|
||||
}
|
||||
|
||||
void DocumentObserver::slotActivateDocument(const App::Document& /*Doc*/)
|
||||
{
|
||||
}
|
||||
|
||||
void DocumentObserver::slotCreatedObject(const App::DocumentObject& /*Obj*/)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -437,10 +437,12 @@ public:
|
||||
void detachDocument();
|
||||
|
||||
private:
|
||||
/** Checks if a new document was created */
|
||||
/** Called when a new document was created */
|
||||
virtual void slotCreatedDocument(const App::Document& Doc);
|
||||
/** Checks if the given document is about to be closed */
|
||||
/** Called when a document is about to be closed */
|
||||
virtual void slotDeletedDocument(const App::Document& Doc);
|
||||
/** Called when a document is activated */
|
||||
virtual void slotActivateDocument(const App::Document& Doc);
|
||||
/** Checks if a new object was added. */
|
||||
virtual void slotCreatedObject(const App::DocumentObject& Obj);
|
||||
/** Checks if the given object is about to be removed. */
|
||||
@@ -460,6 +462,7 @@ private:
|
||||
typedef boost::signals2::connection Connection;
|
||||
Connection connectApplicationCreatedDocument;
|
||||
Connection connectApplicationDeletedDocument;
|
||||
Connection connectApplicationActivateDocument;
|
||||
Connection connectDocumentCreatedObject;
|
||||
Connection connectDocumentDeletedObject;
|
||||
Connection connectDocumentChangedObject;
|
||||
|
||||
Reference in New Issue
Block a user