Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmllistmodelworkeragent_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant
4
5#ifndef QQUICKLISTMODELWORKERAGENT_P_H
6#define QQUICKLISTMODELWORKERAGENT_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <qtqmlmodelsglobal_p.h>
20
21#include <QEvent>
22#include <QMutex>
23#include <QWaitCondition>
24#include <QtQml/qqml.h>
25
26#include <private/qv4engine_p.h>
27
29
30QT_BEGIN_NAMESPACE
31
32
33class QQmlListModel;
34
36{
37 Q_OBJECT
38 Q_PROPERTY(int count READ count FINAL)
42
43public:
46
47 QV4::ExecutionEngine *engine() const;
48 void setEngine(QV4::ExecutionEngine *eng);
49
50 Q_INVOKABLE void addref();
51 Q_INVOKABLE void release();
52
53 int count() const;
54
55 Q_INVOKABLE void clear();
56 Q_INVOKABLE void remove(QQmlV4FunctionPtr args);
57 Q_INVOKABLE void append(QQmlV4FunctionPtr args);
58 Q_INVOKABLE void insert(QQmlV4FunctionPtr args);
59 Q_INVOKABLE QJSValue get(int index) const;
60 Q_INVOKABLE void set(int index, const QJSValue &value);
61 Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value);
62 Q_INVOKABLE void move(int from, int to, int count);
63 Q_INVOKABLE void sync();
64
65 void modelDestroyed();
66
69
70protected:
71 bool event(QEvent *) override;
72
73private:
75 friend class QQmlListModel;
76
77 struct Sync : public QEvent {
78 Sync(QQmlListModel *l)
79 : QEvent(QEvent::User)
80 , list(l)
81 {}
82 ~Sync();
83 QQmlListModel *list;
84 };
85
86 QAtomicInt m_ref;
87 QQmlListModel *m_orig;
88 QQmlListModel *m_copy;
89 QMutex mutex;
90 QWaitCondition syncDone;
91};
92
93QT_END_NAMESPACE
94
95#endif // QQUICKLISTMODELWORKERAGENT_P_H
DynamicRoleModelNodeMetaObject(DynamicRoleModelNode *object)
void propertyWritten(int index) override
void propertyWrite(int index) override
static QVector< int > sync(DynamicRoleModelNode *src, DynamicRoleModelNode *target)
QVariant getValue(const QString &name) const
bool setValue(const QByteArray &name, const QVariant &val)
void setNodeUpdatesEnabled(bool enable)
void updateValues(const QVariantMap &object, QVector< int > &roles)
static QVector< int > sync(ListElement *src, ListLayout *srcLayout, ListElement *target, ListLayout *targetLayout)
ListElement(int existingUid)
Role(const Role *other)
ListLayout(const ListLayout *other)
int roleCount() const
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)
int elementCount() const
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)
int appendElement()
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)
void set(int elementIndex, QV4::Object *object, QVector< int > *roles)
ListModel * getListProperty(int elementIndex, const ListLayout::Role &role)
int roleCount() const
int setOrCreateProperty(int elementIndex, const QString &key, const QVariant &data)
const ListLayout::Role & getOrCreateListRole(const QString &name)
const ListLayout::Role & getExistingRole(int index) const
QQmlListModel * m_model
void propertyWritten(int index) override
static ModelNodeMetaObject * get(QObject *obj)
ModelNodeMetaObject(QObject *object, QQmlListModel *model, int elementIndex)
void updateValues(const QVector< int > &roles)
\inmodule QtCore
Definition qobject.h:105
void verifyBindings(const QQmlRefPointer< QV4::CompiledData::CompilationUnit > &compilationUnit, const QList< const QV4::CompiledData::Binding * > &bindings) override
void applyBindings(QObject *obj, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit, const QList< const QV4::CompiledData::Binding * > &bindings) override
bool event(QEvent *) override
This virtual function receives events to an object and should return true if the event e was recogniz...
Q_INVOKABLE void move(int from, int to, int count)
Q_INVOKABLE void remove(QQmlV4FunctionPtr args)
Q_INVOKABLE void insert(QQmlV4FunctionPtr args)
Q_INVOKABLE void setProperty(int index, const QString &property, const QVariant &value)
Q_INVOKABLE void append(QQmlV4FunctionPtr args)
void setEngine(QV4::ExecutionEngine *eng)
QV4::ExecutionEngine * engine() const
Definition qjsvalue.h:23
DEFINE_OBJECT_VTABLE(ModelObject)
QT_REQUIRE_CONFIG(animation)
QQmlCustomParser * qmlCreateCustomParser< QQmlConnections >()
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
void setString(const QString &s)
QString toString(const QQmlListModel *owner) const
QString asString() const
void setTranslation(const QV4::CompiledData::Binding *binding)