24 #include <QCoreApplication>
28 #include "../vproperty_p.h"
31 :
VProperty(name, QVariant::Int), EnumerationLiterals()
41 if (EnumerationLiterals.empty())
48 if (tmpIndex < 0 || tmpIndex >= EnumerationLiterals.count())
53 if (column == DPC_Data && Qt::DisplayRole == role)
55 return EnumerationLiterals.at(tmpIndex);
57 else if (column == DPC_Data && Qt::EditRole == role)
68 const QAbstractItemDelegate* delegate)
72 QComboBox* tmpEditor =
new QComboBox(parent);
74 tmpEditor->setLocale(parent->locale());
75 tmpEditor->addItems(EnumerationLiterals);
77 connect(tmpEditor,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this,
87 const QComboBox* tmpEditor = qobject_cast<const QComboBox*>(editor);
90 return tmpEditor->currentIndex();
99 EnumerationLiterals = literals;
105 return EnumerationLiterals;
111 int tmpIndex = value.toInt();
113 if (tmpIndex < 0 || tmpIndex >= EnumerationLiterals.count())
139 if (key ==
"literals")
141 setLiterals(value.toString().split(
";;"));
147 if (key ==
"literals")
149 return getLiterals().join(
";;");
157 return QStringList(
"literals");
void currentIndexChanged(int index)
virtual QStringList getLiterals() const
Get the settings. This function has to be implemented in a subclass in order to have an effect.
virtual void setValue(const QVariant &value) Q_DECL_OVERRIDE
Sets the value of the property.
virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE
Returns the list of keys of the property's settings.
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
Get the data how it should be displayed.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this property.
virtual void setSetting(const QString &key, const QVariant &value) Q_DECL_OVERRIDE
Sets the settings. Available settings:
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
Gets the data from the widget.
virtual QVariant getSetting(const QString &key) const Q_DECL_OVERRIDE
Get the settings. This function has to be implemented in a subclass in order to have an effect.
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &options, const QAbstractItemDelegate *delegate) Q_DECL_OVERRIDE
Returns an editor widget, or NULL if it doesn't supply one.
VEnumProperty(const QString &name)
Constructor.
virtual void setLiterals(const QStringList &literals)
Sets the enumeration literals.
QVariant VariantValue
The property's value. This does not have to be used by subclasses, but it makes sense in cases where ...
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const
Clones this property.
VPropertyPrivate * d_ptr
The protected structure holding the member variables (to assure binary compatibility)
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const
Get the data how it should be displayed.
virtual QVariant getSetting(const QString &key) const
Get the settings. This function has to be implemented in a subclass in order to have an effect.