41 #include <QMetaObject>
42 #include <QMetaProperty>
43 #include <QVBoxLayout>
44 #include <QScrollArea>
62 int enumToInt(
const QMetaEnum& metaEnum,
int enumValue)
const;
63 int intToEnum(
const QMetaEnum& metaEnum,
int intValue)
const;
64 int flagToInt(
const QMetaEnum& metaEnum,
int flagValue)
const;
65 int intToFlag(
const QMetaEnum& metaEnum,
int intValue)
const;
87 QMap<int, int> valueMap;
90 for (
int i = 0; i < metaEnum.keyCount(); i++)
92 int value = metaEnum.value(i);
94 if (!valueMap.contains(
value))
96 if (
value == enumValue)
101 valueMap[
value] = pos++;
110 QMap<int, bool> valueMap;
113 for (
int i = 0; i < metaEnum.keyCount(); i++)
115 int value = metaEnum.value(i);
117 if (!valueMap.contains(
value))
124 if (intValue >=
values.count())
129 return values.at(intValue);
134 if (
value == subValue)
143 if (!(
value & (1 << i)))
152 subValue = subValue >> 1;
181 QMap<int, int> valueMap;
184 for (
int i = 0; i < metaEnum.keyCount(); i++)
186 int value = metaEnum.value(i);
192 intValue |= (1 << pos);
195 valueMap[
value] = pos++;
204 QMap<int, bool> valueMap;
207 for (
int i = 0; i < metaEnum.keyCount(); i++)
209 int value = metaEnum.value(i);
213 valueMap[
value] =
true;
231 flagValue |=
values.at(i);
260 for (
int idx = metaObject->propertyOffset(); idx < metaObject->propertyCount(); idx++)
262 QMetaProperty metaProperty = metaObject->property(idx);
264 if (metaProperty.isReadable())
270 if (metaProperty.isEnumType())
272 if (metaProperty.isFlagType())
303 QString className = QLatin1String(metaObject->className());
308 for (
int idx = metaObject->propertyOffset(); idx < metaObject->propertyCount(); idx++)
310 QMetaProperty metaProperty = metaObject->property(idx);
311 int type = metaProperty.userType();
314 if (!metaProperty.isReadable())
317 subProperty->
setValue(QLatin1String(
"< Non Readable >"));
319 else if (metaProperty.isEnumType())
321 if (metaProperty.isFlagType())
324 QMetaEnum metaEnum = metaProperty.enumerator();
325 QMap<int, bool> valueMap;
326 QStringList flagNames;
328 for (
int i = 0; i < metaEnum.keyCount(); i++)
330 int value = metaEnum.value(i);
334 valueMap[
value] =
true;
335 flagNames.append(QLatin1String(metaEnum.key(i)));
338 subProperty->
setAttribute(QLatin1String(
"flagNames"), flagNames);
345 QMetaEnum metaEnum = metaProperty.enumerator();
346 QMap<int, bool> valueMap;
347 QStringList enumNames;
349 for (
int i = 0; i < metaEnum.keyCount(); i++)
351 int value = metaEnum.value(i);
353 if (!valueMap.contains(
value))
355 valueMap[
value] =
true;
356 enumNames.append(QLatin1String(metaEnum.key(i)));
360 subProperty->
setAttribute(QLatin1String(
"enumNames"), enumNames);
366 if (!metaProperty.isWritable())
371 if (!metaProperty.isDesignable())
385 subProperty->
setValue(QLatin1String(
"< Unknown Type >"));
422 const QMetaObject* metaObject =
m_object->metaObject();
423 QMetaProperty metaProperty = metaObject->property(idx);
425 if (metaProperty.isEnumType())
427 if (metaProperty.isFlagType())
466 QVBoxLayout* layout =
new QVBoxLayout(
this);
467 layout->setMargin(0);
476 this, SLOT(slotValueChanged(
QtProperty*,
const QVariant&)));
521 #include "moc_objectcontroller.cpp"