BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
standardviewmodelcontrollers.cpp
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/standardviewmodelcontrollers.cpp
6 //! @brief Implements 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 
16 #include "mvvm/model/groupitem.h"
21 
22 using namespace ModelView;
23 
24 // ----------------------------------------------------------------------------
25 
27  ViewModelBase* view_model)
28  : ViewModelController(session_model, view_model)
29 {
30  setChildrenStrategy(std::make_unique<AllChildrenStrategy>());
31  setRowStrategy(std::make_unique<LabelDataRowStrategy>());
32 }
33 
34 // ----------------------------------------------------------------------------
35 
37  ViewModelBase* view_model)
38  : ViewModelController(session_model, view_model)
39 {
40  setChildrenStrategy(std::make_unique<TopItemsStrategy>());
41  setRowStrategy(std::make_unique<LabelDataRowStrategy>());
42 }
43 
44 // ----------------------------------------------------------------------------
45 
47  ViewModelBase* view_model)
48  : ViewModelController(session_model, view_model)
49 {
50  setChildrenStrategy(std::make_unique<PropertyItemsStrategy>());
51  setRowStrategy(std::make_unique<LabelDataRowStrategy>());
52 }
53 
55 {
57  // If data change occured with GroupItem, performs cleanup and regeneration of
58  // ViewItems, corresponding to groupItem's current index.
59  if (auto group = dynamic_cast<GroupItem*>(item))
60  update_branch(group);
61 }
62 
63 // ----------------------------------------------------------------------------
64 
65 // FIXME What to do with group property?
66 
68  SessionModel* session_model, ViewModelBase* view_model, const std::vector<std::string>& labels)
69  : ViewModelController(session_model, view_model)
70 {
71  setChildrenStrategy(std::make_unique<TopItemsStrategy>());
72  setRowStrategy(std::make_unique<PropertiesRowStrategy>(labels));
73 }
74 
75 // ----------------------------------------------------------------------------
76 
78  ViewModelBase* view_model)
79  : ViewModelController(session_model, view_model)
80 {
81  setChildrenStrategy(std::make_unique<PropertyItemsFlatStrategy>());
82  setRowStrategy(std::make_unique<LabelDataRowStrategy>());
83 }
84 
86 {
88  // If data change occured with GroupItem, performs cleanup and regeneration of
89  // ViewItems, corresponding to groupItem's current index.
90  if (auto group = dynamic_cast<GroupItem*>(item))
91  update_branch(group->parent());
92 }
DefaultViewModelController(SessionModel *session_model, ViewModelBase *view_model)
Group item holds collection of predefined items.
Definition: groupitem.h:26
PropertyFlatViewModelController(SessionModel *session_model, ViewModelBase *view_model)
void onDataChange(SessionItem *item, int role) override
PropertyTableViewModelController(SessionModel *session_model, ViewModelBase *view_model, const std::vector< std::string > &labels={})
PropertyViewModelController(SessionModel *session_model, ViewModelBase *view_model)
void onDataChange(SessionItem *item, int role) override
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
TopItemsViewModelController(SessionModel *session_model, ViewModelBase *view_model)
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.
void setChildrenStrategy(std::unique_ptr< ChildrenStrategyInterface > children_strategy)
void update_branch(const SessionItem *item)
virtual void onDataChange(SessionItem *item, int role)
void setRowStrategy(std::unique_ptr< RowStrategyInterface > row_strategy)
Defines class CLASS?
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?