Salome HOME
Merge from 'master'
[modules/shaper.git] / src / XGUI / XGUI_DataTreeModel.h
1
2 #ifndef XGUI_DataTreeModel_H
3 #define XGUI_DataTreeModel_H
4
5 #include "XGUI.h"
6 #include "XGUI_Constants.h"
7
8 #include <ModelAPI_Document.h>
9 #include <ModelAPI_Feature.h>
10
11 #include <QAbstractItemModel>
12 #include <QColor>
13
14 /**\class XGUI_FeaturesModel
15  * \ingroup GUI
16  * \brief Abstaract class of model object which operates with features data.
17  */
18 class XGUI_EXPORT XGUI_FeaturesModel : public QAbstractItemModel
19 {
20 public:
21   XGUI_FeaturesModel(QObject* theParent):
22       QAbstractItemModel(theParent), myItemsColor(Qt::black) {}
23
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;
27
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;
31
32   //! Returns parent index of the given feature
33   virtual QModelIndex findParent(const FeaturePtr& theFeature) const = 0;
34
35   //! Returns index corresponded to the group
36   virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
37
38   void setItemsColor(const QColor& theColor) { myItemsColor = theColor; }
39
40   QColor itemsColor() const { return myItemsColor; }
41
42 protected:
43   QColor myItemsColor;
44 };
45
46
47 /**\class XGUI_PartModel
48  * \ingroup GUI
49  * \brief Abstaract class of model object which operates with parts data.
50  */
51 class XGUI_PartModel : public XGUI_FeaturesModel
52 {
53 public:
54   XGUI_PartModel(QObject* theParent):
55       XGUI_FeaturesModel(theParent) {}
56
57   void setPartId(int theId) { myId = theId; }
58
59   //! Returns true if the given document is a sub-document of this tree
60   virtual bool hasDocument(const DocumentPtr& theDoc) const = 0;
61
62   //! Return a Part object
63   virtual FeaturePtr part() const = 0;
64
65 protected:
66   //! Id of the current part object in the document
67   int myId;
68 };
69
70
71 #endif