1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 #ifndef PartSet_PartDataModel_H
4 #define PartSet_PartDataModel_H
7 #include "PartSet_DataTreeModel.h"
10 /**\class PartSet_PartDataModel
12 * \brief This is a data model for Object Browser (QTreeView).
13 * It represents data tree only of a one part
15 class PartSet_PartDataModel : public PartSet_PartModel
20 /// \param theParent a parent object
21 PartSet_PartDataModel(QObject* theParent);
22 virtual ~PartSet_PartDataModel();
24 // Reimpl from QAbstractItemModel
26 /// Returns the data stored under the given role for the item referred to by the index.
27 /// \param theIndex a model index
28 /// \param theRole a data role (see Qt::ItemDataRole)
29 virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
31 /// Returns the data for the given role and section in the header with the specified orientation.
32 /// \param theSection a section
33 /// \param theOrient an orientation
34 /// \param theRole a data role (see Qt::ItemDataRole)
35 virtual QVariant headerData(int theSection, Qt::Orientation theOrient,
36 int theRole = Qt::DisplayRole) const;
38 /// Returns the number of rows under the given parent. When the parent is valid it means that
39 /// rowCount is returning the number of children of parent.
40 /// \param theParent a parent model index
41 virtual int rowCount(const QModelIndex &theParent = QModelIndex()) const;
43 /// Returns the number of columns for the children of the given parent.
44 /// It has a one column
45 /// \param theParent a parent model index
46 virtual int columnCount(const QModelIndex &theParent = QModelIndex()) const;
48 /// Returns the item flags for the given index.
49 /// \param theIndex a model index
50 virtual Qt::ItemFlags flags(const QModelIndex& theIndex) const;
52 /// Returns the index of the item in the model specified by the given row, column and parent index.
53 /// \param theRow a row
54 /// \param theColumn a column
55 /// \param theParent a parent model index
56 virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent =
59 /// Returns the parent of the model item with the given index.
60 /// If the item has no parent, an invalid QModelIndex is returned.
61 /// \param theIndex a model index
62 virtual QModelIndex parent(const QModelIndex& theIndex) const;
64 /// Returns true if parent has any children; otherwise returns false.
65 /// \param theParent a parent model index
66 virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
68 //! Returns object by the given Model index.
69 //! Returns 0 if the given index is not index of a object
70 virtual ObjectPtr object(const QModelIndex& theIndex) const;
72 //! Returns QModelIndex which corresponds to the given object
73 //! If the object is not found then index is not valid
74 virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
76 //! Returns true if the given document is a sub-document of this tree
77 virtual bool hasDocument(const DocumentPtr& theDoc) const;
79 //! Returns parent index of the given object
80 virtual QModelIndex findParent(const ObjectPtr& theObject) const;
82 //! Returns index corresponded to the group
83 virtual QModelIndex findGroup(const std::string& theGroup) const;
85 //! Set an Index which will be considered as a last history index
86 //! \param theIndex a last index for history
87 void setLastHistoryItem(const QModelIndex& theIndex);
89 //! Returns last history item
90 QModelIndex lastHistoryItem() const;
94 //! Returns document of the current part
95 DocumentPtr partDocument() const;
97 //! Returns defult number of rows
98 int getRowsNumber() const;
100 int lastHistoryRow() const;
102 //! Types of QModelIndexes
103 //! All types have negative Id's. Positive Id means sub-feature and contains row of its parent