BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
viewmodelcontroller.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/viewmodelcontroller.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_VIEWMODELCONTROLLER_H
16 #define BORNAGAIN_MVVM_VIEWMODEL_MVVM_VIEWMODEL_VIEWMODELCONTROLLER_H
17 
18 #include "mvvm/model/tagrow.h"
20 #include "mvvm/viewmodel_export.h"
21 #include <QStringList>
22 #include <memory>
23 #include <vector>
24 
25 class QStandardItem;
26 
27 namespace ModelView {
28 
29 class SessionModel;
30 class SessionItem;
31 class ViewModelBase;
32 class ViewItem;
33 class ChildrenStrategyInterface;
34 class RowStrategyInterface;
35 
36 //! Propagates changes from SessionModel to its ViewModelBase.
37 
38 class MVVM_VIEWMODEL_EXPORT ViewModelController : public ModelListener<SessionModel> {
39 public:
40  ViewModelController(SessionModel* session_model, ViewModelBase* view_model = nullptr);
42 
43  void setViewModel(ViewModelBase* view_model);
44 
45  void setChildrenStrategy(std::unique_ptr<ChildrenStrategyInterface> children_strategy);
46 
47  void setRowStrategy(std::unique_ptr<RowStrategyInterface> row_strategy);
48 
49  SessionModel* sessionModel() const;
50 
51  void setRootSessionItem(SessionItem* item);
52 
53  SessionItem* rootSessionItem() const;
54 
55  std::vector<ViewItem*> findViews(const ModelView::SessionItem* item) const;
56 
57  QStringList horizontalHeaderLabels() const;
58 
59 protected:
60  virtual void onDataChange(SessionItem* item, int role);
61  virtual void onItemInserted(SessionItem* parent, TagRow tagrow);
62  virtual void onItemRemoved(SessionItem* parent, TagRow tagrow);
63  virtual void onAboutToRemoveItem(SessionItem* parent, TagRow tagrow);
64 
65  void update_branch(const SessionItem* item);
66 
67 private:
69  std::unique_ptr<ViewModelControllerImpl> p_impl;
70 };
71 
72 } // namespace ModelView
73 
74 #endif // BORNAGAIN_MVVM_VIEWMODEL_MVVM_VIEWMODEL_VIEWMODELCONTROLLER_H
Templated class for all objects willing to listen for changes in concrete SessionModel.
Definition: modellistener.h:26
The main object representing an editable/displayable/serializable entity.
Definition: sessionitem.h:38
Main class to hold hierarchy of SessionItem objects.
Definition: sessionmodel.h:37
Aggregate to hold (tag, row) information for SessionModel.
Definition: tagrow.h:25
Base class for all view models to show content of SessionModel in Qt views.
Definition: viewmodelbase.h:31
Propagates changes from SessionModel to its ViewModelBase.
std::unique_ptr< ViewModelControllerImpl > p_impl
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.
Defines class CLASS?