1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: XGUI_DataModel.h
4 // Created: 21 Jul 2015
5 // Author: Vitaly SMETANNIKOV
8 #ifndef XGUI_DataModel_H
9 #define XGUI_DataModel_H
12 #include <ModelAPI_Object.h>
13 #include <Config_DataModelReader.h>
14 #include <QAbstractItemModel>
16 class XGUI_EXPORT XGUI_DataModel : public QAbstractItemModel
20 XGUI_DataModel(QObject* theParent);
22 //! Returns an object by the given Model index.
23 //! Returns 0 if the given index is not index of an object
24 virtual ObjectPtr object(const QModelIndex& theIndex) const;
26 //! Returns index of the object
27 //! \param theObject object to find
28 virtual QModelIndex objectIndex(const ObjectPtr theObject) const;
30 //! Clear internal data
34 virtual void rebuildDataTree();
37 /// Returns the data stored under the given role for the item referred to by the index.
38 /// \param theIndex a model index
39 /// \param theRole a data role (see Qt::ItemDataRole)
40 virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
42 /// Returns the data for the given role and section in the header with the specified orientation.
43 /// \param theSection a section
44 /// \param theOrient an orientation
45 /// \param theRole a data role (see Qt::ItemDataRole)
46 virtual QVariant headerData(int theSection, Qt::Orientation theOrient, int theRole =
47 Qt::DisplayRole) const;
49 /// Returns the number of rows under the given parent. When the parent is valid it means that
50 /// rowCount is returning the number of children of parent.
51 /// \param theParent a parent model index
52 virtual int rowCount(const QModelIndex& theParent = QModelIndex()) const;
54 /// Returns the number of columns for the children of the given parent.
55 /// It has a one column
56 /// \param theParent a parent model index
57 virtual int columnCount(const QModelIndex& theParent = QModelIndex()) const;
59 /// Returns the index of the item in the model specified by the given row, column and parent index.
60 /// \param theRow a row
61 /// \param theColumn a column
62 /// \param theParent a parent model index
63 virtual QModelIndex index(int theRow, int theColumn, const QModelIndex &theParent =
66 /// Returns the parent of the model item with the given index.
67 /// If the item has no parent, an invalid QModelIndex is returned.
68 /// \param theIndex a model index
69 virtual QModelIndex parent(const QModelIndex& theIndex) const;
71 /// Returns true if parent has any children; otherwise returns false.
72 /// \param theParent a parent model index
73 virtual bool hasChildren(const QModelIndex& theParent = QModelIndex()) const;
77 Config_DataModelReader myXMLReader;