1 #include "XGUI_DocumentDataModel.h"
3 #include <ModelAPI_PluginManager.h>
4 #include <ModelAPI_Iterator.h>
5 #include <ModelAPI_Document.h>
10 XGUI_DocumentDataModel::XGUI_DocumentDataModel(QObject* theParent)
11 : QAbstractItemModel(theParent),
15 //std::shared_ptr<ModelAPI_Feature> myRoot = aMgr->createFeature("Point");
16 std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
17 myDocument = aMgr->currentDocument();
21 XGUI_DocumentDataModel::~XGUI_DocumentDataModel()
26 QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole) const
31 if (theIndex.internalId() == quintptr(&myParamsFolder))
33 else if (theIndex.internalId() == quintptr(&myConstructFolder))
34 return "Constructions";
35 else if (theIndex.internalId() == 0) {
39 case Qt::DecorationRole:
50 QVariant XGUI_DocumentDataModel::headerData(int section, Qt::Orientation orientation, int role) const
55 int XGUI_DocumentDataModel::rowCount(const QModelIndex &parent) const
57 std::shared_ptr<ModelAPI_Iterator> aIt = myDocument->featuresIterator(PARTS_GROUP);
58 return aIt->numIterationsLeft() + 2;
61 int XGUI_DocumentDataModel::columnCount(const QModelIndex &parent) const
66 QModelIndex XGUI_DocumentDataModel::index(int theRow, int theColumn, const QModelIndex& theParent) const
70 return createIndex(theRow, theColumn, (quintptr) &myParamsFolder);
72 return createIndex(theRow, theColumn, (quintptr) &myConstructFolder);
75 std::shared_ptr<ModelAPI_Iterator> aIt = myDocument->featuresIterator(PARTS_GROUP);
76 if (aIt->numIterationsLeft() <= (theRow - 1)) {
77 return createIndex(theRow, theColumn, (quintptr) 0);
85 QModelIndex XGUI_DocumentDataModel::parent(const QModelIndex &index) const
90 bool XGUI_DocumentDataModel::hasChildren(const QModelIndex& theParent) const
92 if (!theParent.isValid())
95 if (theParent.internalId() == quintptr(&myParamsFolder))
96 return myDocument->featuresIterator(PARAMETERS_GROUP)->more();
97 if (theParent.internalId() == quintptr(&myConstructFolder))
98 return myDocument->featuresIterator(CONSTRUCTIONS_GROUP)->more();
99 if (theParent.internalId() == 0)