Salome HOME
Bodies folder in Part data tree
[modules/shaper.git] / src / XGUI / XGUI_PartDataModel.h
1
2 #ifndef XGUI_PartDataModel_H
3 #define XGUI_PartDataModel_H
4
5 #include "XGUI.h"
6 #include "XGUI_DataTreeModel.h"
7
8 /**\class XGUI_TopDataModel
9  * \ingroup GUI
10  * \brief This is a data model for Object Browser (QTreeView).
11  * It represents only upper part of data tree (non-parts tree items)
12  */
13 class XGUI_EXPORT XGUI_TopDataModel : public XGUI_FeaturesModel
14 {
15   Q_OBJECT
16 public:
17   XGUI_TopDataModel(QObject* theParent);
18   virtual ~XGUI_TopDataModel();
19
20   // Reimpl from QAbstractItemModel
21   virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
22   virtual QVariant headerData(int section, Qt::Orientation orientation,
23                               int role = Qt::DisplayRole) const;
24
25   virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
26   virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
27
28   virtual QModelIndex index(int theRow, int theColumn, 
29                             const QModelIndex& theParent = QModelIndex()) const;
30
31   virtual QModelIndex parent(const QModelIndex& theIndex) const;
32
33   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
34
35   //! Returns object by the given Model index.
36   //! Returns 0 if the given index is not index of a object
37   virtual ObjectPtr object(const QModelIndex& theIndex) const;
38
39   //! Returns QModelIndex which corresponds to the given object
40   //! If the object is not found then index is not valid
41   virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
42
43   //! Returns parent index of the given object
44   virtual QModelIndex findParent(const ObjectPtr& theObject) const;
45
46   //! Returns index corresponded to the group
47   virtual QModelIndex findGroup(const std::string& theGroup) const;
48
49 private:
50   //! Types of QModelIndexes
51   enum DataIds {
52     ParamsFolder,
53     ParamObject,
54     ConstructFolder,
55     ConstructObject,
56     BodiesFolder,
57     BodiesObject
58   };
59
60 };
61
62
63 /**\class XGUI_PartDataModel
64  * \ingroup GUI
65  * \brief This is a data model for Object Browser (QTreeView).
66  * It represents data tree only of a one part
67  */
68 class XGUI_PartDataModel : public XGUI_PartModel
69 {
70   Q_OBJECT
71 public:
72   XGUI_PartDataModel(QObject* theParent);
73   virtual ~XGUI_PartDataModel();
74
75   // Reimpl from QAbstractItemModel
76   virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
77   virtual QVariant headerData(int section, Qt::Orientation orientation,
78                               int role = Qt::DisplayRole) const;
79
80   virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
81   virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
82
83   virtual QModelIndex index(int theRow, int theColumn, 
84                             const QModelIndex& theParent = QModelIndex()) const;
85
86   virtual QModelIndex parent(const QModelIndex& theIndex) const;
87
88   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
89
90   //! Returns object by the given Model index.
91   //! Returns 0 if the given index is not index of a object
92   virtual ObjectPtr object(const QModelIndex& theIndex) const;
93
94   //! Returns QModelIndex which corresponds to the given object
95   //! If the object is not found then index is not valid
96   virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
97
98   //! Returns true if the given document is a sub-document of this tree
99   virtual bool hasDocument(const DocumentPtr& theDoc) const;
100
101   //! Returns parent index of the given object
102   virtual QModelIndex findParent(const ObjectPtr& theObject) const;
103
104   //! Returns index corresponded to the group
105   virtual QModelIndex findGroup(const std::string& theGroup) const;
106
107   //! Return a Part object
108   virtual ResultPartPtr part() const;
109
110 private: 
111
112   //! Returns document of the current part
113   DocumentPtr partDocument() const;
114
115   //! Types of QModelIndexes
116   enum DataIds {
117     MyRoot,
118     ParamsFolder,
119     ParamObject,
120     ConstructFolder,
121     ConstructObject,
122     BodiesFolder,
123     BodiesObject,
124     HistoryObject
125   };
126
127 };
128
129 #endif