1 #ifndef XGUI_PartDataModel_H
2 #define XGUI_PartDataModel_H
5 #include "XGUI_DataTreeModel.h"
7 /**\class XGUI_TopDataModel
9 * \brief This is a data model for Object Browser (QTreeView).
10 * It represents only upper part of data tree (non-parts tree items)
12 class XGUI_EXPORT XGUI_TopDataModel : public XGUI_FeaturesModel
16 XGUI_TopDataModel(QObject* theParent);
17 virtual ~XGUI_TopDataModel();
19 // Reimpl 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;
24 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
25 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
27 virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent =
30 virtual QModelIndex parent(const QModelIndex& theIndex) const;
32 virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
34 //! Returns object by the given Model index.
35 //! Returns 0 if the given index is not index of a object
36 virtual ObjectPtr object(const QModelIndex& theIndex) const;
38 //! Returns QModelIndex which corresponds to the given object
39 //! If the object is not found then index is not valid
40 virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
42 //! Returns parent index of the given object
43 virtual QModelIndex findParent(const ObjectPtr& theObject) const;
45 //! Returns index corresponded to the group
46 virtual QModelIndex findGroup(const std::string& theGroup) const;
49 //! Types of QModelIndexes
60 /**\class XGUI_PartDataModel
62 * \brief This is a data model for Object Browser (QTreeView).
63 * It represents data tree only of a one part
65 class XGUI_PartDataModel : public XGUI_PartModel
69 XGUI_PartDataModel(QObject* theParent);
70 virtual ~XGUI_PartDataModel();
72 // Reimpl from QAbstractItemModel
73 virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
74 virtual QVariant headerData(int section, Qt::Orientation orientation,
75 int role = Qt::DisplayRole) const;
77 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
78 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
80 virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent =
83 virtual QModelIndex parent(const QModelIndex& theIndex) const;
85 virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
87 //! Returns object by the given Model index.
88 //! Returns 0 if the given index is not index of a object
89 virtual ObjectPtr object(const QModelIndex& theIndex) const;
91 //! Returns QModelIndex which corresponds to the given object
92 //! If the object is not found then index is not valid
93 virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
95 //! Returns true if the given document is a sub-document of this tree
96 virtual bool hasDocument(const DocumentPtr& theDoc) const;
98 //! Returns parent index of the given object
99 virtual QModelIndex findParent(const ObjectPtr& theObject) const;
101 //! Returns index corresponded to the group
102 virtual QModelIndex findGroup(const std::string& theGroup) const;
104 //! Return a Part object
105 virtual ResultPartPtr part() const;
109 //! Returns document of the current part
110 DocumentPtr partDocument() const;
112 //! Types of QModelIndexes