5#ifndef QQMLLISTMODEL_P_P_H
6#define QQMLLISTMODEL_P_P_H
20#include <private/qtqmlmodelsglobal_p.h>
21#include <private/qqmlengine_p.h>
22#include <private/qqmlopenmetaobject_p.h>
23#include <private/qv4qobjectwrapper_p.h>
33class DynamicRoleModelNode;
59 void updateValues(
const QVariantMap &object, QList<
int> &roles);
63 return m_meta->value(name.toUtf8());
66 bool setValue(
const QByteArray &name,
const QVariant &val)
68 return m_meta->setValue(name, val);
84 QQmlListModel *m_owner;
94 ModelNodeMetaObject(QObject *object, QQmlListModel *model,
int elementIndex);
97#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
)
100 QMetaObject *toDynamicMetaObject(QObject *object)
override;
120 void emitDirectNotifies(
const int *changedRoles,
int roleCount);
123 mutable bool m_initialized;
131 void init(QObject *object, QQmlListModel *model)
133 QObjectWrapper::init(object);
140 QObjectWrapper::destroy();
144 if (
const QObject *o = object()) {
145 const QObjectPrivate *op = QObjectPrivate::get(o);
228 int currentBlockOffset;
230 QStringHash<Role *> roleHash;
236 bool isSet()
const {
return binding || arrayData; }
240 QString toString(
const QQmlListModel *owner)
const;
250 QTypedArrayData<
char16_t> *arrayData =
nullptr;
255
256
273 int setVariantProperty(
const ListLayout::
Role &role,
const QVariant &d);
275 int setJsProperty(
const ListLayout::
Role &role,
const QV4::Value &d, QV4::ExecutionEngine *eng);
277 int setStringProperty(
const ListLayout::
Role &role,
const QString &s);
281 int setQObjectProperty(
const ListLayout::
Role &role, QV4::QObjectWrapper *o);
282 int setVariantMapProperty(
const ListLayout::
Role &role, QV4::Object *o);
283 int setVariantMapProperty(
const ListLayout::
Role &role, QVariantMap *m);
284 int setDateTimeProperty(
const ListLayout::
Role &role,
const QDateTime &dt);
285 int setUrlProperty(
const ListLayout::
Role &role,
const QUrl &url);
286 int setFunctionProperty(
const ListLayout::
Role &role,
const QJSValue &f);
287 int setTranslationProperty(
const ListLayout::
Role &role,
const QV4::CompiledData::Binding *b);
289 void setStringPropertyFast(
const ListLayout::
Role &role,
const QString &s);
290 void setDoublePropertyFast(
const ListLayout::
Role &role,
double n);
292 void setQObjectPropertyFast(
const ListLayout::
Role &role, QV4::QObjectWrapper *o);
294 void setVariantMapFast(
const ListLayout::
Role &role, QV4::Object *o);
295 void setDateTimePropertyFast(
const ListLayout::
Role &role,
const QDateTime &dt);
296 void setUrlPropertyFast(
const ListLayout::
Role &role,
const QUrl &url);
297 void setFunctionPropertyFast(
const ListLayout::
Role &role,
const QJSValue &f);
301 QVariant getProperty(
const ListLayout::
Role &role,
const QQmlListModel *owner, QV4::ExecutionEngine *eng);
304 QV4::QObjectWrapper *getQObjectProperty(
const ListLayout::
Role &role);
305 QV4::PersistentValue *getGuardProperty(
const ListLayout::
Role &role);
313 int getUid()
const {
return uid; }
321 QObject *m_objectCache;
327
328
333 ListModel(
ListLayout *layout, QQmlListModel *modelCache);
338 int setExistingProperty(
int uid,
const QString &key,
const QV4::Value &data, QV4::ExecutionEngine *eng);
340 QVariant getProperty(
int elementIndex,
int roleIndex,
const QQmlListModel *owner, QV4::ExecutionEngine *eng);
367 return int(elements.size());
372 void set(
int elementIndex, QV4::Object *object, QList<
int> *roles);
375 int append(QV4::Object *object);
376 void insert(
int elementIndex, QV4::Object *object);
383 void move(
int from,
int to,
int n);
387 QObject *getOrCreateModelObject(QQmlListModel *model,
int elementIndex);
390 std::vector<ListElement *> elements;
393 QQmlListModel *m_modelCache;
400 int targetIndex = -1;
401 QList<
int> changedRoles;
404 void newElement(
int index);
406 void updateCacheIndices(
int start = 0,
int end = -1);
408 template<
typename ArrayLike>
411 ListModel *subModel =
new ListModel(r.subLayout,
nullptr);
413 for (qint64 j = 0, arrayLength = a->getLength(); j < arrayLength; ++j) {
415 subModel->append(*o);
421 template<
typename ArrayLike>
422 void setArrayLikeFast(
423 QV4::ScopedObject *o, QV4::String *propertyName,
ListElement *e, ArrayLike *a)
427 e->setListPropertyFast(r, resolveSubModel(o, r, a));
430 template<
typename ArrayLike>
432 QV4::ScopedObject *o, QV4::String *propertyName,
ListElement *e, ArrayLike *a)
435 return e->setListProperty(r, resolveSubModel(o, r, a));
void updateValues(const QVariantMap &object, QList< int > &roles)
static QList< int > sync(DynamicRoleModelNode *src, DynamicRoleModelNode *target)
QVariant getValue(const QString &name) const
bool setValue(const QByteArray &name, const QVariant &val)
void setNodeUpdatesEnabled(bool enable)
static QList< int > sync(ListElement *src, ListLayout *srcLayout, ListElement *target, ListLayout *targetLayout)
ListElement(int existingUid)
ListLayout(const ListLayout *other)
const Role * getRoleOrCreate(const QString &key, const QVariant &data)
const Role * getExistingRole(QV4::String *key) const
static void sync(ListLayout *src, ListLayout *target)
const Role & getExistingRole(int index) const
const Role & getRoleOrCreate(const QString &key, Role::DataType type)
const Role & getRoleOrCreate(QV4::String *key, Role::DataType type)
const Role * getExistingRole(const QString &key) const
void set(int elementIndex, QV4::Object *object, SetElement reason=SetElement::IsCurrentlyUpdated)
static bool sync(ListModel *src, ListModel *target)
int append(QV4::Object *object)
QVariant getProperty(int elementIndex, int roleIndex, const QQmlListModel *owner, QV4::ExecutionEngine *eng)
void move(int from, int to, int n)
const ListLayout::Role * getExistingRole(QV4::String *key) const
void insertElement(int index)
ListModel(ListLayout *layout, QQmlListModel *modelCache)
void insert(int elementIndex, QV4::Object *object)
int setExistingProperty(int uid, const QString &key, const QV4::Value &data, QV4::ExecutionEngine *eng)
void updateTranslations()
QObject * getOrCreateModelObject(QQmlListModel *model, int elementIndex)
ListModel * getListProperty(int elementIndex, const ListLayout::Role &role)
int setOrCreateProperty(int elementIndex, const QString &key, const QVariant &data)
void set(int elementIndex, QV4::Object *object, QList< int > *roles)
const ListLayout::Role & getOrCreateListRole(const QString &name)
const ListLayout::Role & getExistingRole(int index) const
void verifyBindings(const QQmlRefPointer< QV4::CompiledData::CompilationUnit > &compilationUnit, const QList< const QV4::CompiledData::Binding * > &bindings) override
DEFINE_OBJECT_VTABLE(ModelObject)
static QAtomicInt uidCounter(MIN_LISTMODEL_UID)
Q_DECLARE_METATYPE(const QV4::CompiledData::Binding *)
static bool isMemoryUsed(const char *mem)
static QString roleTypeName(ListLayout::Role::DataType t)
QT_END_NAMESPACE Q_DECLARE_METATYPE(ListModel *)
QT_REQUIRE_CONFIG(qml_list_model)
QV4QPointer< QQmlListModel > m_model
PropertyKey next(const Object *o, Property *pd=nullptr, PropertyAttributes *attrs=nullptr) override
~ModelObjectOwnPropertyKeyIterator() override=default
static OwnPropertyKeyIterator * virtualOwnPropertyKeys(const Object *m, Value *target)
static ReturnedValue lookupGetter(Lookup *l, ExecutionEngine *engine, const Value &object)
static ReturnedValue virtualResolveLookupGetter(const Object *object, ExecutionEngine *engine, Lookup *lookup)
static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
const QV4::CompiledData::Binding * binding
bool isTranslation() const
void setString(const QString &s)
QString toString(const QQmlListModel *owner) const
void setTranslation(const QV4::CompiledData::Binding *binding)