BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
viewitem.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/viewmodel/mvvm/viewmodel/viewitem.h
6 //! @brief Defines class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_MVVM_VIEWMODEL_MVVM_VIEWMODEL_VIEWITEM_H
16 #define BORNAGAIN_MVVM_VIEWMODEL_MVVM_VIEWMODEL_VIEWITEM_H
17 
18 #include "mvvm/core/variant.h"
19 #include "mvvm/viewmodel_export.h"
20 #include <memory>
21 #include <vector>
22 
23 namespace ModelView {
24 
25 class SessionItem;
26 
27 //! Represents the view of SessionItem's data in a single cell of ViewModel.
28 
29 class MVVM_VIEWMODEL_EXPORT ViewItem {
30 public:
31  virtual ~ViewItem();
32 
33  int rowCount() const;
34 
35  int columnCount() const;
36 
37  void appendRow(std::vector<std::unique_ptr<ViewItem>> items);
38 
39  void insertRow(int row, std::vector<std::unique_ptr<ViewItem>> items);
40 
41  void removeRow(int row);
42 
43  void clear();
44 
45  ViewItem* parent() const;
46 
47  ViewItem* child(int row, int column) const;
48 
49  SessionItem* item() const;
50 
51  int item_role() const;
52 
53  int row() const;
54 
55  int column() const;
56 
57  virtual QVariant data(int qt_role) const;
58 
59  virtual bool setData(const QVariant& value, int qt_role);
60 
61  virtual Qt::ItemFlags flags() const;
62 
63  std::vector<ViewItem*> children() const;
64 
65 protected:
66  ViewItem(SessionItem* item, int role);
67  void setParent(ViewItem* parent);
68 
69 private:
70  struct ViewItemImpl;
71  std::unique_ptr<ViewItemImpl> p_impl;
72 };
73 
74 } // namespace ModelView
75 
76 #endif // BORNAGAIN_MVVM_VIEWMODEL_MVVM_VIEWMODEL_VIEWITEM_H
The main object representing an editable/displayable/serializable entity.
Definition: sessionitem.h:38
Represents the view of SessionItem's data in a single cell of ViewModel.
Definition: viewitem.h:29
std::unique_ptr< ViewItemImpl > p_impl
Definition: viewitem.h:70
void removeRow(QGridLayout *layout, int row, bool deleteWidgets=true)
Removes row from grid layout (important: doesn't change row count).
Definition: LayoutUtils.cpp:58
materialitems.h Collection of materials to populate MaterialModel.
Defines class CLASS?