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 //! Returns parent index of the given feature
39 virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
41 //! Returns index corresponded to the group
42 virtual QModelIndex findGroup(const std::string& theGroup) const;
45 //! Types of QModelIndexes
56 /**\class XGUI_PartDataModel
58 * \brief This is a data model for Object Browser (QTreeView).
59 * It represents data tree only of a one part
61 class XGUI_PartDataModel : public XGUI_PartModel
65 XGUI_PartDataModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
66 virtual ~XGUI_PartDataModel();
68 // Reimplementation from QAbstractItemModel
69 virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
70 virtual QVariant headerData(int section, Qt::Orientation orientation,
71 int role = Qt::DisplayRole) const;
73 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
74 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
76 virtual QModelIndex index(int theRow, int theColumn,
77 const QModelIndex& theParent = QModelIndex()) const;
79 virtual QModelIndex parent(const QModelIndex& theIndex) const;
81 virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
83 //! Returns Feature object by the given Model index.
84 //! Returns 0 if the given index is not index of a feature
85 virtual FeaturePtr feature(const QModelIndex& theIndex) const;
87 //! Returns true if the given document is a sub-document of this tree
88 virtual bool hasDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) const;
90 //! Returns parent index of the given feature
91 virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
93 //! Returns index corresponded to the group
94 virtual QModelIndex findGroup(const std::string& theGroup) const;
97 std::shared_ptr<ModelAPI_Document> featureDocument() const;
99 //! Types of QModelIndexes