From: vsv Date: Wed, 26 Aug 2015 14:54:39 +0000 (+0300) Subject: Fix for update of "Bodies" folder (disappear an expanding folder icon) X-Git-Tag: V_1.4.0_beta4~234 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=d296db28ebf945ae475f2331cd2e8f813618866b;p=modules%2Fshaper.git Fix for update of "Bodies" folder (disappear an expanding folder icon) --- diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 075317acb..4a54e941b 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -128,7 +128,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess } else { // List of objects under a folder if (aRow != -1) { - int aFolderId = myXMLReader.subFolderId(aObjType); + int aFolderId = folderId(aObjType, aDoc.get()); if (aFolderId != -1) { insertRow(aRow, createIndex(aFolderId, 0, aDoc.get())); } @@ -179,7 +179,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess removeRow(aRow + aNbSubFolders, aDocRoot); } else { // List of objects under a folder - int aFolderId = myXMLReader.subFolderId(aGroup); + int aFolderId = folderId(aGroup, aDoc.get()); if (aFolderId != -1) { removeRow(aRow, createIndex(aFolderId, 0, aDoc.get())); } @@ -474,7 +474,11 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex & ModelAPI_Document* aDoc = getSubDocument(theParent.internalPointer()); if (aDoc) { // It is a folder of sub-document - std::string aType = myXMLReader.subFolderType(aParentPos); + int aParentRow = aParentPos; + QIntList aMissedIdx = missedFolderIndexes(aDoc); + while (aMissedIdx.contains(aParentRow)) + aParentRow++; + std::string aType = myXMLReader.subFolderType(aParentRow); if (theRow < aDoc->size(aType)) { ObjectPtr aObj = aDoc->object(aType, theRow); aIndex = objectIndex(aObj); @@ -806,4 +810,37 @@ QModelIndex XGUI_DataModel::lastHistoryIndex() const else return createIndex(foldersCount(aCurDoc.get()) - 1, 1, aCurDoc.get()); } -} \ No newline at end of file +} + +//****************************************************** +int XGUI_DataModel::folderId(std::string theType, ModelAPI_Document* theDoc) +{ + SessionPtr aSession = ModelAPI_Session::get(); + ModelAPI_Document* aDoc = theDoc; + if (aDoc == 0) + aDoc = aSession->moduleDocument().get(); + + bool aUseSubDoc = (aDoc != aSession->moduleDocument().get()); + + int aRes = -1; + if (aUseSubDoc) { + int aId = myXMLReader.subFolderId(theType); + aRes = aId; + for (int i = 0; i < aId; i++) { + if (!myXMLReader.subShowEmpty(i)) { + if (aDoc->size(myXMLReader.subFolderType(i)) == 0) + aRes--; + } + } + } else { + int aId = myXMLReader.rootFolderId(theType); + aRes = aId; + for (int i = 0; i < aId; i++) { + if (!myXMLReader.rootShowEmpty(i)) { + if (aDoc->size(myXMLReader.rootFolderType(i)) == 0) + aRes--; + } + } + } + return aRes; +} diff --git a/src/XGUI/XGUI_DataModel.h b/src/XGUI/XGUI_DataModel.h index 4e74b5468..70f537651 100644 --- a/src/XGUI/XGUI_DataModel.h +++ b/src/XGUI/XGUI_DataModel.h @@ -127,6 +127,11 @@ private: /// \param theDoc document which has to be checked. If 0 then Root document will be considered QIntList missedFolderIndexes(ModelAPI_Document* theDoc = 0) const; + /// Returns Id (row) of a folder taking into consideration 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); + /// Returns list of folders types which can not be shown empty /// \param fromRoot - root document flag QStringList listOfShowNotEmptyFolders(bool fromRoot = true) const;