From 2af52b19b485181c61d1065fa45ec24b94cb1449 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 15 May 2014 09:21:38 +0400 Subject: [PATCH] Nested operations --- src/Model/Model_Document.cpp | 7 +++++++ src/Model/Model_Document.h | 2 ++ src/PartSetPlugin/PartSetPlugin_Part.h | 3 +++ 3 files changed, 12 insertions(+) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 9d8c2c12a..274fc6f1b 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -168,6 +168,10 @@ void Model_Document::close() void Model_Document::startOperation() { + // check is it nested or not + if (myDoc->HasOpenCommand()) { + myIsNested = true; + } // new command for this myDoc->NewCommand(); // new command for all subs @@ -181,6 +185,7 @@ void Model_Document::finishOperation() // returns false if delta is empty and no transaction was made myIsEmptyTr[myTransactionsAfterSave] = !myDoc->CommitCommand(); myTransactionsAfterSave++; + myIsNested = false; // finish for all subs set::iterator aSubIter = mySubs.begin(); for(; aSubIter != mySubs.end(); aSubIter++) @@ -393,6 +398,8 @@ Model_Document::Model_Document(const std::string theID) { myDoc->SetUndoLimit(UNDO_LIMIT); myTransactionsAfterSave = 0; + myIsNested = false; + myDoc->SetNestedTransactionMode(); // to have something in the document and avoid empty doc open/save problem TDataStd_Integer::Set(myDoc->Main().Father(), 0); } diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 0bf22b98e..b314d9dc8 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -120,6 +120,8 @@ private: std::set mySubs; ///< set of identifiers of sub-documents of this document /// transaction indexes (related to myTransactionsAfterSave) which were empty in this doc std::map myIsEmptyTr; + /// true if the current operation is nested + bool myIsNested; }; #endif diff --git a/src/PartSetPlugin/PartSetPlugin_Part.h b/src/PartSetPlugin/PartSetPlugin_Part.h index 25af3bea7..eaae463ad 100644 --- a/src/PartSetPlugin/PartSetPlugin_Part.h +++ b/src/PartSetPlugin/PartSetPlugin_Part.h @@ -34,6 +34,9 @@ public: PARTSETPLUGIN_EXPORT virtual boost::shared_ptr documentToAdd(); + /// Returns true if this feature must be displayed in the history (top level of Part tree) + PARTSETPLUGIN_EXPORT virtual bool isInHistory() {return false;} + /// Use plugin manager for features creation PartSetPlugin_Part(); }; -- 2.39.2