2 #ifndef XGUI_PartDataModel_H
3 #define XGUI_PartDataModel_H
5 #include "XGUI_DataTreeModel.h"
7 /**\class XGUI_TopDataModel
9 * \brief This is a data model for Object Browser (QTreeView).
10 * It represents only upper part of data tree (non-parts tree items)
12 class XGUI_TopDataModel : public XGUI_FeaturesModel
16 XGUI_TopDataModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
17 virtual ~XGUI_TopDataModel();
19 // Reimplementation from QAbstractItemModel
20 virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
21 virtual QVariant headerData(int section, Qt::Orientation orientation,
22 int role = Qt::DisplayRole) const;
24 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
25 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
27 virtual QModelIndex index(int theRow, int theColumn,
28 const QModelIndex& theParent = QModelIndex()) const;
30 virtual QModelIndex parent(const QModelIndex& theIndex) const;
32 virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
34 //! Returns Feature object by the given Model index.
35 //! Returns 0 if the given index is not index of a feature
36 virtual FeaturePtr feature(const QModelIndex& theIndex) const;
38 virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
41 //! Types of QModelIndexes
52 /**\class XGUI_PartDataModel
54 * \brief This is a data model for Object Browser (QTreeView).
55 * It represents data tree only of a one part
57 class XGUI_PartDataModel : public XGUI_PartModel
61 XGUI_PartDataModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
62 virtual ~XGUI_PartDataModel();
64 // Reimplementation from QAbstractItemModel
65 virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
66 virtual QVariant headerData(int section, Qt::Orientation orientation,
67 int role = Qt::DisplayRole) const;
69 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
70 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
72 virtual QModelIndex index(int theRow, int theColumn,
73 const QModelIndex& theParent = QModelIndex()) const;
75 virtual QModelIndex parent(const QModelIndex& theIndex) const;
77 virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
79 //! Returns Feature object by the given Model index.
80 //! Returns 0 if the given index is not index of a feature
81 virtual FeaturePtr feature(const QModelIndex& theIndex) const;
83 //! Returns true if the given document is a sub-document of this tree
84 virtual bool hasDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) const;
86 //! Returns parent index of the given feature
87 virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
90 std::shared_ptr<ModelAPI_Document> featureDocument() const;
92 //! Types of QModelIndexes