8#include <private/qqmlcontextdata_p.h>
9#include <private/qqmlproperty_p.h>
10#include <private/qqmlpropertycache_p.h>
18 if (elementType.isNull() || !QQmlMetaObject::canConvert(object, elementType))
34 if (!prop.object)
return rv;
36 rv.d =
new QQmlListReferencePrivate;
37 rv.d->object = prop.object;
38 rv.d->property = prop;
39 rv.d->propertyType = propType;
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
99
100
101
102
103
104
105
106
107
110
111
112QQmlListReference::QQmlListReference()
117#if QT_DEPRECATED_SINCE(6
, 4
)
119
120
121
122
123
124
125
126
127
128
129
130QQmlListReference::QQmlListReference(
const QVariant &variant, [[maybe_unused]] QQmlEngine *engine)
131 : QQmlListReference(variant)
135
136
137
138
139
140
141
142
143
144QQmlListReference::QQmlListReference(QObject *object,
const char *property,
145 [[maybe_unused]] QQmlEngine *engine)
146 : QQmlListReference(object, property)
151
152
153
154
155
156
157
158
159QQmlListReference::QQmlListReference(
const QVariant &variant)
162 const QMetaType t = variant.metaType();
163 if (!(t.flags() & QMetaType::IsQmlList))
166 d =
new QQmlListReferencePrivate;
169 d->property.~QQmlListProperty();
170 t.construct(&d->property, variant.constData());
172 d->object = d->property.object;
176
177
178
179
180
181QQmlListReference::QQmlListReference(QObject *object,
const char *property)
184 if (!object || !property)
return;
186 QQmlPropertyData local;
187 const QQmlPropertyData *data =
188 QQmlPropertyCache::property(object, QLatin1String(property),
nullptr, &local);
190 if (!data || !data->isQList())
return;
192 d =
new QQmlListReferencePrivate;
194 d->propertyType = data->propType();
196 void *args[] = { &d->property,
nullptr };
197 QMetaObject::metacall(object, QMetaObject::ReadProperty, data->coreIndex(), args);
201QQmlListReference::QQmlListReference(
const QQmlListReference &o)
208QQmlListReference &QQmlListReference::operator=(
const QQmlListReference &o)
210 if (o.d) o.d->addref();
217QQmlListReference::~QQmlListReference()
223
224
225bool QQmlListReference::isValid()
const
227 return d && d->object;
231
232
233QObject *QQmlListReference::object()
const
235 if (isValid())
return d->object;
240
241
242
243
244
245
246const QMetaObject *QQmlListReference::listElementType()
const
248 return isValid() ? d->elementType() :
nullptr;
252
253
254
255
256
257bool QQmlListReference::canAppend()
const
259 return (isValid() && d->property.append);
263
264
265
266
267
268bool QQmlListReference::canAt()
const
270 return (isValid() && d->property.at);
274
275
276
277
278
279bool QQmlListReference::canClear()
const
281 return (isValid() && d->property.clear);
285
286
287
288
289
290bool QQmlListReference::canCount()
const
292 return (isValid() && d->property.count);
296
297
298
299
300
301bool QQmlListReference::canReplace()
const
303 return (isValid() && d->property.replace);
307
308
309
310
311
312bool QQmlListReference::canRemoveLast()
const
314 return (isValid() && d->property.removeLast);
318
319
320
321
322
323
324
325
326
327
328bool QQmlListReference::isManipulable()
const
331 && d->property.append
334 && d->property.clear);
339
340
341
342
343bool QQmlListReference::isReadable()
const
345 return (isValid() && d->property.count && d->property.at);
349
350
351
352
353bool QQmlListReference::append(QObject *object)
const
355 if (!canAppend())
return false;
357 if (!isObjectCompatible(object, d))
360 d->property.append(&d->property, object);
366
367
368
369
370QObject *QQmlListReference::at(qsizetype index)
const
372 if (!canAt())
return nullptr;
374 return d->property.at(&d->property, index);
378
379
380
381
382bool QQmlListReference::clear()
const
384 if (!canClear())
return false;
386 d->property.clear(&d->property);
392
393
394qsizetype QQmlListReference::count()
const
396 if (!canCount())
return 0;
398 return d->property.count(&d->property);
402
403
404
405
408
409
410
411
412
413bool QQmlListReference::replace(qsizetype index, QObject *object)
const
418 if (!isObjectCompatible(object, d))
421 d->property.replace(&d->property, index, object);
426
427
428
429
430
431bool QQmlListReference::removeLast()
const
433 if (!canRemoveLast())
436 d->property.removeLast(&d->property);
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
485
486
487
488
489
490
491
492
493
494
495
496
497
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
517
518
519
520
521
522
523
524
525
526
527
528
529
532
533
534
537
538
539
540
541
542
543
544
545
546
547
548
549
552
553
554
555
556
557
558
559
560
561
562
563
564
567
568
569
570
571
572
573
574
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
626
627
628
629
630
631
634
635
636
637
638
639
642
643
644
645
648
649
650
651
652
653
656
657
658
659
660
661
664
665
666
667
668
669
672
673
674
675
676
677
680
681
682
683
684
685
688
689
690
691
692
693
694
695
696
697
698
699
700
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
const QMetaObject * elementType()
QQmlListReferencePrivate()
The QQmlListReference class allows the manipulation of \l QQmlListProperty properties.
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE bool isObjectCompatible(QObject *object, QQmlListReferencePrivate *d)