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