BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
modelhaschangedcontroller.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/project/modelhaschangedcontroller.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_PROJECT_MODELHASCHANGEDCONTROLLER_H
16 #define BORNAGAIN_MVVM_MODEL_MVVM_PROJECT_MODELHASCHANGEDCONTROLLER_H
17 
19 #include <functional>
20 
21 namespace ModelView {
22 
23 //! Tracks changes in the model.
24 //! Allows to check if model has been changed (e.g. modified, inserted or removed items) since last
25 //! call of ::resetChanged().
26 
27 class MVVM_MODEL_EXPORT ModelHasChangedController : public ModelListener<SessionModel> {
28 public:
29  using callback_t = std::function<void()>;
30  ModelHasChangedController(SessionModel* model, callback_t callback = {});
31 
32  bool hasChanged() const;
33 
34  void resetChanged();
35 
36 private:
37  void process_change();
38  bool m_has_changed{false};
39  callback_t m_callback; //! informs the user about change in the model
40 };
41 
42 } // namespace ModelView
43 
44 #endif // BORNAGAIN_MVVM_MODEL_MVVM_PROJECT_MODELHASCHANGEDCONTROLLER_H
Templated class for all objects willing to listen for changes in concrete SessionModel.
Definition: modellistener.h:26
Main class to hold hierarchy of SessionItem objects.
Definition: sessionmodel.h:37
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.