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 QModelIndex which corresponds to the given feature
29 //! If the feature is not found then index is not valid
30 virtual QModelIndex featureIndex(const FeaturePtr& theFeature) const = 0;
32 //! Returns parent index of the given feature
33 virtual QModelIndex findParent(const FeaturePtr& theFeature) 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; }
43 boost::shared_ptr<ModelAPI_Document> myDocument;
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(const DocumentPtr& theDocument, QObject* theParent):
56 XGUI_FeaturesModel(theDocument, 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 FeaturePtr part() const = 0;
67 //! Id of the current part object in the document