BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
itemmapper.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/itemmapper.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_ITEMMAPPER_H
16 #define BORNAGAIN_MVVM_MODEL_MVVM_SIGNALS_ITEMMAPPER_H
17 
20 #include <memory>
21 
22 namespace ModelView {
23 
24 class SessionItem;
25 
26 //! Provides notifications on various changes for a specific item.
27 //! ItemMapper listens signals coming from the model (i.e. via ModelMapper) and processes only whose
28 //! signals which are related to the given item. Notifies all interested subscribers about things
29 //! going with the item and its relatives.
30 
31 class MVVM_MODEL_EXPORT ItemMapper : public ItemListenerInterface,
32  private ModelListener<SessionModel> {
33 public:
34  ItemMapper(SessionItem* item);
36 
37  void setOnItemDestroy(Callbacks::item_t f, Callbacks::slot_t owner) override;
38  void setOnDataChange(Callbacks::item_int_t f, Callbacks::slot_t owner) override;
39  void setOnPropertyChange(Callbacks::item_str_t f, Callbacks::slot_t owner) override;
40  void setOnChildPropertyChange(Callbacks::item_str_t f, Callbacks::slot_t owner) override;
41  void setOnItemInserted(Callbacks::item_tagrow_t f, Callbacks::slot_t owner) override;
42  void setOnItemRemoved(Callbacks::item_tagrow_t f, Callbacks::slot_t owner) override;
43  void setOnAboutToRemoveItem(Callbacks::item_tagrow_t f, Callbacks::slot_t owner) override;
44 
45  void unsubscribe(Callbacks::slot_t client) override;
46 
47  void setActive(bool value);
48 
49 private:
50  friend class SessionItem;
51  void callOnItemDestroy();
52 
53  struct ItemMapperImpl;
54  std::unique_ptr<ItemMapperImpl> p_impl;
55 };
56 
57 } // namespace ModelView
58 
59 #endif // BORNAGAIN_MVVM_MODEL_MVVM_SIGNALS_ITEMMAPPER_H
Interface to subscribe to various events happening with specific SessionItem.
Provides notifications on various changes for a specific item.
Definition: itemmapper.h:32
std::unique_ptr< ItemMapperImpl > p_impl
Definition: itemmapper.h:53
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
Defines class CLASS?
Defines class CLASS?
std::function< void(SessionItem *, std::string)> item_str_t
std::function< void(SessionItem *, TagRow)> item_tagrow_t
std::function< void(SessionItem *, int)> item_int_t
std::function< void(SessionItem *)> item_t
materialitems.h Collection of materials to populate MaterialModel.