+
+//******************************************************
+QModelIndex XGUI_DataModel::documentRootIndex(DocumentPtr theDoc) const
+{
+ SessionPtr aSession = ModelAPI_Session::get();
+ DocumentPtr aRootDoc = aSession->moduleDocument();
+ if (theDoc == aRootDoc)
+ return QModelIndex();
+ else
+ return findDocumentRootIndex(theDoc.get());
+}
+
+//******************************************************
+int XGUI_DataModel::foldersCount(ModelAPI_Document* theDoc) const
+{
+ int aNb = 0;
+ SessionPtr aSession = ModelAPI_Session::get();
+ DocumentPtr aRootDoc = aSession->moduleDocument();
+ if ((theDoc == 0) || (theDoc == aRootDoc.get())) {
+ for (int i = 0; i < myXMLReader.rootFoldersNumber(); i++) {
+ if (myXMLReader.rootShowEmpty(i))
+ aNb++;
+ else {
+ if (aRootDoc->size(myXMLReader.rootFolderType(i)) > 0)
+ aNb++;
+ }
+ }
+ } else {
+ for (int i = 0; i < myXMLReader.subFoldersNumber(); i++) {
+ if (myXMLReader.subShowEmpty(i))
+ aNb++;
+ else {
+ if (theDoc->size(myXMLReader.subFolderType(i)) > 0)
+ aNb++;
+ }
+ }
+ }
+ return aNb;
+}
+
+//******************************************************
+QStringList XGUI_DataModel::listOfShowNotEmptyFolders(bool fromRoot) const
+{
+ QStringList aResult;
+ if (fromRoot) {
+ for (int i = 0; i < myXMLReader.rootFoldersNumber(); i++) {
+ if (!myXMLReader.rootShowEmpty(i))
+ aResult << myXMLReader.rootFolderType(i).c_str();
+ }
+ } else {
+ for (int i = 0; i < myXMLReader.subFoldersNumber(); i++) {
+ if (!myXMLReader.subShowEmpty(i))
+ aResult << myXMLReader.subFolderType(i).c_str();
+ }
+ }
+ return aResult;
+}
+
+//******************************************************
+QModelIndex XGUI_DataModel::lastHistoryIndex() const
+{
+ SessionPtr aSession = ModelAPI_Session::get();
+ DocumentPtr aCurDoc = aSession->activeDocument();
+ FeaturePtr aFeature = aCurDoc->currentFeature(true);
+ if (aFeature.get()) {
+ QModelIndex aInd = objectIndex(aFeature);
+ return createIndex(aInd.row(), 1, aInd.internalPointer());
+ } else {
+ if (aCurDoc == aSession->moduleDocument())
+ return createIndex(foldersCount() - 1, 1, -1);
+ else
+ return createIndex(foldersCount(aCurDoc.get()) - 1, 1, aCurDoc.get());
+ }
+}
\ No newline at end of file