6#include <QtQml/private/qqmlproperty_p.h>
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
81
82
83
84
85
86
87
88
89
90
91
92
95
96
97
98
99
100
101
102
103
106
107
108QQmlListReference::QQmlListReference()
113#if QT_DEPRECATED_SINCE(6
, 4
)
115
116
117
118
119
120
121
122
123
124
125
126QQmlListReference::QQmlListReference(
const QVariant &variant, [[maybe_unused]] QQmlEngine *engine)
127 : QQmlListReference(variant)
131
132
133
134
135
136
137
138
139
140QQmlListReference::QQmlListReference(QObject *object,
const char *property,
141 [[maybe_unused]] QQmlEngine *engine)
142 : QQmlListReference(object, property)
147
148
149
150
151
152
153
154
155QQmlListReference::QQmlListReference(
const QVariant &variant)
158 const QMetaType t = variant.metaType();
159 if (!(t.flags() & QMetaType::IsQmlList))
162 d =
new QQmlListReferencePrivate;
165 d->property.~QQmlListProperty();
166 t.construct(&d->property, variant.constData());
168 d->object = d->property.object;
172
173
174
175
176
177QQmlListReference::QQmlListReference(QObject *object,
const char *property)
180 if (!object || !property)
return;
182 QQmlPropertyData local;
183 const QQmlPropertyData *data =
184 QQmlPropertyCache::property(object, QLatin1String(property),
nullptr, &local);
186 if (!data || !data->isQList())
return;
188 d =
new QQmlListReferencePrivate;
190 d->propertyType = data->propType();
192 void *args[] = { &d->property,
nullptr };
193 QMetaObject::metacall(object, QMetaObject::ReadProperty, data->coreIndex(), args);
197QQmlListReference::QQmlListReference(
const QQmlListReference &o)
204QQmlListReference &QQmlListReference::operator=(
const QQmlListReference &o)
206 if (o.d) o.d->addref();
213QQmlListReference::~QQmlListReference()
219
220
221bool QQmlListReference::isValid()
const
223 return d && d->object;
227
228
229QObject *QQmlListReference::object()
const
231 if (isValid())
return d->object;
236
237
238
239
240
241
242const QMetaObject *QQmlListReference::listElementType()
const
244 return isValid() ? d->elementType() :
nullptr;
248
249
250
251
252
253bool QQmlListReference::canAppend()
const
255 return (isValid() && d->property.append);
259
260
261
262
263
264bool QQmlListReference::canAt()
const
266 return (isValid() && d->property.at);
270
271
272
273
274
275bool QQmlListReference::canClear()
const
277 return (isValid() && d->property.clear);
281
282
283
284
285
286bool QQmlListReference::canCount()
const
288 return (isValid() && d->property.count);
292
293
294
295
296
297bool QQmlListReference::canReplace()
const
299 return (isValid() && d->property.replace);
303
304
305
306
307
308bool QQmlListReference::canRemoveLast()
const
310 return (isValid() && d->property.removeLast);
314
315
316
317
318
319
320
321
322
323
324bool QQmlListReference::isManipulable()
const
327 && d->property.append
330 && d->property.clear);
335
336
337
338
339bool QQmlListReference::isReadable()
const
341 return (isValid() && d->property.count && d->property.at);
345
346
347
348
349bool QQmlListReference::append(QObject *object)
const
351 if (!canAppend())
return false;
353 if (!isObjectCompatible(object, d))
356 d->property.append(&d->property, object);
362
363
364
365
366QObject *QQmlListReference::at(qsizetype index)
const
368 if (!canAt())
return nullptr;
370 return d->property.at(&d->property, index);
374
375
376
377
378bool QQmlListReference::clear()
const
380 if (!canClear())
return false;
382 d->property.clear(&d->property);
388
389
390qsizetype QQmlListReference::count()
const
392 if (!canCount())
return 0;
394 return d->property.count(&d->property);
398
399
400
401
404
405
406
407
408
409bool QQmlListReference::replace(qsizetype index, QObject *object)
const
414 if (!isObjectCompatible(object, d))
417 d->property.replace(&d->property, index, object);
422
423
424
425
426
427bool QQmlListReference::removeLast()
const
429 if (!canRemoveLast())
432 d->property.removeLast(&d->property);
437
438
439
440
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
480
481
482
483
484
485
486
487
488
489
490
491
492
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
512
513
514
515
516
517
518
519
520
521
522
523
524
527
528
529
532
533
534
535
536
537
538
539
540
541
542
543
544
547
548
549
550
551
552
553
554
555
556
557
558
559
562
563
564
565
566
567
568
569
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
621
622
623
624
625
626
629
630
631
632
633
634
637
638
639
640
643
644
645
646
647
648
651
652
653
654
655
656
659
660
661
662
663
664
667
668
669
670
671
672
675
676
677
678
679
680
683
684
685
686
687
688
689
690
691
692
693
694
695
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)