return aObject->data()->name().c_str();
}
case HistoryObject: {
- ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 4);
+ ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - getRowsNumber());
if (aObject)
return aObject->data()->name().c_str();
}
return QIcon(":pictures/constr_object.png");
}
case HistoryObject: {
- ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 4);
+ ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - getRowsNumber());
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
if (aFeature)
return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
case MyRoot:
{
DocumentPtr aDoc = partDocument();
- if (aDoc)
- return 4 + aDoc->size(ModelAPI_Feature::group());
- else
+ if (aDoc) {
+ return getRowsNumber() + aDoc->size(ModelAPI_Feature::group());
+ } else
return 0;
}
case ParamsFolder:
case 2:
return createIndex(theRow, 0, (qint32) BodiesFolder);
case 3:
- return createIndex(theRow, 0, (qint32) GroupsFolder);
+ {
+ int aSize = partDocument()->size(ModelAPI_ResultGroup::group());
+ if (aSize > 0)
+ return createIndex(theRow, 0, (qint32) GroupsFolder);
+ else
+ return createIndex(theRow, theColumn, (qint32) HistoryObject);
+ }
default:
return createIndex(theRow, theColumn, (qint32) HistoryObject);
}
case GroupObject:
return partDocument()->object(ModelAPI_ResultGroup::group(), theIndex.row());
case HistoryObject:
- return partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 4);
+ return partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - getRowsNumber());
}
return ObjectPtr();
}
QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const
{
- if (theGroup.compare(ModelAPI_ResultParameters::group()) == 0)
+ if (theGroup == ModelAPI_ResultParameters::group())
return createIndex(0, 0, (qint32) ParamsFolder);
- if (theGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
+ if (theGroup == ModelAPI_ResultConstruction::group())
return createIndex(1, 0, (qint32) ConstructFolder);
- if (theGroup.compare(ModelAPI_ResultBody::group()) == 0)
+ if (theGroup == ModelAPI_ResultBody::group())
return createIndex(2, 0, (qint32) BodiesFolder);
- if (theGroup.compare(ModelAPI_ResultGroup::group()) == 0)
+ if (theGroup == ModelAPI_ResultGroup::group())
return createIndex(3, 0, (qint32) GroupsFolder);
return QModelIndex();
}
else if (aGroup == ModelAPI_ResultGroup::group())
return createIndex(aRow, 0, (qint32) GroupObject);
else
- return createIndex(aRow + 4, 0, (qint32) HistoryObject);
+ 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