2 #ifndef XGUI_DocumentDataModel_H
3 #define XGUI_DocumentDataModel_H
5 #include <QAbstractItemModel>
6 #include <Event_Listener.h>
10 class ModelAPI_Document;
11 class XGUI_PartDataModel;
12 class XGUI_TopDataModel;
14 /**\class XGUI_DocumentDataModel
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.
19 class XGUI_DocumentDataModel : public QAbstractItemModel, public Event_Listener
25 XGUI_DocumentDataModel(QObject* theParent);
26 virtual ~XGUI_DocumentDataModel();
28 // Event Listener method
29 virtual void processEvent(const Event_Message* theMessage);
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;
36 virtual int rowCount(const QModelIndex& theParent = QModelIndex()) const;
37 virtual int columnCount(const QModelIndex& theParent = QModelIndex()) const;
39 virtual QModelIndex index(int theRow, int theColumn,
40 const QModelIndex &parent = QModelIndex()) const;
42 virtual QModelIndex parent(const QModelIndex& theIndex) const;
44 virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
48 //! Converts QModelIndex of this model to QModelIndex of a one of sub-models.
49 QModelIndex toSourceModel(const QModelIndex& theProxy) const;
51 //! Finds a pointer on QModelIndex which is equal to the given one
52 QModelIndex* findModelIndex(const QModelIndex& theIndex) const;
54 //! Returns pointer on QModelIndex which is equal to the given one.
55 QModelIndex* getModelIndex(const QModelIndex& theIndex) const;
57 //! Deletes all saved pointers on QModelIndex objects.
58 void clearModelIndexes();
61 std::shared_ptr<ModelAPI_Document> myDocument;
63 //! Data model of top part of data tree (not parts object)
64 XGUI_TopDataModel* myModel;
66 //! Data models for Parts data tree representation (one data model per a one part)
67 QList<XGUI_PartDataModel*> myPartModels;
69 //! List of saved QModelIndexes created by sub-models
70 QList<QModelIndex*> myIndexes;