BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
groupitem.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/model/groupitem.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_MODEL_GROUPITEM_H
16 #define BORNAGAIN_MVVM_MODEL_MVVM_MODEL_GROUPITEM_H
17 
19 #include "mvvm/model/sessionitem.h"
20 #include <memory>
21 
22 namespace ModelView {
23 
24 //! Group item holds collection of predefined items.
25 
26 class MVVM_MODEL_EXPORT GroupItem : public SessionItem {
27 public:
28  static inline const std::string T_GROUP_ITEMS = "T_GROUP_ITEMS";
29 
31  ~GroupItem() override;
32 
33  int currentIndex() const;
34 
35  const SessionItem* currentItem() const;
36  SessionItem* currentItem();
37 
38  std::string currentType() const;
39  void setCurrentType(const std::string& model_type);
40 
41 protected:
42  void setCurrentIndex(int index);
43  bool is_valid_index() const;
44  template <typename T> void registerItem(const std::string& text, bool make_selected = false);
45  // FIXME how to make sure that init_group() was called in constructor?
46  // Shell we delegate this call to CompoundItem::addProperty ?
47  void init_group();
48  std::unique_ptr<ItemCatalogue> m_catalogue;
50 };
51 
52 template <typename T> void GroupItem::registerItem(const std::string& text, bool make_selected)
53 {
54  m_catalogue->registerItem<T>(text);
55  if (make_selected)
56  m_default_selected_index = m_catalogue->itemCount() - 1;
57 }
58 
59 } // namespace ModelView
60 
61 #endif // BORNAGAIN_MVVM_MODEL_MVVM_MODEL_GROUPITEM_H
Group item holds collection of predefined items.
Definition: groupitem.h:26
void registerItem(const std::string &text, bool make_selected=false)
Definition: groupitem.h:52
std::unique_ptr< ItemCatalogue > m_catalogue
Definition: groupitem.h:48
int m_default_selected_index
Definition: groupitem.h:49
The main object representing an editable/displayable/serializable entity.
Definition: sessionitem.h:38
Defines class CLASS?
const model_type GroupItemType
Definition: mvvm_types.h:55
materialitems.h Collection of materials to populate MaterialModel.
std::string model_type
Definition: types.h:23
Defines class CLASS?