26 using value_type = T*;
50 replace((a && c && t && r) ? qslow_replace :
nullptr),
51 removeLast((a && c && t && r) ? qslow_removeLast :
nullptr)
55 ClearFunction r, ReplaceFunction s, RemoveLastFunction p)
61 clear((!r && p && c) ? qslow_clear : r),
62 replace((!s && a && c && t && (r || p)) ? qslow_replace : s),
63 removeLast((!p && a && c && t && r) ? qslow_removeLast : p)
71 return object == o.object &&
77 replace == o.replace &&
78 removeLast == o.removeLast;
86 AtFunction
at =
nullptr;
91 template<
typename List>
94 if constexpr (std::is_same_v<List, QList<T *>>) {
95 if (
append == qlist_append)
96 return *
static_cast<QList<T *> *>(
data);
99 const qsizetype size = count(
this);
102 if constexpr (QContainerInfo::has_reserve_v<List>)
103 result.reserve(size);
105 static_assert(QContainerInfo::has_push_back_v<List>);
106 for (qsizetype i = 0; i < size; ++i)
107 result.push_back(
at(this, i
));
114 static_cast<QList<T *> *>(p->data)->append(v);
117 return static_cast<QList<T *> *>(p->data)->size();
120 return static_cast<QList<T *> *>(p->data)->at(idx);
123 return static_cast<QList<T *> *>(p->data)->clear();
126 return static_cast<QList<T *> *>(p->data)->replace(idx, v);
129 return static_cast<QList<T *> *>(p->data)->removeLast();
134 const qsizetype length = list->count(list);
135 if (idx < 0 || idx >= length)
139 if (list->clear != qslow_clear) {
140 stash.reserve(length);
141 for (qsizetype i = 0; i < length; ++i)
142 stash.append(i == idx ? v : list->at(list, i));
144 for (T *item : std::as_const(stash))
145 list->append(list, item);
147 stash.reserve(length - idx - 1);
148 for (qsizetype i = length - 1; i > idx; --i) {
149 stash.append(list->at(list, i));
150 list->removeLast(list);
152 list->removeLast(list);
153 list->append(list, v);
154 while (!stash.isEmpty())
155 list->append(list, stash.takeLast());
161 for (qsizetype i = 0, end = list->count(list); i < end; ++i)
162 list->removeLast(list);
167 const qsizetype length = list->count(list) - 1;
171 stash.reserve(length);
172 for (qsizetype i = 0; i < length; ++i)
173 stash.append(list->at(list, i));
175 for (T *item : std::as_const(stash))
176 list->append(list, item);
187#if QT_DEPRECATED_SINCE(6
, 4
)
188 QT_DEPRECATED_X(
"Drop the QQmlEngine* argument")
189 QQmlListReference(
const QVariant &variant, [[maybe_unused]] QQmlEngine *engine);
191 QT_DEPRECATED_X(
"Drop the QQmlEngine* argument")
192 QQmlListReference(QObject *o,
const char *property, [[maybe_unused]] QQmlEngine *engine);
195 explicit QQmlListReference(
const QVariant &variant);
196 QQmlListReference(QObject *o,
const char *property);
197 QQmlListReference(
const QQmlListReference &);
198 QQmlListReference &operator=(
const QQmlListReference &);
199 ~QQmlListReference();
201 bool isValid()
const;
203 QObject *object()
const;
204 const QMetaObject *listElementType()
const;
206 bool canAppend()
const;
208 bool canClear()
const;
209 bool canCount()
const;
210 bool canReplace()
const;
211 bool canRemoveLast()
const;
213 bool isManipulable()
const;
214 bool isReadable()
const;
216 bool append(QObject *)
const;
217 QObject *at(qsizetype)
const;
219 qsizetype count()
const;
220 qsizetype size()
const {
return count(); }
221 bool replace(qsizetype, QObject *)
const;
222 bool removeLast()
const;
223 bool operator==(
const QQmlListReference &other)
const {
return d == other.d;}
226 friend class QQmlListReferencePrivate;
227 QQmlListReferencePrivate* d;
QQmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c, AtFunction t, ClearFunction r)
Construct a QQmlListProperty from a set of operation functions append, count, at, and clear.
QQmlListProperty(QObject *o, void *d, CountFunction c, AtFunction a)
Construct a readonly QQmlListProperty from a set of operation functions count and at.
QQmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c, AtFunction t, ClearFunction r, ReplaceFunction s, RemoveLastFunction p)
Construct a QQmlListProperty from a set of operation functions append, count, at, clear,...