2 #ifndef XGUI_DataTreeModel_H
3 #define XGUI_DataTreeModel_H
6 #include "XGUI_Constants.h"
8 #include <ModelAPI_Document.h>
9 #include <ModelAPI_Feature.h>
11 #include <QAbstractItemModel>
14 /**\class XGUI_FeaturesModel
16 * \brief Abstaract class of model object which operates with features data.
18 class XGUI_EXPORT XGUI_FeaturesModel : public QAbstractItemModel
21 XGUI_FeaturesModel(QObject* theParent):
22 QAbstractItemModel(theParent), myItemsColor(Qt::black) {}
24 //! Returns Feature object by the given Model index.
25 //! Returns 0 if the given index is not index of a feature
26 virtual ObjectPtr object(const QModelIndex& theIndex) const = 0;
28 //! Returns QModelIndex which corresponds to the given feature
29 //! If the feature is not found then index is not valid
30 virtual QModelIndex objectIndex(const ObjectPtr& theFeature) const = 0;
32 //! Returns parent index of the given feature
33 virtual QModelIndex findParent(const ObjectPtr& theObject) const = 0;
35 //! Returns index corresponded to the group
36 virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
38 void setItemsColor(const QColor& theColor) { myItemsColor = theColor; }
40 QColor itemsColor() const { return myItemsColor; }
47 /**\class XGUI_PartModel
49 * \brief Abstaract class of model object which operates with parts data.
51 class XGUI_PartModel : public XGUI_FeaturesModel
54 XGUI_PartModel(QObject* theParent):
55 XGUI_FeaturesModel(theParent) {}
57 void setPartId(int theId) { myId = theId; }
59 //! Returns true if the given document is a sub-document of this tree
60 virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
62 //! Return a Part object
63 virtual ResultPartPtr part() const = 0;
66 //! Id of the current part object in the document