BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
modelmapper.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/model/mvvm/signals/modelmapper.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_MODEL_MVVM_SIGNALS_MODELMAPPER_H
16 #define BORNAGAIN_MVVM_MODEL_MVVM_SIGNALS_MODELMAPPER_H
17 
19 #include <memory>
20 
21 namespace ModelView {
22 
23 class SessionItem;
24 class SessionModel;
25 
26 //! Provides notifications on various SessionModel changes.
27 //! Allows to subscribe to SessionModel's changes, and triggers notifications.
28 
29 class MVVM_MODEL_EXPORT ModelMapper : public ModelListenerInterface {
30 public:
31  ModelMapper(SessionModel* model);
33 
34  ModelMapper(const ModelMapper& other) = delete;
35  ModelMapper& operator=(const ModelMapper& other) = delete;
36 
37  void setOnDataChange(Callbacks::item_int_t f, Callbacks::slot_t client) override;
38  void setOnItemInserted(Callbacks::item_tagrow_t f, Callbacks::slot_t client) override;
39  void setOnItemRemoved(Callbacks::item_tagrow_t f, Callbacks::slot_t client) override;
40  void setOnAboutToRemoveItem(Callbacks::item_tagrow_t f, Callbacks::slot_t client) override;
41  void setOnModelDestroyed(Callbacks::model_t f, Callbacks::slot_t client) override;
42  void setOnModelAboutToBeReset(Callbacks::model_t f, Callbacks::slot_t client) override;
43  void setOnModelReset(Callbacks::model_t f, Callbacks::slot_t client) override;
44 
45  void setActive(bool value);
46 
47  void unsubscribe(Callbacks::slot_t client) override;
48 
49 private:
50  friend class SessionModel;
51  friend class SessionItem;
52 
53  void callOnDataChange(SessionItem* item, int role);
54  void callOnItemInserted(SessionItem* parent, const TagRow& tagrow);
55  void callOnItemRemoved(SessionItem* parent, const TagRow& tagrow);
56  void callOnItemAboutToBeRemoved(SessionItem* parent, const TagRow& tagrow);
57  void callOnModelDestroyed();
58  void callOnModelAboutToBeReset();
59  void callOnModelReset();
60 
61  struct ModelMapperImpl;
62  std::unique_ptr<ModelMapperImpl> p_impl;
63 };
64 
65 } // namespace ModelView
66 
67 #endif // BORNAGAIN_MVVM_MODEL_MVVM_SIGNALS_MODELMAPPER_H
Interface to subscribe to various signals generated by SessionModel.
Provides notifications on various SessionModel changes.
Definition: modelmapper.h:29
std::unique_ptr< ModelMapperImpl > p_impl
Definition: modelmapper.h:61
ModelMapper & operator=(const ModelMapper &other)=delete
ModelMapper(const ModelMapper &other)=delete
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
SessionItem * parent() const
Returns parent of this item.
Definition: SessionItem.cpp:73
T * item(const QString &tag) const
Definition: SessionItem.h:151
Defines class CLASS?
std::function< void(SessionModel *)> model_t
std::function< void(SessionItem *, TagRow)> item_tagrow_t
std::function< void(SessionItem *, int)> item_int_t
materialitems.h Collection of materials to populate MaterialModel.