13#include "customtyperegistry_p.h"
14#include "metaenumvariable_p.h"
16#include <QAssociativeIterable>
18#include <QSequentialIterable>
22Q_GLOBAL_STATIC(CustomTypeRegistry, customTypes)
24void KTextTemplate::MetaType::internalLock()
26 return customTypes()->mutex.lock();
29void KTextTemplate::MetaType::internalUnlock()
31 return customTypes()->mutex.unlock();
34void KTextTemplate::MetaType::registerLookUpOperator(
int id, LookupFunction f)
39 customTypes()->registerLookupOperator(
id, f);
46 if (property == QStringLiteral(
"children")) {
47 const auto &childList =
object->children();
48 if (childList.isEmpty())
50 QVariantList children;
52 auto it = childList.constBegin();
53 const auto end = childList.constEnd();
54 for (; it !=
end; ++it)
59 if (property == QStringLiteral(
"objectName")) {
60 return object->objectName();
63 auto metaObj =
object->metaObject();
66 for (
auto i = 0; i < metaObj->propertyCount(); ++i) {
69 mp = metaObj->property(i);
79 return mp.
read(
object);
82 for (
auto i = 0; i < metaObj->enumeratorCount(); ++i) {
83 me = metaObj->enumerator(i);
86 MetaEnumVariable mev(me);
95 const MetaEnumVariable mev(me, value);
104 if (
object.canConvert<QObject *>()) {
105 return doQobjectLookUp(
object.value<QObject *>(), property);
107 if (
object.canConvert<QVariantList>()) {
109 if (property == QStringLiteral(
"size") || property == QStringLiteral(
"count")) {
114 const auto listIndex =
property.toInt(&ok);
116 if (!ok || listIndex >= iter.size()) {
120 return iter.at(listIndex);
122 if (
object.canConvert<QVariantHash>()) {
125 if (iter.find(property) != iter.end()) {
126 return iter.value(property);
129 if (property == QStringLiteral(
"size") || property == QStringLiteral(
"count")) {
133 if (property == QStringLiteral(
"items")) {
134 auto it = iter.begin();
135 const auto end = iter.end();
137 for (; it !=
end; ++it) {
143 if (property == QStringLiteral(
"keys")) {
144 auto it = iter.begin();
145 const auto end = iter.end();
147 for (; it !=
end; ++it) {
153 if (property == QStringLiteral(
"values")) {
154 auto it = iter.begin();
155 const auto end = iter.end();
157 for (; it !=
end; ++it) {
171 const auto mp = mo->property(idx);
182 for (
auto i = 0; i < mo->enumeratorCount(); ++i) {
183 me = mo->enumerator(i);
186 MetaEnumVariable mev(me);
196 MetaEnumVariable mev(me, value);
202 return customTypes()->lookup(
object, property);
205bool KTextTemplate::MetaType::lookupAlreadyRegistered(
int id)
207 return customTypes()->lookupAlreadyRegistered(
id);
KIOCORE_EXPORT QStringList list(const QString &fileClass)
const QList< QKeySequence > & end()
The KTextTemplate namespace holds all public KTextTemplate API.
const char * constData() const const
void push_back(parameter_type value)
QString fromUtf8(QByteArrayView str)
QByteArray toLatin1() const const
QByteArray toUtf8() const const
QVariant fromValue(T &&value)