+ add slots for undo/redo to Python document observer
This commit is contained in:
parent
22b63a7653
commit
a869033925
|
@ -67,6 +67,10 @@ DocumentObserverPython::DocumentObserverPython(const Py::Object& obj) : inst(obj
|
||||||
(&DocumentObserverPython::slotRelabelDocument, this, _1));
|
(&DocumentObserverPython::slotRelabelDocument, this, _1));
|
||||||
this->connectApplicationActivateDocument = App::GetApplication().signalActiveDocument.connect(boost::bind
|
this->connectApplicationActivateDocument = App::GetApplication().signalActiveDocument.connect(boost::bind
|
||||||
(&DocumentObserverPython::slotActivateDocument, this, _1));
|
(&DocumentObserverPython::slotActivateDocument, this, _1));
|
||||||
|
this->connectApplicationUndoDocument = App::GetApplication().signalUndoDocument.connect(boost::bind
|
||||||
|
(&DocumentObserverPython::slotUndoDocument, this, _1));
|
||||||
|
this->connectApplicationRedoDocument = App::GetApplication().signalRedoDocument.connect(boost::bind
|
||||||
|
(&DocumentObserverPython::slotRedoDocument, this, _1));
|
||||||
|
|
||||||
this->connectDocumentCreatedObject = App::GetApplication().signalNewObject.connect(boost::bind
|
this->connectDocumentCreatedObject = App::GetApplication().signalNewObject.connect(boost::bind
|
||||||
(&DocumentObserverPython::slotCreatedObject, this, _1));
|
(&DocumentObserverPython::slotCreatedObject, this, _1));
|
||||||
|
@ -82,6 +86,8 @@ DocumentObserverPython::~DocumentObserverPython()
|
||||||
this->connectApplicationDeletedDocument.disconnect();
|
this->connectApplicationDeletedDocument.disconnect();
|
||||||
this->connectApplicationRelabelDocument.disconnect();
|
this->connectApplicationRelabelDocument.disconnect();
|
||||||
this->connectApplicationActivateDocument.disconnect();
|
this->connectApplicationActivateDocument.disconnect();
|
||||||
|
this->connectApplicationUndoDocument.disconnect();
|
||||||
|
this->connectApplicationRedoDocument.disconnect();
|
||||||
|
|
||||||
this->connectDocumentCreatedObject.disconnect();
|
this->connectDocumentCreatedObject.disconnect();
|
||||||
this->connectDocumentDeletedObject.disconnect();
|
this->connectDocumentDeletedObject.disconnect();
|
||||||
|
@ -156,6 +162,40 @@ void DocumentObserverPython::slotActivateDocument(const App::Document& Doc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DocumentObserverPython::slotUndoDocument(const App::Document& Doc)
|
||||||
|
{
|
||||||
|
Base::PyGILStateLocker lock;
|
||||||
|
try {
|
||||||
|
if (this->inst.hasAttr(std::string("slotUndoDocument"))) {
|
||||||
|
Py::Callable method(this->inst.getAttr(std::string("slotUndoDocument")));
|
||||||
|
Py::Tuple args(1);
|
||||||
|
args.setItem(0, Py::Object(const_cast<App::Document&>(Doc).getPyObject(), true));
|
||||||
|
method.apply(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Py::Exception&) {
|
||||||
|
Base::PyException e; // extract the Python error text
|
||||||
|
e.ReportException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DocumentObserverPython::slotRedoDocument(const App::Document& Doc)
|
||||||
|
{
|
||||||
|
Base::PyGILStateLocker lock;
|
||||||
|
try {
|
||||||
|
if (this->inst.hasAttr(std::string("slotRedoDocument"))) {
|
||||||
|
Py::Callable method(this->inst.getAttr(std::string("slotRedoDocument")));
|
||||||
|
Py::Tuple args(1);
|
||||||
|
args.setItem(0, Py::Object(const_cast<App::Document&>(Doc).getPyObject(), true));
|
||||||
|
method.apply(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Py::Exception&) {
|
||||||
|
Base::PyException e; // extract the Python error text
|
||||||
|
e.ReportException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DocumentObserverPython::slotCreatedObject(const App::DocumentObject& Obj)
|
void DocumentObserverPython::slotCreatedObject(const App::DocumentObject& Obj)
|
||||||
{
|
{
|
||||||
Base::PyGILStateLocker lock;
|
Base::PyGILStateLocker lock;
|
||||||
|
|
|
@ -65,6 +65,10 @@ private:
|
||||||
void slotDeletedObject(const App::DocumentObject& Obj);
|
void slotDeletedObject(const App::DocumentObject& Obj);
|
||||||
/** The property of an observed object has changed */
|
/** The property of an observed object has changed */
|
||||||
void slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop);
|
void slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop);
|
||||||
|
/** Undoes the last transaction of the document */
|
||||||
|
void slotUndoDocument(const App::Document& Doc);
|
||||||
|
/** Redoes the last undone transaction of the document */
|
||||||
|
void slotRedoDocument(const App::Document& Doc);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Py::Object inst;
|
Py::Object inst;
|
||||||
|
@ -75,6 +79,8 @@ private:
|
||||||
Connection connectApplicationDeletedDocument;
|
Connection connectApplicationDeletedDocument;
|
||||||
Connection connectApplicationRelabelDocument;
|
Connection connectApplicationRelabelDocument;
|
||||||
Connection connectApplicationActivateDocument;
|
Connection connectApplicationActivateDocument;
|
||||||
|
Connection connectApplicationUndoDocument;
|
||||||
|
Connection connectApplicationRedoDocument;
|
||||||
Connection connectDocumentCreatedObject;
|
Connection connectDocumentCreatedObject;
|
||||||
Connection connectDocumentDeletedObject;
|
Connection connectDocumentDeletedObject;
|
||||||
Connection connectDocumentChangedObject;
|
Connection connectDocumentChangedObject;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user