MCPcopy Create free account
hub / github.com/KDAB/GammaRay / enumToString

Method enumToString

core/enumutil.cpp:122–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122QString EnumUtil::enumToString(const QVariant &value, const char *typeName, const QMetaObject *metaObject)
123{
124 const auto me = metaEnum(value, typeName, metaObject);
125 if (me.isValid()) {
126 if (me.isFlag()) {
127 return QString::fromUtf8(me.valueToKeys(enumToInt(value, me)));
128 } else {
129 return QString::fromUtf8(me.valueToKey(enumToInt(value, me)));
130 }
131 }
132 if (EnumRepositoryServer::isEnum(value.userType())) {
133 const auto ev = EnumRepositoryServer::valueFromVariant(value);
134 const auto def = EnumRepositoryServer::definitionForId(ev.id());
135 return def.valueToString(ev);
136 }
137 return QString();
138}

Callers

nothing calls this directly

Calls 6

isEnumFunction · 0.85
isFlagMethod · 0.80
valueToStringMethod · 0.80
QStringClass · 0.70
isValidMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected