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(const DocumentPtr& theDocument, QObject* theParent):
22 QAbstractItemModel(theParent), myDocument(theDocument), 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 FeaturePtr feature(const QModelIndex& theIndex) const = 0;
28 //! Returns parent index of the given feature
29 virtual QModelIndex findParent(const FeaturePtr& theFeature) const = 0;
31 //! Returns index corresponded to the group
32 virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
34 void setItemsColor(const QColor& theColor) { myItemsColor = theColor; }
36 QColor itemsColor() const { return myItemsColor; }
39 boost::shared_ptr<ModelAPI_Document> myDocument;
44 /**\class XGUI_PartModel
46 * \brief Abstaract class of model object which operates with parts data.
48 class XGUI_PartModel : public XGUI_FeaturesModel
51 XGUI_PartModel(const DocumentPtr& theDocument, QObject* theParent):
52 XGUI_FeaturesModel(theDocument, theParent) {}
54 void setPartId(int theId) { myId = theId; }
56 //! Returns true if the given document is a sub-document of this tree
57 virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
59 //! Return a Part object
60 virtual FeaturePtr part() const = 0;
63 //! Id of the current part object in the document