Salome HOME
Merge branch 'master' of newgeom:newgeom
[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
15 class XGUI_DocumentDataModel : public QAbstractItemModel, public Event_Listener
16 {
17   Q_OBJECT
18 public:
19   XGUI_DocumentDataModel(QObject* theParent);
20   virtual ~XGUI_DocumentDataModel();
21
22   // Event Listener method
23   virtual void processEvent(const Event_Message* theMessage);
24
25
26   virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
27   virtual QVariant headerData(int theSection, Qt::Orientation theOrient,
28                               int theRole = Qt::DisplayRole) const;
29
30   virtual int rowCount(const QModelIndex& theParent = QModelIndex()) const;
31   virtual int columnCount(const QModelIndex& theParent = QModelIndex()) const;
32
33   virtual QModelIndex index(int theRow, int theColumn, 
34                             const QModelIndex &parent = QModelIndex()) const;
35
36   virtual QModelIndex parent(const QModelIndex& theIndex) const;
37
38   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
39
40 private:
41
42   QModelIndex toSourceModel(const QModelIndex& theProxy) const;
43   QModelIndex* findModelIndex(const QModelIndex& theIndex) const;
44   QModelIndex* getModelIndex(const QModelIndex& theIndex) const;
45   void clearModelIndexes();
46
47   std::shared_ptr<ModelAPI_Document> myDocument;
48
49   XGUI_TopDataModel* myModel;
50   QList<XGUI_PartDataModel*> myPartModels;
51
52   QList<QModelIndex*> myIndexes;
53 };
54
55 #endif