+ return FeaturePtr();
+}
+
+bool XGUI_PartDataModel::hasDocument(const DocumentPtr& theDoc) const
+{
+ return (featureDocument() == theDoc);
+}
+
+
+QModelIndex XGUI_PartDataModel::findParent(const FeaturePtr& theFeature) const
+{
+ return findGroup(theFeature->getGroup().c_str());
+}
+
+QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const
+{
+ if (theGroup.compare(PARAMETERS_GROUP) == 0)
+ return createIndex(0, 0, (qint32) ParamsFolder);
+ if (theGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+ return createIndex(1, 0, (qint32) ConstructFolder);
+ return QModelIndex();
+}
+
+FeaturePtr XGUI_PartDataModel::part() const
+{
+ DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
+ return aRootDoc->feature(PARTS_GROUP, myId, true);
+}
+
+QModelIndex XGUI_PartDataModel::featureIndex(const FeaturePtr& theFeature) const
+{
+ QModelIndex aIndex;
+ if (theFeature) {
+ if (part() == theFeature)
+ return aIndex;
+
+ std::string aGroup = theFeature->getGroup();
+ DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
+ int aNb = aRootDoc->size(aGroup);
+ int aRow = -1;
+ for (int i = 0; i < aNb; i++) {
+ if (aRootDoc->feature(aGroup, i) == theFeature) {
+ aRow = i;
+ break;
+ }
+ }
+ if (aRow != -1) {
+ if (aGroup.compare(PARAMETERS_GROUP) == 0)
+ return createIndex(aRow, 0, (qint32) ParamObject);
+ if (aGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+ return createIndex(aRow, 0, (qint32) ConstructObject);
+ }
+ }
+ return aIndex;