From: vsv Date: Mon, 14 Nov 2016 13:19:00 +0000 (+0300) Subject: Issue #1855: Open a folder (Constructions or Result) on first created object X-Git-Tag: V_2.6.0~90 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=45c468680156e1c25cfd9b66ab0438f658742594;p=modules%2Fshaper.git Issue #1855: Open a folder (Constructions or Result) on first created object --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index bda26290a..921205e73 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1236,7 +1236,6 @@ void PartSet_Module::processEvent(const std::shared_ptr& theMess QObjectPtrList aObjects = aDisplayer->displayedObjects(); bool aHidden; foreach(ObjectPtr aObj, aObjects) { - //TODO: replace by redisplay event. aHidden = !aObj->data() || !aObj->data()->isValid() || aObj->isDisabled() || (!aObj->isDisplayed()); if (!aHidden) @@ -1251,12 +1250,14 @@ void PartSet_Module::processEvent(const std::shared_ptr& theMess ObjectPtr aConstrObj; ObjectPtr aResultObj; std::set::const_iterator aIt; - std::string aObjType; + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { ObjectPtr aObject = (*aIt); - if ((!aResultObj.get()) && aObject->groupName() == ModelAPI_ResultBody::group()) + if ((!aResultObj.get()) && (aObject->groupName() == ModelAPI_ResultBody::group()) + && (aObject->document() != aRootDoc)) aResultObj = aObject; - if ((!aConstrObj.get()) && aObject->groupName() == ModelAPI_ResultConstruction::group()) + if ((!aConstrObj.get()) && (aObject->groupName() == ModelAPI_ResultConstruction::group()) + && (aObject->document() != aRootDoc)) aConstrObj = aObject; if (aResultObj.get() && aConstrObj.get()) break; diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 8d05f330f..6e0acaba8 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -677,7 +677,7 @@ QModelIndex XGUI_DataModel::parent(const QModelIndex& theIndex) const return findDocumentRootIndex(aSubDoc.get()); else { // return first level of folder index - int aFolderId = myXMLReader->subFolderId(aType); + int aFolderId = folderId(aType, aSubDoc.get()); // Items in a one row must have the same parent return createIndex(aFolderId, 0, aSubDoc.get()); } @@ -920,7 +920,7 @@ QModelIndex XGUI_DataModel::lastHistoryIndex() const } //****************************************************** -int XGUI_DataModel::folderId(std::string theType, ModelAPI_Document* theDoc) +int XGUI_DataModel::folderId(std::string theType, ModelAPI_Document* theDoc) const { SessionPtr aSession = ModelAPI_Session::get(); ModelAPI_Document* aDoc = theDoc; diff --git a/src/XGUI/XGUI_DataModel.h b/src/XGUI/XGUI_DataModel.h index ed5652d04..a57f85c20 100644 --- a/src/XGUI/XGUI_DataModel.h +++ b/src/XGUI/XGUI_DataModel.h @@ -147,7 +147,7 @@ private: /// folders which can not be shown non empty /// \param theType Type of the folder /// \param theDoc a document which contains this folder - int folderId(std::string theType, ModelAPI_Document* theDoc = 0); + int folderId(std::string theType, ModelAPI_Document* theDoc = 0) const; /// Removes a row from branch of tree /// \param theStart - start row to update indexes