BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GroupInfo.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Support/Type/GroupInfo.h
6 //! @brief Defines class GroupInfo
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_SUPPORT_TYPE_GROUPINFO_H
16 #define BORNAGAIN_GUI_SUPPORT_TYPE_GROUPINFO_H
17 
18 #include <QString>
19 #include <QStringList>
20 #include <QVector>
21 
22 //! Defines info for GroupProperty, i.e. collection of model types, their labels and
23 //! the name of default item's modelType.
24 
25 class GroupInfo {
26 public:
27  explicit GroupInfo(bool is_sorted = true);
28 
29  void add(const QString& itemType, const QString& itemLabel);
30 
31  QString defaultType() const;
32  void setDefaultType(const QString& modelType);
33 
34  template <typename T>
36  {
37  setDefaultType(T::M_TYPE);
38  }
39 
40  QStringList itemTypes() const;
41 
42  QStringList itemLabels() const;
43 
44 private:
45  struct TypeAndLabel {
46  QString m_itemType;
47  QString m_itemLabel;
48  };
49 
50  bool containsType(const QString& itemType) const;
51 
52  //!< Default model type for given group (i.e. FFCylinder for formfactor group)
54  //!< Info will be sorted if true, otherwise order of insertion will be preserved
55  bool is_sorted;
56  QVector<TypeAndLabel> m_info;
57 };
58 
59 #endif // BORNAGAIN_GUI_SUPPORT_TYPE_GROUPINFO_H
Defines info for GroupProperty, i.e. collection of model types, their labels and the name of default ...
Definition: GroupInfo.h:25
QVector< TypeAndLabel > m_info
Definition: GroupInfo.h:56
QStringList itemLabels() const
Definition: GroupInfo.cpp:54
void add(const QString &itemType, const QString &itemLabel)
Definition: GroupInfo.cpp:23
void setDefaultType()
Definition: GroupInfo.h:35
QString defaultType() const
Definition: GroupInfo.cpp:33
QStringList itemTypes() const
Definition: GroupInfo.cpp:46
bool is_sorted
Definition: GroupInfo.h:55
GroupInfo(bool is_sorted=true)
Definition: GroupInfo.cpp:18
QString m_defaultItemType
Info will be sorted if true, otherwise order of insertion will be preserved.
Definition: GroupInfo.h:53
bool containsType(const QString &itemType) const
Default model type for given group (i.e. FFCylinder for formfactor group)
Definition: GroupInfo.cpp:62