1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 #ifndef XGUI_DataTreeModel_H
4 #define XGUI_DataTreeModel_H
8 #include <ModelAPI_Document.h>
9 #include <ModelAPI_Feature.h>
10 #include <ModelAPI_ResultPart.h>
12 #include <QAbstractItemModel>
15 /**\class XGUI_FeaturesModel
17 * \brief Abstaract class of model object which operates with features data.
19 class XGUI_EXPORT XGUI_FeaturesModel : public QAbstractItemModel
23 /// \param theParent a parent object
24 XGUI_FeaturesModel(QObject* theParent)
25 : QAbstractItemModel(theParent),
26 myItemsColor(Qt::black)
30 //! Returns Feature object by the given Model index.
31 //! Returns 0 if the given index is not index of a feature
32 /// \param theIndex a model index
33 virtual ObjectPtr object(const QModelIndex& theIndex) const = 0;
35 //! Returns QModelIndex which corresponds to the given feature
36 //! If the feature is not found then index is not valid
37 virtual QModelIndex objectIndex(const ObjectPtr& theFeature) const = 0;
39 //! Returns parent index of the given feature
40 virtual QModelIndex findParent(const ObjectPtr& theObject) const = 0;
42 //! Returns index corresponded to the group
43 //! \param theGroup a group name
44 virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
46 //! Set color of items
47 void setItemsColor(const QColor& theColor)
49 myItemsColor = theColor;
52 //! Returns color of items
53 QColor itemsColor() const
63 /**\class XGUI_PartModel
65 * \brief Abstaract class of model object which operates with parts data.
67 class XGUI_PartModel : public XGUI_FeaturesModel
71 /// \param theParent a parent object
72 XGUI_PartModel(QObject* theParent)
73 : XGUI_FeaturesModel(theParent)
78 /// \param theId a new id
79 void setPartId(int theId)
84 //! Returns true if the given document is a sub-document of this tree
85 //! \param theDoc a document to check
86 virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
88 //! Return a Part object
89 virtual ResultPartPtr part() const = 0;
92 //! Id of the current part object in the document