Merge branch 'master' of ssh://git.code.sf.net/p/free-cad/code

This commit is contained in:
Yorik van Havre 2014-12-13 13:37:19 -02:00
commit 0ea52029cd
4 changed files with 31 additions and 1 deletions

View File

@ -123,8 +123,12 @@ public:
boost::signal<void (Base::XMLReader&)> signalRestoreDocument;
boost::signal<void (const std::vector<App::DocumentObject*>&,
Base::Writer &)> signalExportObjects;
boost::signal<void (const std::vector<App::DocumentObject*>&,
Base::Writer &)> signalExportViewObjects;
boost::signal<void (const std::vector<App::DocumentObject*>&,
Base::XMLReader&)> signalImportObjects;
boost::signal<void (const std::vector<App::DocumentObject*>&, Base::Reader&,
const std::map<std::string, std::string>&)> signalImportViewObjects;
//@}
/** @name File handling of the document */

View File

@ -25,6 +25,9 @@
# include <stack>
# include <boost/bind.hpp>
#endif
#include <QCoreApplication>
#include "MergeDocuments.h"
#include <Base/Console.h>
#include <Base/Reader.h>
@ -94,12 +97,17 @@ private:
};
}
MergeDocuments::MergeDocuments(App::Document* doc) : appdoc(doc)
MergeDocuments::MergeDocuments(App::Document* doc) : guiup(false), appdoc(doc)
{
connectExport = doc->signalExportObjects.connect
(boost::bind(&MergeDocuments::exportObject, this, _1, _2));
connectImport = doc->signalImportObjects.connect
(boost::bind(&MergeDocuments::importObject, this, _1, _2));
QCoreApplication* app = QCoreApplication::instance();
if (app && app->inherits("QApplication")) {
guiup = true;
}
}
MergeDocuments::~MergeDocuments()
@ -143,19 +151,27 @@ void MergeDocuments::exportObject(const std::vector<App::DocumentObject*>& o, Ba
void MergeDocuments::Save (Base::Writer & w) const
{
// Save view provider stuff
if (guiup) {
w.addFile("GuiDocument.xml", this);
}
}
void MergeDocuments::Restore(Base::XMLReader &r)
{
// Restore view provider stuff
if (guiup) {
r.addFile("GuiDocument.xml", this);
}
}
void MergeDocuments::SaveDocFile (Base::Writer & w) const
{
// Save view provider stuff
appdoc->signalExportViewObjects(this->objects, w);
}
void MergeDocuments::RestoreDocFile(Base::Reader & r)
{
// Restore view provider stuff
appdoc->signalImportViewObjects(this->objects, r, this->nameMap);
}

View File

@ -49,6 +49,7 @@ public:
void RestoreDocFile(Base::Reader & r);
private:
bool guiup;
zipios::ZipInputStream* stream;
App::Document* appdoc;
std::vector<App::DocumentObject*> objects;

View File

@ -94,6 +94,8 @@ struct DocumentP
Connection connectRestDocument;
Connection connectStartLoadDocument;
Connection connectFinishLoadDocument;
Connection connectExportObjects;
Connection connectImportObjects;
};
} // namespace Gui
@ -136,6 +138,11 @@ Document::Document(App::Document* pcDocument,Application * app)
d->connectFinishLoadDocument = App::GetApplication().signalFinishRestoreDocument.connect
(boost::bind(&Gui::Document::slotFinishRestoreDocument, this, _1));
d->connectExportObjects = pcDocument->signalExportViewObjects.connect
(boost::bind(&Gui::Document::exportObjects, this, _1, _2));
d->connectImportObjects = pcDocument->signalImportViewObjects.connect
(boost::bind(&Gui::Document::importObjects, this, _1, _2, _3));
// pointer to the python class
// NOTE: As this Python object doesn't get returned to the interpreter we
// mustn't increment it (Werner Jan-12-2006)
@ -162,6 +169,8 @@ Document::~Document()
d->connectRestDocument.disconnect();
d->connectStartLoadDocument.disconnect();
d->connectFinishLoadDocument.disconnect();
d->connectExportObjects.disconnect();
d->connectImportObjects.disconnect();
// e.g. if document gets closed from within a Python command
d->_isClosing = true;