+
+QModelIndex XGUI_DocumentDataModel::featureIndex(const FeaturePtr theFeature) const
+{
+ // Check that this feature belongs to root document
+ DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
+ DocumentPtr aDoc = theFeature->document();
+ if (aDoc == aRootDoc) {
+ // This feature belongs to histrory or top model
+ if (theFeature->isInHistory()) {
+ int aId;
+ for (aId = 0; aId < aRootDoc->size(FEATURES_GROUP); aId++) {
+ if (theFeature == aRootDoc->feature(FEATURES_GROUP, aId))
+ break;
+ }
+ return index(aId + historyOffset(), 0, QModelIndex());
+ } else {
+ QModelIndex aIndex = myModel->featureIndex(theFeature);
+ return aIndex.isValid()?
+ createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)) :
+ QModelIndex();
+ }
+ } else {
+ XGUI_PartModel* aPartModel = 0;
+ foreach(XGUI_PartModel* aModel, myPartModels) {
+ if (aModel->hasDocument(aDoc)) {
+ aPartModel = aModel;
+ break;
+ }
+ }
+ if (aPartModel) {
+ QModelIndex aIndex = aPartModel->featureIndex(theFeature);
+ return aIndex.isValid()?
+ createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)) :
+ QModelIndex();
+ }
+ }
+ return QModelIndex();
+}
\ No newline at end of file