Salome HOME
0d9a394af72ef34037cf1e0bf6e5836b096033a4
[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     //GroupsFolder,
57     //GroupObject
58   };
59
60 };
61
62 /**\class XGUI_PartDataModel
63  * \ingroup GUI
64  * \brief This is a data model for Object Browser (QTreeView).
65  * It represents data tree only of a one part
66  */
67 class XGUI_PartDataModel : public XGUI_PartModel
68 {
69 Q_OBJECT
70  public:
71   XGUI_PartDataModel(QObject* theParent);
72   virtual ~XGUI_PartDataModel();
73
74   // Reimpl from QAbstractItemModel
75   virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
76   virtual QVariant headerData(int section, Qt::Orientation orientation,
77                               int role = Qt::DisplayRole) const;
78
79   virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
80   virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
81
82   virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent =
83                                 QModelIndex()) const;
84
85   virtual QModelIndex parent(const QModelIndex& theIndex) const;
86
87   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
88
89   //! Returns object by the given Model index.
90   //! Returns 0 if the given index is not index of a object
91   virtual ObjectPtr object(const QModelIndex& theIndex) const;
92
93   //! Returns QModelIndex which corresponds to the given object
94   //! If the object is not found then index is not valid
95   virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
96
97   //! Returns true if the given document is a sub-document of this tree
98   virtual bool hasDocument(const DocumentPtr& theDoc) const;
99
100   //! Returns parent index of the given object
101   virtual QModelIndex findParent(const ObjectPtr& theObject) const;
102
103   //! Returns index corresponded to the group
104   virtual QModelIndex findGroup(const std::string& theGroup) const;
105
106   //! Return a Part object
107   virtual ResultPartPtr part() const;
108
109  private:
110
111   //! Returns document of the current part
112   DocumentPtr partDocument() const;
113
114   int getRowsNumber() const;
115
116   //! Types of QModelIndexes
117   enum DataIds
118   {
119     MyRoot,
120     ParamsFolder,
121     ParamObject,
122     ConstructFolder,
123     ConstructObject,
124     BodiesFolder,
125     BodiesObject,
126     GroupsFolder,
127     GroupObject,
128     HistoryObject
129   };
130
131 };
132
133 #endif