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
146
147
148QQmlPropertyMap::QQmlPropertyMap(QObject *parent)
149: QQmlPropertyMap(&staticMetaObject, parent)
154
155
156QQmlPropertyMap::~QQmlPropertyMap()
161
162
163void QQmlPropertyMap::clear(
const QString &key)
165 Q_D(QQmlPropertyMap);
166 if (d->validKeyName(key))
167 d->mo->setValue(key.toUtf8(), QVariant());
171
172
173
174
175
176
177
178
179void QQmlPropertyMap::freeze()
181 Q_D(QQmlPropertyMap);
182 d->mo->setAutoCreatesProperties(
false);
183 d->mo->setCached(
true);
187
188
189
190
191
192QVariant QQmlPropertyMap::value(
const QString &key)
const
194 Q_D(
const QQmlPropertyMap);
195 return d->mo->value(key.toUtf8());
199
200
201
202
203void QQmlPropertyMap::insert(
const QString &key,
const QVariant &value)
205 Q_D(QQmlPropertyMap);
207 if (d->validKeyName(key)) {
208 d->mo->setValue(key.toUtf8(), value);
210 qWarning() <<
"Creating property with name"
212 <<
"is not permitted, conflicts with internal symbols.";
217
218
219
220
221
222
223
224
225
226void QQmlPropertyMap::insert(
const QVariantHash &values)
228 Q_D(QQmlPropertyMap);
230 QHash<QByteArray, QVariant> checkedValues;
231 for (
auto it = values.begin(), end = values.end(); it != end; ++it) {
232 const QString &key = it.key();
233 if (!d->validKeyName(key)) {
234 qWarning() <<
"Creating property with name"
236 <<
"is not permitted, conflicts with internal symbols.";
240 checkedValues.insert(key.toUtf8(), it.value());
242 d->mo->setValues(checkedValues);
247
248
249
250
251
252QStringList QQmlPropertyMap::keys()
const
254 Q_D(
const QQmlPropertyMap);
259
260
261
262
263int QQmlPropertyMap::count()
const
265 Q_D(
const QQmlPropertyMap);
266 return d->keys.size();
270
271
272
273
274int QQmlPropertyMap::size()
const
276 Q_D(
const QQmlPropertyMap);
277 return d->keys.size();
281
282
283
284
285
286bool QQmlPropertyMap::isEmpty()
const
288 Q_D(
const QQmlPropertyMap);
289 return d->keys.isEmpty();
293
294
295
296
297bool QQmlPropertyMap::contains(
const QString &key)
const
299 Q_D(
const QQmlPropertyMap);
300 return d->keys.contains(key);
304
305
306
307
308
309
310
311
312
313QVariant &QQmlPropertyMap::operator[](
const QString &key)
316 Q_D(QQmlPropertyMap);
317 QByteArray utf8key = key.toUtf8();
318 if (!d->keys.contains(key))
319 insert(key, QVariant());
321 return d->mo->valueRef(utf8key);
325
326
327
328
329QVariant QQmlPropertyMap::operator[](
const QString &key)
const
335
336
337
338
339
340
341QVariant QQmlPropertyMap::updateValue(
const QString &key,
const QVariant &input)
348QQmlPropertyMap::QQmlPropertyMap(
const QMetaObject *staticMetaObject, QObject *parent)
349 : QObject(*(
new QQmlPropertyMapPrivate), parent)
351 Q_D(QQmlPropertyMap);
352 d->mo =
new QQmlPropertyMapMetaObject(
this, d, staticMetaObject);
356
357
358
359
360
361
362
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
392#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.