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