34 QList<OptionalEdit*> editors = editorToProperty.keys();
35 QListIterator<OptionalEdit*> it(editors);
52 SIGNAL(valueChanged(
QtProperty*,
const QVariant&)),
54 SLOT(slotPropertyChanged(
QtProperty*,
const QVariant&)));
56 SIGNAL(attributeChanged(
QtProperty*,
const QString&,
const QVariant&)),
58 SLOT(slotPropertyAttributeChanged(
QtProperty*,
const QString&,
const QVariant&)));
76 ->attributeValue(varProp, QLatin1String(
"PossibleValues"))
83 ->attributeValue(property, QLatin1String(
"enabled"))
86 ->attributeValue(property, QLatin1String(
"readOnly"))
89 createdEditors[property].append(editor);
90 editorToProperty[editor] = property;
93 connect(editor, SIGNAL(valueChanged(QString)),
this, SLOT(slotSetValue(
const QString&)));
94 connect(editor, SIGNAL(enabledChanged(
bool)),
this, SLOT(slotSetEnabled(
const bool&)));
95 connect(editor, SIGNAL(destroyed(QObject*)),
this, SLOT(slotEditorDestroyed(QObject*)));
105 SIGNAL(valueChanged(
QtProperty*,
const QVariant&)),
107 SLOT(slotPropertyChanged(
QtProperty*,
const QVariant&)));
109 SIGNAL(attributeChanged(
QtProperty*,
const QString&,
const QVariant&)),
111 SLOT(slotPropertyAttributeChanged(
QtProperty*,
const QString&,
const QVariant&)));
116OptionalVariantFactory::slotPropertyChanged(
QtProperty* property,
const QVariant& value)
118 if (!createdEditors.contains(property))
123 QList<OptionalEdit*> editors = createdEditors[property];
124 QListIterator<OptionalEdit*> itEditor(editors);
125 while (itEditor.hasNext())
127 itEditor.next()->setValue(
value.toString());
132OptionalVariantFactory::slotPropertyAttributeChanged(
QtProperty* property,
133 const QString& attribute,
134 const QVariant& value)
136 if (!createdEditors.contains(property))
141 if (attribute == QLatin1String(
"enabled"))
143 QList<OptionalEdit*> editors = createdEditors[property];
144 QListIterator<OptionalEdit*> itEditor(editors);
145 while (itEditor.hasNext())
147 itEditor.next()->setPropertyEnabled(
value.toBool());
151 if (attribute == QLatin1String(
"readOnly"))
153 QList<OptionalEdit*> editors = createdEditors[property];
154 QListIterator<OptionalEdit*> itEditor(editors);
155 while (itEditor.hasNext())
157 itEditor.next()->setReadOnly(
value.toBool());
163OptionalVariantFactory::slotSetValue(
const QString& value)
165 QObject*
object = sender();
166 QMap<OptionalEdit*, QtProperty*>::ConstIterator itEditor = editorToProperty.constBegin();
167 while (itEditor != editorToProperty.constEnd())
169 if (itEditor.key() ==
object)
171 QtProperty*
property = itEditor.value();
172 OptionalVariantManager* manager =
186OptionalVariantFactory::slotSetEnabled(
const bool& value)
188 QObject*
object = sender();
189 QMap<OptionalEdit*, QtProperty*>::ConstIterator itEditor = editorToProperty.constBegin();
190 while (itEditor != editorToProperty.constEnd())
192 if (itEditor.key() ==
object)
194 QtProperty*
property = itEditor.value();
195 OptionalVariantManager* manager =
201 manager->
setAttribute(property, QLatin1String(
"enabled"), value);
209OptionalVariantFactory::slotEditorDestroyed(QObject*
object)
211 QMap<OptionalEdit*, QtProperty*>::ConstIterator itEditor = editorToProperty.constBegin();
212 while (itEditor != editorToProperty.constEnd())
214 if (itEditor.key() ==
object)
216 OptionalEdit* editor = itEditor.key();
217 QtProperty*
property = itEditor.value();
218 editorToProperty.remove(editor);
219 createdEditors[property].removeAll(editor);
220 if (createdEditors[property].isEmpty())
222 createdEditors.remove(property);
~OptionalVariantFactory() override
void connectPropertyManager(QtVariantPropertyManager *manager) override
void disconnectPropertyManager(QtVariantPropertyManager *manager) override
QWidget * createEditor(QtVariantPropertyManager *manager, QtProperty *property, QWidget *parent) override
void setElementName(const QString &name)
void setValue(QtProperty *property, const QVariant &val) override
void setAttribute(QtProperty *property, const QString &attribute, const QVariant &value) override
static int optionalProprtyTypeId()
QtVariantPropertyManager * propertyManager(QtProperty *property) const
The QtProperty class encapsulates an instance of a property.
QString propertyName() const
void connectPropertyManager(QtVariantPropertyManager *manager) override
void disconnectPropertyManager(QtVariantPropertyManager *manager) override
QWidget * createEditor(QtVariantPropertyManager *manager, QtProperty *property, QWidget *parent) override
The QtVariantPropertyManager class provides and manages QVariant based properties.
virtual QVariant value(const QtProperty *property) const
int propertyType(const QtProperty *property) const
The QtVariantProperty class is a convenience class handling QVariant based properties.
void setPossibleValues(const QStringList &values)
void setValue(const QString &value)
void setPropertyEnabled(const bool &enabled=true)
void setReadOnly(bool readOnly)
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< Value > value()