Gui New Feature: Gui::Document support for App::Document undo and redo signals
========================================================================== It defines new slots connected to App::Document's signalUndo/signalRedo, which triggers Gui::Document's signalUndoDocument and signalRedoDocument signals. setModified is not executed upon redo/undo, as this is already done on modification of the properties if properties were modified, and if there were not, no setModified is needed anyway.
This commit is contained in:
parent
eb7a3c763c
commit
da5270131c
|
@ -96,6 +96,8 @@ struct DocumentP
|
|||
Connection connectFinishLoadDocument;
|
||||
Connection connectExportObjects;
|
||||
Connection connectImportObjects;
|
||||
Connection connectUndoDocument;
|
||||
Connection connectRedoDocument;
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
@ -142,6 +144,11 @@ Document::Document(App::Document* pcDocument,Application * app)
|
|||
(boost::bind(&Gui::Document::exportObjects, this, _1, _2));
|
||||
d->connectImportObjects = pcDocument->signalImportViewObjects.connect
|
||||
(boost::bind(&Gui::Document::importObjects, this, _1, _2, _3));
|
||||
|
||||
d->connectUndoDocument = pcDocument->signalUndo.connect
|
||||
(boost::bind(&Gui::Document::slotUndoDocument, this, _1));
|
||||
d->connectRedoDocument = pcDocument->signalRedo.connect
|
||||
(boost::bind(&Gui::Document::slotRedoDocument, this, _1));
|
||||
|
||||
// pointer to the python class
|
||||
// NOTE: As this Python object doesn't get returned to the interpreter we
|
||||
|
@ -171,6 +178,8 @@ Document::~Document()
|
|||
d->connectFinishLoadDocument.disconnect();
|
||||
d->connectExportObjects.disconnect();
|
||||
d->connectImportObjects.disconnect();
|
||||
d->connectUndoDocument.disconnect();
|
||||
d->connectRedoDocument.disconnect();
|
||||
|
||||
// e.g. if document gets closed from within a Python command
|
||||
d->_isClosing = true;
|
||||
|
@ -535,6 +544,22 @@ void Document::slotActivatedObject(const App::DocumentObject& Obj)
|
|||
}
|
||||
}
|
||||
|
||||
void Document::slotUndoDocument(const App::Document& doc)
|
||||
{
|
||||
if (d->_pcDocument != &doc)
|
||||
return;
|
||||
|
||||
signalUndoDocument(*this);
|
||||
}
|
||||
|
||||
void Document::slotRedoDocument(const App::Document& doc)
|
||||
{
|
||||
if (d->_pcDocument != &doc)
|
||||
return;
|
||||
|
||||
signalRedoDocument(*this);
|
||||
}
|
||||
|
||||
void Document::setModified(bool b)
|
||||
{
|
||||
d->_isModified = b;
|
||||
|
|
|
@ -77,6 +77,8 @@ protected:
|
|||
void slotActivatedObject(const App::DocumentObject&);
|
||||
void slotStartRestoreDocument(const App::Document&);
|
||||
void slotFinishRestoreDocument(const App::Document&);
|
||||
void slotUndoDocument(const App::Document&);
|
||||
void slotRedoDocument(const App::Document&);
|
||||
//@}
|
||||
|
||||
public:
|
||||
|
@ -105,7 +107,10 @@ public:
|
|||
/// signal on changed Object, the 2nd argument is the highlite mode to use
|
||||
mutable boost::signal<void (const Gui::ViewProviderDocumentObject&,
|
||||
const Gui::TreeItemMode&)> signalExpandObject;
|
||||
|
||||
/// signal on undo Document
|
||||
mutable boost::signal<void (const Gui::Document& doc)> signalUndoDocument;
|
||||
/// signal on redo Document
|
||||
mutable boost::signal<void (const Gui::Document& doc)> signalRedoDocument;
|
||||
//@}
|
||||
|
||||
/** @name I/O of the document */
|
||||
|
|
Loading…
Reference in New Issue
Block a user