App/Gui: introduce temporary document

Add new argument to Application::newDocument() to create a temporary
    document. Also exposed to Python API App.newDocument() with a named
    argument 'temp'.

    The temporary document is marked with status bit 'TempDoc'. The user
    will not be prompt for saving when closing. The undo/redo is disabled.
    The AutoSaver skips it. And the tree view will not show it.
    PropertyXLink allows linking to/from object within a temporary document
    without saving.
This commit is contained in:
Zheng, Lei
2020-01-03 20:36:54 +08:00
committed by wmayer
parent 20cb8e2480
commit 36d046d489
13 changed files with 119 additions and 46 deletions

View File

@@ -927,17 +927,25 @@ void Application::onLastWindowClosed(Gui::Document* pcDoc)
// Call the closing mechanism from Python. This also checks whether pcDoc is the last open document.
Command::doCommand(Command::Doc, "App.closeDocument(\"%s\")", pcDoc->getDocument()->getName());
if (!d->activeDocument && d->documents.size()) {
Document *gdoc = nullptr;
for(auto &v : d->documents) {
if (v.second->getDocument()->testStatus(App::Document::TempDoc))
continue;
else if (!gdoc)
gdoc = v.second;
Gui::MDIView* view = v.second->getActiveView();
if(view) {
if (view) {
setActiveDocument(v.second);
getMainWindow()->setActiveWindow(view);
return;
}
}
auto gdoc = d->documents.begin()->second;
setActiveDocument(gdoc);
activateView(View3DInventor::getClassTypeId(),true);
if (gdoc) {
setActiveDocument(gdoc);
activateView(View3DInventor::getClassTypeId(),true);
}
}
}
catch (const Base::Exception& e) {