+
+QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const
+{
+ if (theGroup == ModelAPI_ResultParameter::group())
+ return createIndex(0, 0, (qint32) ParamsFolder);
+ if (theGroup == ModelAPI_ResultConstruction::group())
+ return createIndex(1, 0, (qint32) ConstructFolder);
+ if (theGroup == ModelAPI_ResultBody::group())
+ return createIndex(2, 0, (qint32) BodiesFolder);
+ if (theGroup == ModelAPI_ResultGroup::group())
+ return createIndex(3, 0, (qint32) GroupsFolder);
+ return QModelIndex();
+}
+
+ResultPartPtr XGUI_PartDataModel::part() const
+{
+ DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
+ ObjectPtr aObj = aRootDoc->object(ModelAPI_ResultPart::group(), myId);
+ return std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObj);
+}
+
+QModelIndex XGUI_PartDataModel::objectIndex(const ObjectPtr& theObject) const
+{
+ QModelIndex aIndex;
+ if (theObject) {
+ if (part() == theObject)
+ return aIndex;
+
+ std::string aGroup = theObject->groupName();
+ DocumentPtr aDoc = theObject->document();
+ int aNb = aDoc->size(aGroup);
+ int aRow = -1;
+ for (int i = 0; i < aNb; i++) {
+ if (aDoc->object(aGroup, i) == theObject) {
+ aRow = i;
+ break;
+ }
+ }
+ if (aRow == -1)
+ return aIndex;
+ if (aGroup == ModelAPI_ResultParameter::group())
+ return createIndex(aRow, 0, (qint32) ParamObject);
+ else if (aGroup == ModelAPI_ResultConstruction::group())
+ return createIndex(aRow, 0, (qint32) ConstructObject);
+ else if (aGroup == ModelAPI_ResultBody::group())
+ return createIndex(aRow, 0, (qint32) BodiesObject);
+ else if (aGroup == ModelAPI_ResultGroup::group())
+ return createIndex(aRow, 0, (qint32) GroupObject);
+ else
+ return createIndex(aRow + getRowsNumber(), 0, (qint32) HistoryObject);
+ }
+ return aIndex;
+}
+
+
+int XGUI_PartDataModel::getRowsNumber() const
+{
+ int aSize = partDocument()->size(ModelAPI_ResultGroup::group());
+ if (aSize == 0) // If there are no groups then do not show group folder
+ return 3;
+ return 4;
+}
\ No newline at end of file