6#include <QtQml/private/qqmlproperty_p.h>
13 const QQmlMetaObject elementType = d->elementType();
14 if (elementType.isNull() || !QQmlMetaObject::canConvert(object, elementType))
30 if (!prop.object)
return rv;
32 rv.d =
new QQmlListReferencePrivate;
33 rv.d->object = prop.object;
34 rv.d->property = prop;
35 rv.d->propertyType = propType;
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
83
84
85QQmlListReference::QQmlListReference()
90#if QT_DEPRECATED_SINCE(6
, 4
)
92
93
94
95
96
97
98
99
100
101
102
103QQmlListReference::QQmlListReference(
const QVariant &variant, [[maybe_unused]] QQmlEngine *engine)
104 : QQmlListReference(variant)
108
109
110
111
112
113
114
115
116
117QQmlListReference::QQmlListReference(QObject *object,
const char *property,
118 [[maybe_unused]] QQmlEngine *engine)
119 : QQmlListReference(object, property)
124
125
126
127
128
129
130
131
132QQmlListReference::QQmlListReference(
const QVariant &variant)
135 const QMetaType t = variant.metaType();
136 if (!(t.flags() & QMetaType::IsQmlList))
139 d =
new QQmlListReferencePrivate;
142 d->property.~QQmlListProperty();
143 t.construct(&d->property, variant.constData());
145 d->object = d->property.object;
149
150
151
152
153
154QQmlListReference::QQmlListReference(QObject *object,
const char *property)
157 if (!object || !property)
return;
159 QQmlPropertyData local;
160 const QQmlPropertyData *data =
161 QQmlPropertyCache::property(object, QLatin1String(property),
nullptr, &local);
163 if (!data || !data->isQList())
return;
165 d =
new QQmlListReferencePrivate;
167 d->propertyType = data->propType();
169 void *args[] = { &d->property,
nullptr };
170 QMetaObject::metacall(object, QMetaObject::ReadProperty, data->coreIndex(), args);
174QQmlListReference::QQmlListReference(
const QQmlListReference &o)
181QQmlListReference &QQmlListReference::operator=(
const QQmlListReference &o)
183 if (o.d) o.d->addref();
190QQmlListReference::~QQmlListReference()
196
197
198bool QQmlListReference::isValid()
const
200 return d && d->object;
204
205
206QObject *QQmlListReference::object()
const
208 if (isValid())
return d->object;
213
214
215
216
217
218
219const QMetaObject *QQmlListReference::listElementType()
const
221 return isValid() ? d->elementType() :
nullptr;
225
226
227
228
229
230bool QQmlListReference::canAppend()
const
232 return (isValid() && d->property.append);
236
237
238
239
240
241bool QQmlListReference::canAt()
const
243 return (isValid() && d->property.at);
247
248
249
250
251
252bool QQmlListReference::canClear()
const
254 return (isValid() && d->property.clear);
258
259
260
261
262
263bool QQmlListReference::canCount()
const
265 return (isValid() && d->property.count);
269
270
271
272
273
274bool QQmlListReference::canReplace()
const
276 return (isValid() && d->property.replace);
280
281
282
283
284
285bool QQmlListReference::canRemoveLast()
const
287 return (isValid() && d->property.removeLast);
291
292
293
294
295
296
297
298
299
300
301bool QQmlListReference::isManipulable()
const
304 && d->property.append
307 && d->property.clear);
312
313
314
315
316bool QQmlListReference::isReadable()
const
318 return (isValid() && d->property.count && d->property.at);
322
323
324
325
326bool QQmlListReference::append(QObject *object)
const
328 if (!canAppend())
return false;
330 if (!isObjectCompatible(object, d))
333 d->property.append(&d->property, object);
339
340
341
342
343QObject *QQmlListReference::at(qsizetype index)
const
345 if (!canAt())
return nullptr;
347 return d->property.at(&d->property, index);
351
352
353
354
355bool QQmlListReference::clear()
const
357 if (!canClear())
return false;
359 d->property.clear(&d->property);
365
366
367qsizetype QQmlListReference::count()
const
369 if (!canCount())
return 0;
371 return d->property.count(&d->property);
375
376
377
378
381
382
383
384
385
386bool QQmlListReference::replace(qsizetype index, QObject *object)
const
391 if (!isObjectCompatible(object, d))
394 d->property.replace(&d->property, index, object);
399
400
401
402
403
404bool QQmlListReference::removeLast()
const
406 if (!canRemoveLast())
409 d->property.removeLast(&d->property);
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
454
455
456
457
458
459
460
461
462
463
464
465
466
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
486
487
488
489
490
491
492
493
494
495
496
497
498
501
502
503
506
507
508
509
510
511
512
513
514
515
516
517
520
521
522
523
524
525
526
529
530
531
532
533
534
535
536
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
587
588
589
590
591
592
595
596
597
598
599
600
603
604
605
606
609
610
611
612
613
614
617
618
619
620
621
622
625
626
627
628
629
630
633
634
635
636
637
638
641
642
643
644
645
646
647
648
649
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
QQmlListReferencePrivate()
The QQmlListReference class allows the manipulation of QQmlListProperty properties.
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE bool isObjectCompatible(QObject *object, QQmlListReferencePrivate *d)