+
+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