Salome HOME
559f007329ec32dbb8c2037854234aa73c65492a
[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 private:
39   //! Types of QModelIndexes
40   enum DataIds {
41     ParamsFolder,
42     ParamObject,
43     ConstructFolder,
44     ConstructObject
45   };
46
47 };
48
49
50 /**\class XGUI_PartDataModel
51  * \ingroup GUI
52  * \brief This is a data model for Object Browser (QTreeView).
53  * It represents data tree only of a one part
54  */
55 class XGUI_PartDataModel : public XGUI_PartModel
56 {
57   Q_OBJECT
58 public:
59   XGUI_PartDataModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
60   virtual ~XGUI_PartDataModel();
61
62   // Reimplementation from QAbstractItemModel
63   virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
64   virtual QVariant headerData(int section, Qt::Orientation orientation,
65                               int role = Qt::DisplayRole) const;
66
67   virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
68   virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
69
70   virtual QModelIndex index(int theRow, int theColumn, 
71                             const QModelIndex& theParent = QModelIndex()) const;
72
73   virtual QModelIndex parent(const QModelIndex& theIndex) const;
74
75   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
76
77   //! Returns Feature object by the given Model index.
78   //! Returns 0 if the given index is not index of a feature
79   virtual FeaturePtr feature(const QModelIndex& theIndex) const;
80
81 private: 
82   std::shared_ptr<ModelAPI_Document> featureDocument() const;
83
84   //! Types of QModelIndexes
85   enum DataIds {
86     MyRoot,
87     ParamsFolder,
88     ParamObject,
89     ConstructFolder,
90     ConstructObject
91   };
92
93 };
94
95 #endif