BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ExternalProperty.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/MaterialEditor/ExternalProperty.cpp
6 //! @brief Implements class ExternalProperty
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 
18 
20 
21 QString ExternalProperty::text() const
22 {
23  return m_text;
24 }
25 
26 void ExternalProperty::setText(const QString& name)
27 {
28  m_text = name;
29 }
30 
32 {
33  return m_color;
34 }
35 
36 void ExternalProperty::setColor(const QColor& color)
37 {
38  m_color = color;
39 }
40 
42 {
43  return m_identifier;
44 }
45 
46 void ExternalProperty::setIdentifier(const QString& identifier)
47 {
49 }
50 
51 QPixmap ExternalProperty::pixmap() const
52 {
53  QPixmap pixmap(10, 10);
54  pixmap.fill(color());
55  return pixmap;
56 }
57 
58 //! Returns true if property is in valid state (i.e. have at least one member defined).
59 
61 {
62  if (m_identifier.isEmpty() && m_text.isEmpty() && !m_color.isValid())
63  return false;
64 
65  return true;
66 }
67 
68 QVariant ExternalProperty::variant() const
69 {
70  QVariant variant;
71  variant.setValue(*this);
72  return variant;
73 }
74 
76 {
77  if (m_identifier != other.m_identifier)
78  return false;
79  if (m_text != other.m_text)
80  return false;
81  if (m_color != other.m_color)
82  return false;
83 
84  return true;
85 }
86 
88 {
89  return !(*this == other);
90 }
91 
93 {
94  return m_identifier < other.m_identifier && m_text < other.m_text;
95 }
Defines class ExternalProperty.
Defines class MaterialItem.
Defines class MaterialModel.
The ExternalProperty class defines custom QVariant property to carry the text, color and an identifie...
QString identifier() const
QVariant variant() const
void setColor(const QColor &color)
bool operator<(const ExternalProperty &other) const
bool operator==(const ExternalProperty &other) const
QString text() const
bool operator!=(const ExternalProperty &other) const
QPixmap pixmap() const
void setText(const QString &name)
bool isValid() const
Returns true if property is in valid state (i.e. have at least one member defined).
void setIdentifier(const QString &identifier)
QColor color() const
QString const & name(EShape k)
Definition: particles.cpp:21