Salome HOME
Issue #663: Don't hide "Activate" menu item in PartSet pop-up
[modules/shaper.git] / src / PartSet / PartSet_TopDataModel.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2 #ifndef PartSet_TopDataModel_H
3 #define PartSet_TopDataModel_H
4
5 #include "PartSet.h"
6 #include "PartSet_DataTreeModel.h"
7
8 /**\class PartSet_TopDataModel
9  * \ingroup GUI
10  * \brief This is a data model for Object Browser (QTreeView).
11  * It represents only upper part of data tree (non-parts tree items)
12  */
13 class PARTSET_EXPORT PartSet_TopDataModel : public PartSet_FeaturesModel
14 {
15 Q_OBJECT
16  public:
17    /// Constructor
18    /// \param theParent a parent object
19   PartSet_TopDataModel(QObject* theParent);
20   virtual ~PartSet_TopDataModel();
21
22   // Reimpl from QAbstractItemModel
23
24   /// Returns the data stored under the given role for the item referred to by the index.
25   /// \param theIndex a model index
26   /// \param theRole a data role (see Qt::ItemDataRole)
27   virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
28
29   /// Returns the data for the given role and section in the header with the specified orientation.
30   /// \param theSection a section
31   /// \param theOrient an orientation
32   /// \param theRole a data role (see Qt::ItemDataRole)
33   virtual QVariant headerData(int theSection, Qt::Orientation theOrient,
34                               int theRole = Qt::DisplayRole) const;
35
36   /// Returns the number of rows under the given parent. When the parent is valid it means that 
37   /// rowCount is returning the number of children of parent.
38   /// \param theParent a parent model index
39   virtual int rowCount(const QModelIndex &theParent = QModelIndex()) const;
40
41   /// Returns the number of columns for the children of the given parent.
42   /// It has a one column
43   /// \param theParent a parent model index
44   virtual int columnCount(const QModelIndex &theParent = QModelIndex()) const;
45
46
47   /// Returns the index of the item in the model specified by the given row, column and parent index.
48   /// \param theRow a row
49   /// \param theColumn a column
50   /// \param theParent a parent model index
51   virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent =
52                                 QModelIndex()) const;
53
54   /// Returns the parent of the model item with the given index. 
55   /// If the item has no parent, an invalid QModelIndex is returned.
56   /// \param theIndex a model index
57   virtual QModelIndex parent(const QModelIndex& theIndex) const;
58
59   /// Returns true if parent has any children; otherwise returns false.
60   /// \param theParent a parent model index
61   virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
62
63   //! Returns object by the given Model index.
64   //! Returns 0 if the given index is not index of a object
65   virtual ObjectPtr object(const QModelIndex& theIndex) const;
66
67   //! Returns QModelIndex which corresponds to the given object
68   //! If the object is not found then index is not valid
69   virtual QModelIndex objectIndex(const ObjectPtr& theObject) const;
70
71   //! Returns parent index of the given object
72   virtual QModelIndex findParent(const ObjectPtr& theObject) const;
73
74   //! Returns index corresponded to the group
75   virtual QModelIndex findGroup(const std::string& theGroup) const;
76
77  private:
78   //! Types of QModelIndexes
79   enum DataIds
80   {
81     ParamsFolder,
82     ParamObject,
83     ConstructFolder,
84     ConstructObject
85     //GroupsFolder,
86     //GroupObject
87   };
88
89 };
90
91 #endif