Salome HOME
Documenting of classes
[modules/shaper.git] / src / XGUI / XGUI_DocumentDataModel.h
1
2 #ifndef XGUI_DocumentDataModel_H
3 #define XGUI_DocumentDataModel_H
4
5 #include <QAbstractItemModel>
6 #include <Event_Listener.h>
7
8 #include <QList>
9
10 class ModelAPI_Document;
11 class XGUI_PartDataModel;
12 class XGUI_TopDataModel;
13
14 /**\class XGUI_DocumentDataModel
15  * \ingroup GUI
16  * \brief This is a proxy data model for Object Browser (QTreeView).
17  * It contains several sub-models for generation of each sub-part of data tree.
18  */
19 class XGUI_DocumentDataModel : public QAbstractItemModel, public Event_Listener
20 {
21   Q_OBJECT
22 public:
23
24
25   XGUI_DocumentDataModel(QObject* theParent);
26   virtual ~XGUI_DocumentDataModel();
27
28   // Event Listener method
29   virtual void processEvent(const Event_Message* theMessage);
30
31
32   virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
33   virtual QVariant headerData(int theSection, Qt::Orientation theOrient,
34                               int theRole = Qt::DisplayRole) const;
35
36   virtual int rowCount(const QModelIndex& theParent = QModelIndex()) const;
37   virtual int columnCount(const QModelIndex& theParent = QModelIndex()) const;
38
39   virtual QModelIndex index(int theRow, int theColumn, 
40                             const QModelIndex &parent = QModelIndex()) const;
41
42   virtual QModelIndex parent(const QModelIndex& theIndex) const;
43
44   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
45
46 private:
47
48   //! Converts QModelIndex of this model to QModelIndex of a one of sub-models.
49   QModelIndex toSourceModel(const QModelIndex& theProxy) const;
50
51   //! Finds a pointer on QModelIndex which is equal to the given one
52   QModelIndex* findModelIndex(const QModelIndex& theIndex) const;
53
54   //! Returns pointer on QModelIndex which is equal to the given one.
55   QModelIndex* getModelIndex(const QModelIndex& theIndex) const;
56
57   //! Deletes all saved pointers on QModelIndex objects.
58   void clearModelIndexes();
59
60   //! Document
61   std::shared_ptr<ModelAPI_Document> myDocument;
62
63   //! Data model of top part of data tree (not parts object)
64   XGUI_TopDataModel* myModel;
65
66   //! Data models for Parts data tree representation (one data model per a one part)
67   QList<XGUI_PartDataModel*> myPartModels;
68
69   //! List of saved QModelIndexes created by sub-models
70   QList<QModelIndex*> myIndexes;
71 };
72
73 #endif