BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
comboproperty.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/comboproperty.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_COMBOPROPERTY_H
16 #define BORNAGAIN_MVVM_MODEL_MVVM_MODEL_COMBOPROPERTY_H
17 
18 #include "mvvm/core/variant.h"
19 #include "mvvm/model_export.h"
20 #include <string>
21 #include <vector>
22 
23 namespace ModelView {
24 
25 //! Custom property to define list of string values with multiple selections.
26 
27 class MVVM_MODEL_EXPORT ComboProperty {
28 public:
30 
31  static ComboProperty createFrom(const std::vector<std::string>& values,
32  const std::string& current_value = {});
33 
34  std::string value() const;
35  void setValue(const std::string& name);
36 
37  std::vector<std::string> values() const;
38  void setValues(const std::vector<std::string>& values);
39 
40  std::vector<std::string> toolTips() const;
41  void setToolTips(const std::vector<std::string>& tooltips);
42 
43  int currentIndex() const;
44  void setCurrentIndex(int index);
45 
46  ComboProperty& operator<<(const std::string& str);
47  ComboProperty& operator<<(const std::vector<std::string>& str);
48  bool operator==(const ComboProperty& other) const;
49  bool operator!=(const ComboProperty& other) const;
50  bool operator<(const ComboProperty& other) const;
51 
52  std::string stringOfValues() const;
53  void setStringOfValues(const std::string& values);
54 
55  std::vector<int> selectedIndices() const;
56  std::vector<std::string> selectedValues() const;
57 
58  void setSelected(int index, bool value = true);
59  void setSelected(const std::string& name, bool value = true);
60 
61  std::string stringOfSelections() const;
62  void setStringOfSelections(const std::string& values);
63 
64  std::string label() const;
65 
66 private:
67  ComboProperty(std::vector<std::string> values);
68 
69  std::vector<std::string> m_values;
70  std::vector<std::string> m_tooltips;
71  std::vector<int> m_selected_indices;
72 };
73 
74 } // namespace ModelView
75 
76 Q_DECLARE_METATYPE(ModelView::ComboProperty)
77 
78 #endif // BORNAGAIN_MVVM_MODEL_MVVM_MODEL_COMBOPROPERTY_H
bool operator<(const CumulativeValue &lhs, const CumulativeValue &rhs)
std::vector< const INode * > & operator<<(std::vector< const INode * > &v_node, const std::unique_ptr< T > &node)
Definition: INode.h:93
bool operator!=(const Material &left, const Material &right)
Comparison operator for material wrapper (inequality check)
Definition: Material.cpp:126
bool operator==(const Material &left, const Material &right)
Comparison operator for material wrapper (equality check)
Definition: Material.cpp:113
Custom property to define list of string values with multiple selections.
Definition: comboproperty.h:27
std::vector< std::string > m_tooltips
Definition: comboproperty.h:70
std::vector< std::string > m_values
Definition: comboproperty.h:69
std::vector< int > m_selected_indices
Definition: comboproperty.h:71
materialitems.h Collection of materials to populate MaterialModel.
QString const & name(EShape k)
Definition: particles.cpp:21
Defines class CLASS?