31 #include <QCoreApplication>
35 #include "../vproperty_p.h"
49 if (m_objects.empty())
56 if (tmpIndex < 0 || tmpIndex >= m_indexList.count())
61 if (column == DPC_Data && Qt::DisplayRole == role)
63 return m_objects.value(m_indexList.at(tmpIndex));
65 else if (column == DPC_Data && Qt::EditRole == role)
77 const QAbstractItemDelegate *delegate)
81 QComboBox *objEditor =
new QComboBox(parent);
83 objEditor->setMinimumWidth(140);
84 objEditor->setLocale(parent->locale());
85 fillListItems(objEditor, m_objects);
87 connect(objEditor,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
97 const QComboBox *objEditor = qobject_cast<const QComboBox*>(editor);
100 return objEditor->currentIndex();
110 this->m_objects = objects;
114 while (i != objects.constEnd())
116 m_indexList.append(i.key());
131 int tmpIndex = value.toInt();
133 if (tmpIndex < 0 || tmpIndex >= m_indexList.count())
161 while (i != objects.constEnd())
163 m_indexList.append(i.key());
166 return m_indexList.indexOf(
object);
181 for (i = list.constBegin(); i != list.constEnd(); ++i)
183 box->addItem(i.key(), i.value());
VObjectProperty(const QString &name)
Constructor.
static int indexOfObject(const QMap< QString, quint32 > &objects, const QString &object)
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this property.
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
Get the data how it should be displayed.
virtual void setValue(const QVariant &value) Q_DECL_OVERRIDE
Sets the value of the property.
void currentIndexChanged(int index)
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
Gets the data from the widget.
void setObjectsList(const QMap< QString, quint32 > &objects)
Sets the objects list.
void fillListItems(QComboBox *box, const QMap< QString, quint32 > &list) const
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.
virtual QMap< QString, quint32 > getObjects() const
Get the settings. This function has to be implemented in a subclass in order to have an effect.
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.