6#include <private/qobjectregistrysingleton_p.h>
11
12
13
14
15
16
17
18
19
20
21
22
23
24
27
28
29
30
31
32
33
34
35
36
37
38
39
40
43
44
45
46
49
50
51
52
55
56
57
58
61QAbstractObjectRegistryRef::QAbstractObjectRegistryRef(QAbstractObjectRegistryRefPrivate &dd,
66QAbstractObjectRegistryRef::~QAbstractObjectRegistryRef()
68 Q_D(QAbstractObjectRegistryRef);
71 d->m_registry->deregisterRef(d);
74QString QAbstractObjectRegistryRef::key()
const
76 Q_D(
const QAbstractObjectRegistryRef);
81void QAbstractObjectRegistryRef::setKey(
const QString &key)
83 Q_D(QAbstractObjectRegistryRef);
89 d->m_registry = QObjectRegistrySingleton::registryForObject(
this);
91 qWarning() <<
"Object registry could not be resolved for ("
93 <<
") when setting key to QAbstractObjectRegistryRef."
94 <<
" Most likely reason for this is that QML engine could not be resolved.";
101 if (!d->m_key.isEmpty() && d->m_registry)
102 d->m_registry->deregisterRef(d);
106 if (!d->m_key.isEmpty() && d->m_registry)
107 d->m_registry->registerRef(d);
109 d->handleInitialObjects();
114QQmlListProperty<QObject> QAbstractObjectRegistryRef::data()
116 return {
this,
nullptr,
117 &QAbstractObjectRegistryRefPrivate::dataAppend,
118 &QAbstractObjectRegistryRefPrivate::dataCount,
119 &QAbstractObjectRegistryRefPrivate::dataAt,
120 &QAbstractObjectRegistryRefPrivate::dataClear,
121 &QAbstractObjectRegistryRefPrivate::dataReplace,
122 &QAbstractObjectRegistryRefPrivate::dataRemoveLast };
125QAbstractObjectRegistryRefPrivate::QAbstractObjectRegistryRefPrivate(QQmlEngine *engine)
127 m_registry = QObjectRegistrySingleton::registryForEngine(engine);
130QString QAbstractObjectRegistryRefPrivate::key()
const
135QObjectRegistrySingleton *QAbstractObjectRegistryRefPrivate::registry()
const
140void QAbstractObjectRegistryRefPrivate::dataAppend(QQmlListProperty<QObject> *l, QObject *o)
142 auto *self =
static_cast<QAbstractObjectRegistryRef *>(l->object);
143 self->d_func()->m_data.append(o);
145 emit self->dataChanged();
148qsizetype QAbstractObjectRegistryRefPrivate::dataCount(QQmlListProperty<QObject> *l)
150 return static_cast<QAbstractObjectRegistryRef *>(l->object)->d_func()->m_data.size();
153QObject *QAbstractObjectRegistryRefPrivate::dataAt(QQmlListProperty<QObject> *l, qsizetype i)
155 return static_cast<QAbstractObjectRegistryRef *>(l->object)->d_func()->m_data.at(i);
158void QAbstractObjectRegistryRefPrivate::dataClear(QQmlListProperty<QObject> *l)
160 auto *self =
static_cast<QAbstractObjectRegistryRef *>(l->object);
162 if (self->d_func()->m_data.isEmpty())
165 self->d_func()->m_data.clear();
167 emit self->dataChanged();
170void QAbstractObjectRegistryRefPrivate::dataReplace(QQmlListProperty<QObject> *l, qsizetype i, QObject *o)
172 auto *self =
static_cast<QAbstractObjectRegistryRef *>(l->object);
174 if (o == self->d_func()->m_data.at(i))
177 self->d_func()->m_data.replace(i, o);
179 emit self->dataChanged();
182void QAbstractObjectRegistryRefPrivate::dataRemoveLast(QQmlListProperty<QObject> *l)
184 auto *self =
static_cast<QAbstractObjectRegistryRef *>(l->object);
186 if (self->d_func()->m_data.isEmpty())
189 self->d_func()->m_data.removeLast();
191 emit self->dataChanged();
Combined button and popup list for selecting options.