BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ComboProperty.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Util/ComboProperty.h
6 //! @brief Defines class ComboProperty
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_UTIL_COMBOPROPERTY_H
16 #define BORNAGAIN_GUI_UTIL_COMBOPROPERTY_H
17 
18 #include <QStringList>
19 #include <QVariant>
20 #include <QVector>
21 
22 //! Custom property to define list of string values with multiple selections.
23 //! Intended for QVariant.
24 
26 public:
28 
29  static ComboProperty fromList(const QStringList& values, const QString& current_value = "");
30 
31  QString getValue() const;
32  void setValue(const QString& name);
33 
34  QStringList getValues() const;
35  void setValues(const QStringList& values);
36 
37  QStringList toolTips() const;
38  void setToolTips(const QStringList& tooltips);
39 
40  int currentIndex() const;
41  void setCurrentIndex(int index);
42 
43  ComboProperty& operator<<(const QString& str);
44  ComboProperty& operator<<(const QStringList& str);
45  bool operator==(const ComboProperty& other) const;
46  bool operator!=(const ComboProperty& other) const;
47  bool operator<(const ComboProperty& other) const;
48 
49  QString stringOfValues() const;
50  void setStringOfValues(const QString& values);
51 
52  QVariant variant() const;
53 
54  QVector<int> selectedIndices() const;
55  QStringList selectedValues() const;
56 
57  void setSelected(int index, bool value = true);
58  void setSelected(const QString& name, bool value = true);
59 
60  QString stringOfSelections() const;
61  void setStringOfSelections(const QString& values);
62 
63  QString label() const;
64 
65 private:
66  ComboProperty(QStringList values);
67 
68  QStringList m_values;
69  QStringList m_tooltips;
70  QVector<int> m_selected_indices;
71 };
72 
73 Q_DECLARE_METATYPE(ComboProperty)
74 
75 #endif // BORNAGAIN_GUI_UTIL_COMBOPROPERTY_H
@ other
The unit has no enum value defined in here (e.g. when defined as an explicit string)
Custom property to define list of string values with multiple selections. Intended for QVariant.
Definition: ComboProperty.h:25
void setStringOfValues(const QString &values)
Sets values from the string containing delimeter ';'.
QString stringOfSelections() const
Return string with coma separated list of selected indices.
ComboProperty & operator<<(const QString &str)
QStringList m_values
Definition: ComboProperty.h:68
QStringList getValues() const
bool operator==(const ComboProperty &other) const
void setStringOfSelections(const QString &values)
Sets selected indices from string.
bool operator<(const ComboProperty &other) const
QVector< int > selectedIndices() const
Returns vector of selected indices.
static ComboProperty fromList(const QStringList &values, const QString &current_value="")
int currentIndex() const
QVector< int > m_selected_indices
Definition: ComboProperty.h:70
QString stringOfValues() const
Returns a single string containing values delimited with ';'.
QVariant variant() const
Constructs variant enclosing given ComboProperty.
void setSelected(int index, bool value=true)
Sets given index selection flag. If false, index will be excluded from selection.
void setValue(const QString &name)
QString label() const
Returns the label to show.
QString getValue() const
void setToolTips(const QStringList &tooltips)
QStringList m_tooltips
Definition: ComboProperty.h:69
QStringList selectedValues() const
Returns list of string with selected values;.
bool operator!=(const ComboProperty &other) const
QStringList toolTips() const
Returns list of tool tips for all values.
void setCurrentIndex(int index)
void setValues(const QStringList &values)
Sets new list of values. Current value will be preserved, if exists in a new list.
QString const & name(EShape k)
Definition: particles.cpp:20