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