22 #include "customtyperegistry_p.h"
24 #include "metaenumvariable_p.h"
25 #include "safestring.h"
27 #include <QtCore/QLoggingCategory>
28 #include <QtCore/QQueue>
29 #include <QtCore/QStack>
30 #include <QtCore/QStringList>
32 Q_LOGGING_CATEGORY(CUTELEE_CUSTOMTYPE,
"cutelee.customtype")
36 CustomTypeRegistry::CustomTypeRegistry()
39 registerBuiltInMetatype<SafeString>();
40 registerBuiltInMetatype<MetaEnumVariable>();
41 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
42 QMetaType::registerComparators<MetaEnumVariable>();
46 void CustomTypeRegistry::registerLookupOperator(
int id,
47 MetaType::LookupFunction f)
49 CustomTypeInfo &info = types[id];
50 info.lookupFunction = f;
56 if (!
object.isValid())
59 const auto id =
object.userType();
60 MetaType::LookupFunction lf;
62 auto it = types.constFind(
id);
63 if (it == types.constEnd()) {
64 qCWarning(CUTELEE_CUSTOMTYPE)
65 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
66 <<
"Don't know how to handle metatype" << QMetaType::typeName(
id);
68 <<
"Don't know how to handle metatype" << QMetaType(
id).name();
74 const CustomTypeInfo &info = it.value();
75 if (!info.lookupFunction) {
76 qCWarning(CUTELEE_CUSTOMTYPE)
77 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
78 <<
"No lookup function for metatype" << QMetaType::typeName(
id);
80 <<
"No lookup function for metatype" << QMetaType(
id).name();
87 lf = info.lookupFunction;
90 return lf(
object, property);
93 bool CustomTypeRegistry::lookupAlreadyRegistered(
int id)
const
95 auto it = types.constFind(
id);
96 if (it != types.constEnd()) {
97 return it.value().lookupFunction != 0;
The Cutelee namespace holds all public Cutelee API.