2 #ifndef XGUI_DocumentDataModel_H
3 #define XGUI_DocumentDataModel_H
5 #include "XGUI_Constants.h"
7 #include <QAbstractItemModel>
8 #include <Event_Listener.h>
12 class ModelAPI_Document;
14 class XGUI_TopDataModel;
16 /**\class XGUI_DocumentDataModel
18 * \brief This is a proxy data model for Object Browser (QTreeView).
19 * It contains several sub-models for generation of each sub-part of data tree.
21 class XGUI_DocumentDataModel : public QAbstractItemModel, public Event_Listener
27 XGUI_DocumentDataModel(QObject* theParent);
28 virtual ~XGUI_DocumentDataModel();
30 // Event Listener method
31 virtual void processEvent(const Event_Message* theMessage);
34 virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
35 virtual QVariant headerData(int theSection, Qt::Orientation theOrient,
36 int theRole = Qt::DisplayRole) const;
38 virtual int rowCount(const QModelIndex& theParent = QModelIndex()) const;
39 virtual int columnCount(const QModelIndex& theParent = QModelIndex()) const;
41 virtual QModelIndex index(int theRow, int theColumn,
42 const QModelIndex &parent = QModelIndex()) const;
44 virtual QModelIndex parent(const QModelIndex& theIndex) const;
46 virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
48 //! Returns Feature object by the given Model index.
49 //! Returns 0 if the given index is not index of a feature
50 FeaturePtr feature(const QModelIndex& theIndex) const;
54 //! Converts QModelIndex of this model to QModelIndex of a one of sub-models.
55 QModelIndex toSourceModel(const QModelIndex& theProxy) const;
57 //! Finds a pointer on QModelIndex which is equal to the given one
58 QModelIndex* findModelIndex(const QModelIndex& theIndex) const;
60 //! Returns pointer on QModelIndex which is equal to the given one.
61 QModelIndex* getModelIndex(const QModelIndex& theIndex) const;
63 //! Deletes all saved pointers on QModelIndex objects.
64 void clearModelIndexes();
67 std::shared_ptr<ModelAPI_Document> myDocument;
69 //! Data model of top part of data tree (not parts object)
70 XGUI_TopDataModel* myModel;
72 //! Data models for Parts data tree representation (one data model per a one part)
73 QList<XGUI_PartModel*> myPartModels;
75 //! List of saved QModelIndexes created by sub-models
76 QList<QModelIndex*> myIndexes;