Salome HOME
Release version on WIndows
[modules/shaper.git] / src / XGUI / XGUI_PartDataModel.h
1
2 #ifndef XGUI_PartDataModel_H
3 #define XGUI_PartDataModel_H
4
5 #include "XGUI_DataTreeModel.h"
6
7 /**\class XGUI_TopDataModel
8  * \ingroup GUI
9  * \brief This is a data model for Object Browser (QTreeView).
10  * It represents only upper part of data tree (non-parts tree items)
11  */
12 class XGUI_TopDataModel : public XGUI_FeaturesModel
13 {
14   Q_OBJECT
15 public:
16   XGUI_TopDataModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
17   virtual ~XGUI_TopDataModel();
18
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;
23
24   virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
25   virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
26
27   virtual QModelIndex index(int theRow, int theColumn, 
28                             const QModelIndex& theParent = QModelIndex()) const;
29
30   virtual QModelIndex parent(const QModelIndex& theIndex) const;
31
32   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
33
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;
37
38   virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
39
40 private:
41   //! Types of QModelIndexes
42   enum DataIds {
43     ParamsFolder,
44     ParamObject,
45     ConstructFolder,
46     ConstructObject
47   };
48
49 };
50
51
52 /**\class XGUI_PartDataModel
53  * \ingroup GUI
54  * \brief This is a data model for Object Browser (QTreeView).
55  * It represents data tree only of a one part
56  */
57 class XGUI_PartDataModel : public XGUI_PartModel
58 {
59   Q_OBJECT
60 public:
61   XGUI_PartDataModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
62   virtual ~XGUI_PartDataModel();
63
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;
68
69   virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
70   virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
71
72   virtual QModelIndex index(int theRow, int theColumn, 
73                             const QModelIndex& theParent = QModelIndex()) const;
74
75   virtual QModelIndex parent(const QModelIndex& theIndex) const;
76
77   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
78
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;
82
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;
85
86   //! Returns parent index of the given feature
87   virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
88
89 private: 
90   std::shared_ptr<ModelAPI_Document> featureDocument() const;
91
92   //! Types of QModelIndexes
93   enum DataIds {
94     MyRoot,
95     ParamsFolder,
96     ParamObject,
97     ConstructFolder,
98     ConstructObject
99   };
100
101 };
102
103 #endif