Skip to content

Commit

Permalink
Merge branch 'master' of ssh://git.code.sf.net/p/free-cad/code
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Dec 13, 2014
2 parents 7e86d94 + 69edf4b commit 0ea5202
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/App/Document.h
Expand Up @@ -123,8 +123,12 @@ class AppExport Document : public App::PropertyContainer
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 */
Expand Down
18 changes: 17 additions & 1 deletion src/App/MergeDocuments.cpp
Expand Up @@ -25,6 +25,9 @@
# include <stack>
# include <boost/bind.hpp>
#endif

#include <QCoreApplication>

#include "MergeDocuments.h"
#include <Base/Console.h>
#include <Base/Reader.h>
Expand Down Expand Up @@ -94,12 +97,17 @@ class XMLMergeReader : public Base::XMLReader
};
}

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()
Expand Down Expand Up @@ -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);
}
1 change: 1 addition & 0 deletions src/App/MergeDocuments.h
Expand Up @@ -49,6 +49,7 @@ class AppExport MergeDocuments : public Base::Persistence
void RestoreDocFile(Base::Reader & r);

private:
bool guiup;
zipios::ZipInputStream* stream;
App::Document* appdoc;
std::vector<App::DocumentObject*> objects;
Expand Down
9 changes: 9 additions & 0 deletions src/Gui/Document.cpp
Expand Up @@ -94,6 +94,8 @@ struct DocumentP
Connection connectRestDocument;
Connection connectStartLoadDocument;
Connection connectFinishLoadDocument;
Connection connectExportObjects;
Connection connectImportObjects;
};

} // namespace Gui
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit 0ea5202

Please sign in to comment.