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>
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
22 XGUI_FeaturesModel(QObject* theParent):
23 QAbstractItemModel(theParent), myItemsColor(Qt::black) {}
25 //! Returns Feature object by the given Model index.
26 //! Returns 0 if the given index is not index of a feature
27 virtual ObjectPtr object(const QModelIndex& theIndex) const = 0;
29 //! Returns QModelIndex which corresponds to the given feature
30 //! If the feature is not found then index is not valid
31 virtual QModelIndex objectIndex(const ObjectPtr& theFeature) const = 0;
33 //! Returns parent index of the given feature
34 virtual QModelIndex findParent(const ObjectPtr& theObject) const = 0;
36 //! Returns index corresponded to the group
37 virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
39 void setItemsColor(const QColor& theColor) { myItemsColor = theColor; }
41 QColor itemsColor() const { return myItemsColor; }
48 /**\class XGUI_PartModel
50 * \brief Abstaract class of model object which operates with parts data.
52 class XGUI_PartModel : public XGUI_FeaturesModel
55 XGUI_PartModel(QObject* theParent):
56 XGUI_FeaturesModel(theParent) {}
58 void setPartId(int theId) { myId = theId; }
60 //! Returns true if the given document is a sub-document of this tree
61 virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
63 //! Return a Part object
64 virtual ResultPartPtr part() const = 0;
67 //! Id of the current part object in the document