BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SessionItemTags.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Support/Data/SessionItemTags.h
6 //! @brief Defines class SessionItemTags
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_DATA_SESSIONITEMTAGS_H
16 #define BORNAGAIN_GUI_SUPPORT_DATA_SESSIONITEMTAGS_H
17 
18 #include <QString>
19 #include <QStringList>
20 #include <QVector>
21 
22 //! Holds all tag info for SessionItem.
23 
25 public:
26  bool registerTag(const QString& name, int min, int max, const QStringList& modelTypes);
27 
28  bool isValid(const QString& tagName, const QString& modelType = "") const;
29 
30  QStringList modelTypesForTag(const QString& tagName) const;
31 
32  int tagStartIndex(const QString& tagName) const;
33 
34  int indexFromTagRow(const QString& tagName, int row) const;
35  int insertIndexFromTagRow(const QString& tagName, int row);
36 
37  QString tagFromIndex(int index) const;
38 
39  int childCount(const QString& tagName);
40  int childMax(const QString& tagName);
41 
42  void addChild(const QString& tagName);
43  void removeChild(const QString& tagName);
44 
45  bool isSingleItemTag(const QString& tagName) const;
46 
47  bool maximumReached(const QString& tagName) const;
48 
49 private:
50  struct TagInfo {
51  QString name;
52  int min{0};
53  int max{-1};
54  int childCount{0};
55  QStringList modelTypes;
56  };
57 
58  TagInfo& tagInfo(const QString& tagName);
59  const TagInfo& tagInfo(const QString& tagName) const;
60 
61  QVector<TagInfo> m_tags;
62 };
63 
64 #endif // BORNAGAIN_GUI_SUPPORT_DATA_SESSIONITEMTAGS_H
Holds all tag info for SessionItem.
TagInfo & tagInfo(const QString &tagName)
int childMax(const QString &tagName)
bool registerTag(const QString &name, int min, int max, const QStringList &modelTypes)
Register tag with given parameters. Returns true in case of success. Returns false if parameters are ...
QString tagFromIndex(int index) const
int indexFromTagRow(const QString &tagName, int row) const
Returns index in SessionItem's m_children corresponding to given row in tagName.
QVector< TagInfo > m_tags
bool isSingleItemTag(const QString &tagName) const
void addChild(const QString &tagName)
void removeChild(const QString &tagName)
int insertIndexFromTagRow(const QString &tagName, int row)
Returns index in SessionItem's m_children to insert new item. If number of items for given tagName ex...
int childCount(const QString &tagName)
int tagStartIndex(const QString &tagName) const
Returns start index of given tagName corresponding to the index of SessionItem's m_children.
bool isValid(const QString &tagName, const QString &modelType="") const
Returns true if there is a registered tag with such name. If modelType is not empty,...
QStringList modelTypesForTag(const QString &tagName) const
Returns list of modelTypes the given tagName is intended for.
bool maximumReached(const QString &tagName) const
QString const & name(EShape k)
Definition: particles.cpp:20