16 #include "Base/Util/Assert.h"
21 const QString value_separator =
";";
22 const QString selection_separator =
",";
29 : m_values(std::move(values))
37 if (!current_value.isEmpty())
51 throw Error(
"ComboProperty::setValue() -> Error. Combo doesn't contain "
66 ASSERT(values.size());
90 if (index < 0 || index >=
m_values.size())
91 throw Error(
"ComboProperty::setCurrentIndex(int index) -> Error. "
124 return !(*
this ==
other);
137 return m_values.join(value_separator);
145 m_values = values.split(value_separator);
154 result.setValue(*
this);
180 if (index < 0 || index >=
m_values.size())
203 text.append(QString::number(index));
204 return text.join(selection_separator);
212 if (values.isEmpty())
215 for (
const auto& str : values.split(selection_separator)) {
217 int num = str.toInt(&success);
Defines class ComboProperty.
@ 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.
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 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 ¤t_value="")
QVector< int > m_selected_indices
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.
void setToolTips(const QStringList &tooltips)
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)