7#include <private/qmetaobjectbuilder_p.h>
8#include <private/qqmlopenmetaobject_p.h>
35 Q_DECLARE_PUBLIC(QQmlPropertyMap)
50 return name != QLatin1String(
"keys")
51 && name != QLatin1String(
"valueChanged")
52 && name != QLatin1String(
"QObject")
53 && name != QLatin1String(
"destroyed")
54 && name != QLatin1String(
"deleteLater");
60 return q->updateValue(key, input);
66 emit q->valueChanged(key, value);
71 Q_ASSERT(index < keys.size());
84 return priv->updateValue(priv->propertyName(index), input);
89 priv->emitChanged(priv->propertyName(index), value(index));
94 priv->keys.append(QString::fromUtf8(b.name()));
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
144
146#if QT_DEPRECATED_SINCE(6
, 11
)
148
149
150
151
152QQmlPropertyMap::QQmlPropertyMap(QObject *parent)
153: QQmlPropertyMap(&staticMetaObject, parent)
159
160
161QQmlPropertyMap *QQmlPropertyMap::create(QObject *parent)
163 return new QQmlPropertyMap(&staticMetaObject, parent);
167
168
169QQmlPropertyMap::~QQmlPropertyMap()
174
175
176void QQmlPropertyMap::clear(
const QString &key)
178 Q_D(QQmlPropertyMap);
179 if (d->validKeyName(key))
180 d->mo->setValue(key.toUtf8(), QVariant());
184
185
186
187
188
189
190
191
192void QQmlPropertyMap::freeze()
194 Q_D(QQmlPropertyMap);
195 d->mo->setAutoCreatesProperties(
false);
196 d->mo->setCached(
true);
200
201
202
203
204
205QVariant QQmlPropertyMap::value(
const QString &key)
const
207 Q_D(
const QQmlPropertyMap);
208 return d->mo->value(key.toUtf8());
212
213
214
215
216void QQmlPropertyMap::insert(
const QString &key,
const QVariant &value)
218 Q_D(QQmlPropertyMap);
220 if (d->validKeyName(key)) {
221 d->mo->setValue(key.toUtf8(), value);
223 qWarning() <<
"Creating property with name"
225 <<
"is not permitted, conflicts with internal symbols.";
230
231
232
233
234
235
236
237
238
239void QQmlPropertyMap::insert(
const QVariantHash &values)
241 Q_D(QQmlPropertyMap);
243 QHash<QByteArray, QVariant> checkedValues;
244 for (
auto it = values.begin(), end = values.end(); it != end; ++it) {
245 const QString &key = it.key();
246 if (!d->validKeyName(key)) {
247 qWarning() <<
"Creating property with name"
249 <<
"is not permitted, conflicts with internal symbols.";
253 checkedValues.insert(key.toUtf8(), it.value());
255 d->mo->setValues(checkedValues);
260
261
262
263
264
265QStringList QQmlPropertyMap::keys()
const
267 Q_D(
const QQmlPropertyMap);
272
273
274
275
276int QQmlPropertyMap::count()
const
278 Q_D(
const QQmlPropertyMap);
279 return d->keys.size();
283
284
285
286
287int QQmlPropertyMap::size()
const
289 Q_D(
const QQmlPropertyMap);
290 return d->keys.size();
294
295
296
297
298
299bool QQmlPropertyMap::isEmpty()
const
301 Q_D(
const QQmlPropertyMap);
302 return d->keys.isEmpty();
306
307
308
309
310bool QQmlPropertyMap::contains(
const QString &key)
const
312 Q_D(
const QQmlPropertyMap);
313 return d->keys.contains(key);
317
318
319
320
321
322
323
324
325
326QVariant &QQmlPropertyMap::operator[](
const QString &key)
329 Q_D(QQmlPropertyMap);
330 QByteArray utf8key = key.toUtf8();
331 if (!d->keys.contains(key))
332 insert(key, QVariant());
334 return d->mo->valueRef(utf8key);
338
339
340
341
342QVariant QQmlPropertyMap::operator[](
const QString &key)
const
348
349
350
351
352
353
354QVariant QQmlPropertyMap::updateValue(
const QString &key,
const QVariant &input)
361QQmlPropertyMap::QQmlPropertyMap(
const QMetaObject *staticMetaObject, QObject *parent)
362 : QObject(*(
new QQmlPropertyMapPrivate), parent)
364 Q_D(QQmlPropertyMap);
365 d->mo =
new QQmlPropertyMapMetaObject(
this, d, staticMetaObject);
369
370
371
372
373
374
375
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
405#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)
Combined button and popup list for selecting options.