6#include <private/qmetaobjectbuilder_p.h>
7#include <private/qqmlopenmetaobject_p.h>
34 Q_DECLARE_PUBLIC(QQmlPropertyMap)
49 return name != QLatin1String(
"keys")
50 && name != QLatin1String(
"valueChanged")
51 && name != QLatin1String(
"QObject")
52 && name != QLatin1String(
"destroyed")
53 && name != QLatin1String(
"deleteLater");
59 return q->updateValue(key, input);
65 emit q->valueChanged(key, value);
70 Q_ASSERT(index < keys.size());
83 return priv->updateValue(priv->propertyName(index), input);
88 priv->emitChanged(priv->propertyName(index), value(index));
93 priv->keys.append(QString::fromUtf8(b.name()));
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
145#if QT_DEPRECATED_SINCE(6
, 11
)
147
148
149
150
151QQmlPropertyMap::QQmlPropertyMap(QObject *parent)
152: QQmlPropertyMap(&staticMetaObject, parent)
158
159
160QQmlPropertyMap *QQmlPropertyMap::create(QObject *parent)
162 return new QQmlPropertyMap(&staticMetaObject, parent);
166
167
168QQmlPropertyMap::~QQmlPropertyMap()
173
174
175void QQmlPropertyMap::clear(
const QString &key)
177 Q_D(QQmlPropertyMap);
178 if (d->validKeyName(key))
179 d->mo->setValue(key.toUtf8(), QVariant());
183
184
185
186
187
188
189
190
191void QQmlPropertyMap::freeze()
193 Q_D(QQmlPropertyMap);
194 d->mo->setAutoCreatesProperties(
false);
195 d->mo->setCached(
true);
199
200
201
202
203
204QVariant QQmlPropertyMap::value(
const QString &key)
const
206 Q_D(
const QQmlPropertyMap);
207 return d->mo->value(key.toUtf8());
211
212
213
214
215void QQmlPropertyMap::insert(
const QString &key,
const QVariant &value)
217 Q_D(QQmlPropertyMap);
219 if (d->validKeyName(key)) {
220 d->mo->setValue(key.toUtf8(), value);
222 qWarning() <<
"Creating property with name"
224 <<
"is not permitted, conflicts with internal symbols.";
229
230
231
232
233
234
235
236
237
238void QQmlPropertyMap::insert(
const QVariantHash &values)
240 Q_D(QQmlPropertyMap);
242 QHash<QByteArray, QVariant> checkedValues;
243 for (
auto it = values.begin(), end = values.end(); it != end; ++it) {
244 const QString &key = it.key();
245 if (!d->validKeyName(key)) {
246 qWarning() <<
"Creating property with name"
248 <<
"is not permitted, conflicts with internal symbols.";
252 checkedValues.insert(key.toUtf8(), it.value());
254 d->mo->setValues(checkedValues);
259
260
261
262
263
264QStringList QQmlPropertyMap::keys()
const
266 Q_D(
const QQmlPropertyMap);
271
272
273
274
275int QQmlPropertyMap::count()
const
277 Q_D(
const QQmlPropertyMap);
278 return d->keys.size();
282
283
284
285
286int QQmlPropertyMap::size()
const
288 Q_D(
const QQmlPropertyMap);
289 return d->keys.size();
293
294
295
296
297
298bool QQmlPropertyMap::isEmpty()
const
300 Q_D(
const QQmlPropertyMap);
301 return d->keys.isEmpty();
305
306
307
308
309bool QQmlPropertyMap::contains(
const QString &key)
const
311 Q_D(
const QQmlPropertyMap);
312 return d->keys.contains(key);
316
317
318
319
320
321
322
323
324
325QVariant &QQmlPropertyMap::operator[](
const QString &key)
328 Q_D(QQmlPropertyMap);
329 QByteArray utf8key = key.toUtf8();
330 if (!d->keys.contains(key))
331 insert(key, QVariant());
333 return d->mo->valueRef(utf8key);
337
338
339
340
341QVariant QQmlPropertyMap::operator[](
const QString &key)
const
347
348
349
350
351
352
353QVariant QQmlPropertyMap::updateValue(
const QString &key,
const QVariant &input)
360QQmlPropertyMap::QQmlPropertyMap(
const QMetaObject *staticMetaObject, QObject *parent)
361 : QObject(*(
new QQmlPropertyMapPrivate), parent)
363 Q_D(QQmlPropertyMap);
364 d->mo =
new QQmlPropertyMapMetaObject(
this, d, staticMetaObject);
368
369
370
371
372
373
374
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
404#include "moc_qqmlpropertymap.cpp"
QVariant updateValue(const QString &key, const QVariant &input)
void emitChanged(const QString &key, const QVariant &value)
const QString & propertyName(int index) const
static bool validKeyName(const QString &name)