1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 #ifndef XGUI_PartDataModel_H
4 #define XGUI_PartDataModel_H
7 #include "XGUI_DataTreeModel.h"
9 /**\class XGUI_TopDataModel
11 * \brief This is a data model for Object Browser (QTreeView).
12 * It represents only upper part of data tree (non-parts tree items)
14 class XGUI_EXPORT XGUI_TopDataModel : public XGUI_FeaturesModel
18 XGUI_TopDataModel(QObject* theParent);
19 virtual ~XGUI_TopDataModel();
21 // Reimpl from QAbstractItemModel
22 virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
23 virtual QVariant headerData(int section, Qt::Orientation orientation,
24 int role = Qt::DisplayRole) const;
26 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
27 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
29 virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent =
32 virtual QModelIndex parent(const QModelIndex& theIndex) const;
34 virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
36 //! Returns object by the given Model index.
37 //! Returns 0 if the given index is not index of a object
38 virtual ObjectPtr object(const QModelIndex& theIndex) const;
40 //! Returns QModelIndex which corresponds to the given object
41 //! If the object is not found then index is not valid
42 virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
44 //! Returns parent index of the given object
45 virtual QModelIndex findParent(const ObjectPtr& theObject) const;
47 //! Returns index corresponded to the group
48 virtual QModelIndex findGroup(const std::string& theGroup) const;
51 //! Types of QModelIndexes
64 /**\class XGUI_PartDataModel
66 * \brief This is a data model for Object Browser (QTreeView).
67 * It represents data tree only of a one part
69 class XGUI_PartDataModel : public XGUI_PartModel
73 XGUI_PartDataModel(QObject* theParent);
74 virtual ~XGUI_PartDataModel();
76 // Reimpl from QAbstractItemModel
77 virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
78 virtual QVariant headerData(int section, Qt::Orientation orientation,
79 int role = Qt::DisplayRole) const;
81 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
82 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
84 virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent =
87 virtual QModelIndex parent(const QModelIndex& theIndex) const;
89 virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
91 //! Returns object by the given Model index.
92 //! Returns 0 if the given index is not index of a object
93 virtual ObjectPtr object(const QModelIndex& theIndex) const;
95 //! Returns QModelIndex which corresponds to the given object
96 //! If the object is not found then index is not valid
97 virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
99 //! Returns true if the given document is a sub-document of this tree
100 virtual bool hasDocument(const DocumentPtr& theDoc) const;
102 //! Returns parent index of the given object
103 virtual QModelIndex findParent(const ObjectPtr& theObject) const;
105 //! Returns index corresponded to the group
106 virtual QModelIndex findGroup(const std::string& theGroup) const;
108 //! Return a Part object
109 virtual ResultPartPtr part() const;
113 //! Returns document of the current part
114 DocumentPtr partDocument() const;
116 int getRowsNumber() const;
118 //! Types of QModelIndexes