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

@@ -289,8 +289,8 @@ PyObject* DocumentPy::removeObject(PyObject *args)
PyObject* DocumentPy::copyObject(PyObject *args)
{
PyObject *obj, *rec=Py_False;
if (!PyArg_ParseTuple(args, "O|O",&obj,&rec))
PyObject *obj, *rec=Py_False, *retAll=Py_False;
if (!PyArg_ParseTuple(args, "O|OO",&obj,&rec,&retAll))
return NULL; // NULL triggers exception
std::vector<App::DocumentObject*> objs;
@@ -314,8 +314,8 @@ PyObject* DocumentPy::copyObject(PyObject *args)
}
PY_TRY {
auto ret = getDocumentPtr()->copyObject(objs,PyObject_IsTrue(rec));
if(ret.size()==1 && single)
auto ret = getDocumentPtr()->copyObject(objs, PyObject_IsTrue(rec), PyObject_IsTrue(retAll));
if (ret.size()==1 && single)
return ret[0]->getPyObject();
Py::Tuple tuple(ret.size());
@@ -866,11 +866,17 @@ Py::Boolean DocumentPy::getRecomputing(void) const
return Py::Boolean(getDocumentPtr()->testStatus(Document::Status::Recomputing));
}
Py::Boolean DocumentPy::getTransacting() const {
Py::Boolean DocumentPy::getTransacting() const
{
return Py::Boolean(getDocumentPtr()->isPerformingTransaction());
}
Py::String DocumentPy::getOldLabel() const {
Py::String DocumentPy::getOldLabel() const
{
return Py::String(getDocumentPtr()->getOldLabel());
}
Py::Boolean DocumentPy::getTemporary() const
{
return Py::Boolean(getDocumentPtr()->testStatus(Document::TempDoc));
}