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
62 /**\class XGUI_PartDataModel
64 * \brief This is a data model for Object Browser (QTreeView).
65 * It represents data tree only of a one part
67 class XGUI_PartDataModel : public XGUI_PartModel
71 XGUI_PartDataModel(QObject* theParent);
72 virtual ~XGUI_PartDataModel();
74 // Reimpl from QAbstractItemModel
75 virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
76 virtual QVariant headerData(int section, Qt::Orientation orientation,
77 int role = Qt::DisplayRole) const;
79 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
80 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
82 virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent =
85 virtual QModelIndex parent(const QModelIndex& theIndex) const;
87 virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
89 //! Returns object by the given Model index.
90 //! Returns 0 if the given index is not index of a object
91 virtual ObjectPtr object(const QModelIndex& theIndex) const;
93 //! Returns QModelIndex which corresponds to the given object
94 //! If the object is not found then index is not valid
95 virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
97 //! Returns true if the given document is a sub-document of this tree
98 virtual bool hasDocument(const DocumentPtr& theDoc) const;
100 //! Returns parent index of the given object
101 virtual QModelIndex findParent(const ObjectPtr& theObject) const;
103 //! Returns index corresponded to the group
104 virtual QModelIndex findGroup(const std::string& theGroup) const;
106 //! Return a Part object
107 virtual ResultPartPtr part() const;
111 //! Returns document of the current part
112 DocumentPtr partDocument() const;
114 //! Types of QModelIndexes