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