Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqmldelegatemodel_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
4#ifndef QQMLDATAMODEL_P_H
5#define QQMLDATAMODEL_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qtqmlmodelsglobal_p.h>
19#include <private/qqmllistcompositor_p.h>
20#include <private/qqmlobjectmodel_p.h>
21#include <private/qqmlincubator_p.h>
22
23#include <QtCore/qabstractitemmodel.h>
24#include <QtCore/qstringlist.h>
25
26QT_REQUIRE_CONFIG(qml_delegate_model);
27
29
30class QQmlChangeSet;
31class QQuickPackage;
32class QQmlV4Function;
36
37
38class Q_QMLMODELS_PRIVATE_EXPORT QQmlDelegateModel : public QQmlInstanceModel, public QQmlParserStatus
39{
41 Q_DECLARE_PRIVATE(QQmlDelegateModel)
42
43 Q_PROPERTY(QVariant model READ model WRITE setModel FINAL)
44 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
45 Q_PROPERTY(QString filterOnGroup READ filterGroup WRITE setFilterGroup NOTIFY filterGroupChanged RESET resetFilterGroup FINAL)
46 Q_PROPERTY(QQmlDelegateModelGroup *items READ items CONSTANT FINAL) //TODO : worth renaming?
47 Q_PROPERTY(QQmlDelegateModelGroup *persistedItems READ persistedItems CONSTANT FINAL)
49 Q_PROPERTY(QObject *parts READ parts CONSTANT FINAL)
50 Q_PROPERTY(QVariant rootIndex READ rootIndex WRITE setRootIndex NOTIFY rootIndexChanged FINAL)
51 Q_CLASSINFO("DefaultProperty", "delegate")
52 QML_NAMED_ELEMENT(DelegateModel)
56
57public:
61
62 void classBegin() override;
63 void componentComplete() override;
64
65 QVariant model() const;
66 void setModel(const QVariant &);
67
68 QQmlComponent *delegate() const;
69 void setDelegate(QQmlComponent *);
70
71 QVariant rootIndex() const;
72 void setRootIndex(const QVariant &root);
73
74 Q_INVOKABLE QVariant modelIndex(int idx) const;
75 Q_INVOKABLE QVariant parentModelIndex() const;
76
77 int count() const override;
78 bool isValid() const override { return delegate() != nullptr; }
80 ReleaseFlags release(QObject *object, ReusableFlag reusableFlag = NotReusable) override;
81 void cancel(int index) override;
82 QVariant variantValue(int index, const QString &role) override;
83 void setWatchedRoles(const QList<QByteArray> &roles) override;
85
86 void drainReusableItemsPool(int maxPoolTime) override;
87 int poolSize() override;
88
89 int indexOf(QObject *object, QObject *objectContext) const override;
90
91 QString filterGroup() const;
92 void setFilterGroup(const QString &group);
93 void resetFilterGroup();
94
99
100 const QAbstractItemModel *abstractItemModel() const override;
101
102 bool event(QEvent *) override;
103
104 static QQmlDelegateModelAttached *qmlAttachedProperties(QObject *obj);
105
111
112private Q_SLOTS:
113 void _q_itemsChanged(int index, int count, const QVector<int> &roles);
114 void _q_itemsInserted(int index, int count);
115 void _q_itemsRemoved(int index, int count);
116 void _q_itemsMoved(int from, int to, int count);
117 void _q_modelAboutToBeReset();
118 void _q_rowsInserted(const QModelIndex &,int,int);
119 void _q_columnsInserted(const QModelIndex &, int, int);
120 void _q_columnsRemoved(const QModelIndex &, int, int);
121 void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
122 void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
123 void _q_rowsRemoved(const QModelIndex &,int,int);
124 void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
125 void _q_dataChanged(const QModelIndex&,const QModelIndex&,const QVector<int> &);
127
128private:
129 void handleModelReset();
130 bool isDescendantOf(const QPersistentModelIndex &desc, const QList<QPersistentModelIndex> &parents) const;
131
132 Q_DISABLE_COPY(QQmlDelegateModel)
133};
134
136class Q_QMLMODELS_PRIVATE_EXPORT QQmlDelegateModelGroup : public QObject
137{
139 Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
140 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged FINAL)
141 Q_PROPERTY(bool includeByDefault READ defaultInclude WRITE setDefaultInclude NOTIFY defaultIncludeChanged FINAL)
142 QML_NAMED_ELEMENT(DelegateModelGroup)
144public:
146 QQmlDelegateModelGroup(const QString &name, QQmlDelegateModel *model, int compositorType, QObject *parent = nullptr);
148
149 QString name() const;
150 void setName(const QString &name);
151
152 int count() const;
153
154 bool defaultInclude() const;
155 void setDefaultInclude(bool include);
156
158
159public Q_SLOTS:
160 void insert(QQmlV4Function *);
161 void create(QQmlV4Function *);
162 void resolve(QQmlV4Function *);
163 void remove(QQmlV4Function *);
164 void addGroups(QQmlV4Function *);
165 void removeGroups(QQmlV4Function *);
166 void setGroups(QQmlV4Function *);
167 void move(QQmlV4Function *);
168
173 void changed(const QJSValue &removed, const QJSValue &inserted);
174private:
175 Q_DECLARE_PRIVATE(QQmlDelegateModelGroup)
176};
177
181{
183 Q_PROPERTY(QQmlDelegateModel *model READ model CONSTANT FINAL)
187 Q_PROPERTY(bool inItems READ inItems WRITE setInItems NOTIFY groupsChanged FINAL)
189 Q_PROPERTY(int itemsIndex READ itemsIndex NOTIFY groupsChanged FINAL)
190
191public:
195
196 void resetCurrentIndex();
198
199 void setInPersistedItems(bool inPersisted);
200 bool inPersistedItems() const;
201 int persistedItemsIndex() const;
202
203 void setInItems(bool inItems);
204 bool inItems() const;
205 int itemsIndex() const;
206
207 QQmlDelegateModel *model() const;
208
209 QStringList groups() const;
210 void setGroups(const QStringList &groups);
211
212 bool isUnresolved() const;
213
214 void emitChanges();
215
217
221
222private:
223 void setInGroup(QQmlListCompositor::Group group, bool inGroup);
224
225public:
230
232};
233
235
238
239#endif // QQMLDATAMODEL_P_H
LayoutChangeHint
This enum describes the way the model changes layout.
\inmodule QtCore
Definition qcoreevent.h:45
The QJSValue class acts as a container for Qt/JavaScript data types.
Definition qjsvalue.h:31
Definition qlist.h:74
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:90
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
The QQmlChangeSet class stores an ordered list of notifications about changes to a linear data set.
The QQmlComponent class encapsulates a QML component definition.
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
void setCacheItem(QQmlDelegateModelItem *item)
void setGroups(const QStringList &groups)
void emitChanges()
\qmlattachedproperty bool QtQml.Models::DelegateModel::inItems
int m_previousIndex[QQmlListCompositor::MaximumGroupCount]
int m_currentIndex[QQmlListCompositor::MaximumGroupCount]
void setInPersistedItems(bool inPersisted)
QQmlDelegateModelItem * m_cacheItem
void changed(const QJSValue &removed, const QJSValue &inserted)
void filterGroupChanged()
bool isValid() const override
QQmlDelegateModelGroup * items()
QObject * parts()
QQmlDelegateModelGroup * persistedItems()
QQmlListProperty< QQmlDelegateModelGroup > groups()
void defaultGroupsChanged()
IncubationMode
Specifies the mode the incubator operates in.
Status
Specifies the status of the QQmlIncubator.
virtual void setWatchedRoles(const QList< QByteArray > &roles)=0
virtual int poolSize()
virtual const QAbstractItemModel * abstractItemModel() const
virtual QQmlIncubator::Status incubationStatus(int index)=0
virtual int indexOf(QObject *object, QObject *objectContext) const =0
virtual void drainReusableItemsPool(int maxPoolTime)
virtual QVariant variantValue(int, const QString &)=0
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
Definition qqmllist.h:24
The QQmlParserStatus class provides updates on the QML parser state.
virtual void classBegin()=0
Invoked after class creation, but before any properties have been set.
virtual void componentComplete()=0
Invoked after the root component that caused this instantiation has completed construction.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qvariant.h:64
employee setName("Richard Schmit")
cache insert(employee->id(), employee)
Combined button and popup list for selecting options.
static QDBusError::ErrorType get(const char *name)
GLsizei GLuint * groups
GLuint index
[2]
GLuint GLuint end
GLenum GLenum GLsizei count
GLboolean GLuint group
GLuint name
struct _cl_event * event
GLhandleARB obj
[2]
#define QML_DECLARE_TYPE(TYPE)
Definition qqml.h:19
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define QML_ATTACHED(ATTACHED_TYPE)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
#define QT_REQUIRE_CONFIG(feature)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_CLASSINFO(name, value)
#define Q_EMIT
#define Q_INVOKABLE
#define Q_INTERFACES(x)
#define Q_SLOTS
#define Q_SIGNALS
@ desc
view setModel(model)
[17] //! [18]
QSqlQueryModel * model
[16]
future cancel()
settings remove("monkey")
sem release()
QGraphicsItem * item
QList< QTreeWidgetItem * > items
view create()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent