+ return createIndex(foldersCount() - 1, 2, -1);
+ else
+ return createIndex(foldersCount(aCurDoc.get()) - 1, 2, aCurDoc.get());
+ }
+}
+
+//******************************************************
+int XGUI_DataModel::folderId(std::string theType, ModelAPI_Document* theDoc) const
+{
+ 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;
+}
+
+//******************************************************
+void XGUI_DataModel::rebuildBranch(int theRow, int theCount, const QModelIndex& theParent)
+{
+ if (theCount > 0) {
+ removeRows(theRow, theCount, theParent);
+ insertRows(theRow, theCount, theParent);
+ }
+}
+
+//******************************************************
+//bool XGUI_DataModel::blockEventsProcessing(const bool theState)
+//{
+// bool aPreviousState = myIsEventsProcessingBlocked;
+// myIsEventsProcessingBlocked = theState;
+// return aPreviousState;
+//}
+
+//******************************************************
+XGUI_DataModel::VisibilityState
+ XGUI_DataModel::getVisibilityState(const QModelIndex& theIndex) const
+{
+ Qt::ItemFlags aFlags = theIndex.flags();
+ if (aFlags == Qt::ItemFlags())
+ return NoneState;
+
+ ObjectPtr aObj = object(theIndex);
+ if (aObj.get()) {
+ if (aObj->groupName() == ModelAPI_ResultParameter::group())
+ return NoneState;
+ ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ if (aResObj.get()) {
+ XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResObj);
+ if (aCompRes.get()) {
+ VisibilityState aState = aCompRes->numberOfSubs(true) == 0 ?
+ (aDisplayer->isVisible(aCompRes)? Visible : Hidden) : NoneState;
+ for (int i = 0; i < aCompRes->numberOfSubs(true); i++) {
+ ResultPtr aSubRes = aCompRes->subResult(i, true);
+ VisibilityState aS = aDisplayer->isVisible(aSubRes)? Visible : Hidden;
+ if (aState == NoneState)
+ aState = aS;
+ else if (aState != aS) {
+ aState = SemiVisible;
+ break;
+ }
+ }
+ return aState;
+ } else {
+ if (aDisplayer->isVisible(aResObj))
+ return Visible;
+ else
+ return Hidden;
+ }
+ }