1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2 #ifndef PartSet_TopDataModel_H
3 #define PartSet_TopDataModel_H
6 #include "PartSet_DataTreeModel.h"
8 /**\class PartSet_TopDataModel
10 * \brief This is a data model for Object Browser (QTreeView).
11 * It represents only upper part of data tree (non-parts tree items)
13 class PARTSET_EXPORT PartSet_TopDataModel : public PartSet_FeaturesModel
18 /// \param theParent a parent object
19 PartSet_TopDataModel(QObject* theParent);
20 virtual ~PartSet_TopDataModel();
22 // Reimpl from QAbstractItemModel
24 /// Returns the data stored under the given role for the item referred to by the index.
25 /// \param theIndex a model index
26 /// \param theRole a data role (see Qt::ItemDataRole)
27 virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
29 /// Returns the data for the given role and section in the header with the specified orientation.
30 /// \param theSection a section
31 /// \param theOrient an orientation
32 /// \param theRole a data role (see Qt::ItemDataRole)
33 virtual QVariant headerData(int theSection, Qt::Orientation theOrient,
34 int theRole = Qt::DisplayRole) const;
36 /// Returns the number of rows under the given parent. When the parent is valid it means that
37 /// rowCount is returning the number of children of parent.
38 /// \param theParent a parent model index
39 virtual int rowCount(const QModelIndex &theParent = QModelIndex()) const;
41 /// Returns the number of columns for the children of the given parent.
42 /// It has a one column
43 /// \param theParent a parent model index
44 virtual int columnCount(const QModelIndex &theParent = QModelIndex()) const;
47 /// Returns the index of the item in the model specified by the given row, column and parent index.
48 /// \param theRow a row
49 /// \param theColumn a column
50 /// \param theParent a parent model index
51 virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent =
54 /// Returns the parent of the model item with the given index.
55 /// If the item has no parent, an invalid QModelIndex is returned.
56 /// \param theIndex a model index
57 virtual QModelIndex parent(const QModelIndex& theIndex) const;
59 /// Returns true if parent has any children; otherwise returns false.
60 /// \param theParent a parent model index
61 virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
63 //! Returns object by the given Model index.
64 //! Returns 0 if the given index is not index of a object
65 virtual ObjectPtr object(const QModelIndex& theIndex) const;
67 //! Returns QModelIndex which corresponds to the given object
68 //! If the object is not found then index is not valid
69 virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
71 //! Returns parent index of the given object
72 virtual QModelIndex findParent(const ObjectPtr& theObject) const;
74 //! Returns index corresponded to the group
75 virtual QModelIndex findGroup(const std::string& theGroup) const;
78 //! Types of QModelIndexes