//! Returns parent index of the given feature
virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const = 0;
+ //! Returns index corresponded to the group
+ virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
+
protected:
std::shared_ptr<ModelAPI_Document> myDocument;
};
std::shared_ptr<ModelAPI_Document> aDoc = aUpdMsg->document();
if (aDoc == myDocument) { // If root objects
- int aStart = myPartModels.count() - 2;
- delete myPartModels.last();
- myPartModels.removeLast();
- beginRemoveRows(QModelIndex(), aStart, aStart);
- endRemoveRows();
+ if (aUpdMsg->group().compare(PARTS_GROUP) == 0) { // Updsate only Parts group
+ int aStart = myModel->rowCount(QModelIndex()) + myPartModels.size() - 1;
+ beginRemoveRows(QModelIndex(), aStart, aStart);
+ delete myPartModels.last();
+ myPartModels.removeLast();
+ endRemoveRows();
+ } else { // Update top groups (other except parts
+ QModelIndex aIndex = myModel->findGroup(aUpdMsg->group());
+ int aStart = myModel->rowCount(aIndex);
+ aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
+ beginRemoveRows(aIndex, aStart, aStart);
+ endRemoveRows();
+ }
+ } else {
+ XGUI_PartModel* aPartModel = 0;
+ QList<XGUI_PartModel*>::const_iterator aIt;
+ for (aIt = myPartModels.constBegin(); aIt != myPartModels.constEnd(); ++aIt) {
+ if ((*aIt)->hasDocument(aDoc)) {
+ aPartModel = (*aIt);
+ break;
+ }
+ }
+ if (aPartModel) {
+ QModelIndex aIndex = aPartModel->findGroup(aUpdMsg->group());
+ int aStart = aPartModel->rowCount(aIndex);
+ aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
+ beginRemoveRows(aIndex, aStart, aStart);
+ endRemoveRows();
+ }
}
+
// Reset whole tree **************************
} else {
beginResetModel();
return QModelIndex();
}
+QModelIndex XGUI_TopDataModel::findGroup(const std::string& theGroup) const
+{
+ if (theGroup.compare(PARAMETERS_GROUP) == 0)
+ return createIndex(0, 0, (quintptr) ParamsFolder);
+ if (theGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+ return createIndex(1, 0, (quintptr) ConstructFolder);
+ return QModelIndex();
+}
+
//******************************************************************
//******************************************************************
if (theFeature->getGroup().compare(CONSTRUCTIONS_GROUP) == 0)
return createIndex(1, 0, (quintptr) ConstructFolder);
return QModelIndex();
+}
+
+QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const
+{
+ if (theGroup.compare(PARAMETERS_GROUP) == 0)
+ return createIndex(0, 0, (quintptr) ParamsFolder);
+ if (theGroup.compare(CONSTRUCTIONS_GROUP) == 0)
+ return createIndex(1, 0, (quintptr) ConstructFolder);
+ return QModelIndex();
}
\ No newline at end of file
//! Returns 0 if the given index is not index of a feature
virtual FeaturePtr feature(const QModelIndex& theIndex) const;
+ //! Returns parent index of the given feature
virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
+ //! Returns index corresponded to the group
+ virtual QModelIndex findGroup(const std::string& theGroup) const;
+
private:
//! Types of QModelIndexes
enum DataIds {
//! Returns parent index of the given feature
virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
+ //! Returns index corresponded to the group
+ virtual QModelIndex findGroup(const std::string& theGroup) const;
+
private:
std::shared_ptr<ModelAPI_Document> featureDocument() const;