#include <QIcon>
-XGUI_TopDataModel::XGUI_TopDataModel(QObject* theParent)
- : QAbstractItemModel(theParent)
+XGUI_TopDataModel::XGUI_TopDataModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent)
+ : XGUI_FeaturesModel(theDocument, theParent)
{
}
return rowCount(theParent) > 0;
}
+FeaturePtr XGUI_TopDataModel::feature(const QModelIndex& theIndex) const
+{
+ switch (theIndex.internalId()) {
+ case ParamsFolder:
+ case ConstructFolder:
+ return 0;
+ case ParamObject:
+ return myDocument->feature(PARAMETERS_GROUP, theIndex.row());
+ case ConstructObject:
+ return myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ }
+ return 0;
+}
+
//******************************************************************
//******************************************************************
//******************************************************************
-XGUI_PartDataModel::XGUI_PartDataModel(QObject* theParent)
- : QAbstractItemModel(theParent)
+XGUI_PartDataModel::XGUI_PartDataModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent)
+ : XGUI_PartModel(theDocument, theParent)
{
}
QModelIndex XGUI_PartDataModel::parent(const QModelIndex& theIndex) const
{
- int aId = (int)theIndex.internalId();
- switch (aId) {
+ switch (theIndex.internalId()) {
case MyRoot:
return QModelIndex();
case ParamsFolder:
{
std::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARTS_GROUP, myId);
return aFeature->data()->docRef("PartDocument")->value();
-}
\ No newline at end of file
+}
+
+FeaturePtr XGUI_PartDataModel::feature(const QModelIndex& theIndex) const
+{
+ switch (theIndex.internalId()) {
+ case MyRoot:
+ return myDocument->feature(PARTS_GROUP, myId);
+ case ParamsFolder:
+ case ConstructFolder:
+ return 0;
+ case ParamObject:
+ return featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
+ case ConstructObject:
+ return featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ }
+ return 0;
+}