Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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;
35
36
37class Q_QMLMODELS_EXPORT QQmlDelegateModel : public QQmlInstanceModel, public QQmlParserStatus
38{
40 Q_DECLARE_PRIVATE(QQmlDelegateModel)
41
43 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
44 Q_PROPERTY(QString filterOnGroup READ filterGroup WRITE setFilterGroup NOTIFY filterGroupChanged RESET resetFilterGroup)
45 Q_PROPERTY(QQmlDelegateModelGroup *items READ items CONSTANT) //TODO : worth renaming?
46 Q_PROPERTY(QQmlDelegateModelGroup *persistedItems READ persistedItems CONSTANT)
48 Q_PROPERTY(QObject *parts READ parts CONSTANT)
49 Q_PROPERTY(QVariant rootIndex READ rootIndex WRITE setRootIndex NOTIFY rootIndexChanged)
50 Q_CLASSINFO("DefaultProperty", "delegate")
51 QML_NAMED_ELEMENT(DelegateModel)
55
56public:
58 QQmlDelegateModel(QQmlContext *, QObject *parent=nullptr);
60
61 void classBegin() override;
62 void componentComplete() override;
63
64 QVariant model() const;
65 void setModel(const QVariant &);
66
67 QQmlComponent *delegate() const;
68 void setDelegate(QQmlComponent *);
69
70 QVariant rootIndex() const;
71 void setRootIndex(const QVariant &root);
72
73 Q_INVOKABLE QVariant modelIndex(int idx) const;
74 Q_INVOKABLE QVariant parentModelIndex() const;
75
76 int count() const override;
77 bool isValid() const override { return delegate() != nullptr; }
79 ReleaseFlags release(QObject *object, ReusableFlag reusableFlag = NotReusable) override;
80 void cancel(int index) override;
81 QVariant variantValue(int index, const QString &role) override;
82 void setWatchedRoles(const QList<QByteArray> &roles) override;
83 QQmlIncubator::Status incubationStatus(int index) override;
84
85 void drainReusableItemsPool(int maxPoolTime) override;
86 int poolSize() override;
87
88 int indexOf(QObject *object, QObject *objectContext) const override;
89
90 QString filterGroup() const;
91 void setFilterGroup(const QString &group);
92 void resetFilterGroup();
93
96 QQmlListProperty<QQmlDelegateModelGroup> groups();
98
99 const QAbstractItemModel *abstractItemModel() const override;
100
101 bool event(QEvent *) override;
102
103 static QQmlDelegateModelAttached *qmlAttachedProperties(QObject *obj);
104
110
111private Q_SLOTS:
112 void _q_itemsChanged(int index, int count, const QVector<int> &roles);
113 void _q_itemsInserted(int index, int count);
114 void _q_itemsRemoved(int index, int count);
115 void _q_itemsMoved(int from, int to, int count);
116 void _q_modelAboutToBeReset();
117 void _q_rowsInserted(const QModelIndex &,int,int);
118 void _q_columnsInserted(const QModelIndex &, int, int);
119 void _q_columnsRemoved(const QModelIndex &, int, int);
120 void _q_columnsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
121 void _q_rowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end);
122 void _q_rowsRemoved(const QModelIndex &,int,int);
123 void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int);
124 void _q_dataChanged(const QModelIndex&,const QModelIndex&,const QVector<int> &);
125 void _q_layoutChanged(const QList<QPersistentModelIndex>&, QAbstractItemModel::LayoutChangeHint);
126
127private:
128 void handleModelReset();
129 bool isDescendantOf(const QPersistentModelIndex &desc, const QList<QPersistentModelIndex> &parents) const;
130
131 Q_DISABLE_COPY(QQmlDelegateModel)
132};
133
135class Q_QMLMODELS_EXPORT QQmlDelegateModelGroup : public QObject
136{
138 Q_PROPERTY(int count READ count NOTIFY countChanged)
139 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
140 Q_PROPERTY(bool includeByDefault READ defaultInclude WRITE setDefaultInclude NOTIFY defaultIncludeChanged)
141 QML_NAMED_ELEMENT(DelegateModelGroup)
143public:
144 QQmlDelegateModelGroup(QObject *parent = nullptr);
145 QQmlDelegateModelGroup(const QString &name, QQmlDelegateModel *model, int compositorType, QObject *parent = nullptr);
147
148 QString name() const;
149 void setName(const QString &name);
150
151 int count() const;
152
153 bool defaultInclude() const;
154 void setDefaultInclude(bool include);
155
157
158public Q_SLOTS:
163 void addGroups(QQmlV4FunctionPtr);
164 void removeGroups(QQmlV4FunctionPtr);
165 void setGroups(QQmlV4FunctionPtr);
166 void move(QQmlV4FunctionPtr);
167
169 void countChanged();
170 void nameChanged();
171 void defaultIncludeChanged();
172 void changed(const QJSValue &removed, const QJSValue &inserted);
173private:
174 Q_DECLARE_PRIVATE(QQmlDelegateModelGroup)
175};
176
180{
183 Q_PROPERTY(QStringList groups READ groups WRITE setGroups NOTIFY groupsChanged FINAL)
184 Q_PROPERTY(bool isUnresolved READ isUnresolved NOTIFY unresolvedChanged FINAL)
185 Q_PROPERTY(bool inPersistedItems READ inPersistedItems WRITE setInPersistedItems NOTIFY groupsChanged FINAL)
186 Q_PROPERTY(bool inItems READ inItems WRITE setInItems NOTIFY groupsChanged FINAL)
187 Q_PROPERTY(int persistedItemsIndex READ persistedItemsIndex NOTIFY groupsChanged FINAL)
188 Q_PROPERTY(int itemsIndex READ itemsIndex NOTIFY groupsChanged FINAL)
189
190public:
194
195 void resetCurrentIndex();
197
198 void setInPersistedItems(bool inPersisted);
199 bool inPersistedItems() const;
200 int persistedItemsIndex() const;
201
202 void setInItems(bool inItems);
203 bool inItems() const;
204 int itemsIndex() const;
205
206 QQmlDelegateModel *model() const;
207
208 QStringList groups() const;
209 void setGroups(const QStringList &groups);
210
211 bool isUnresolved() const;
212
213 void emitChanges();
214
215 void emitUnresolvedChanged() { Q_EMIT unresolvedChanged(); }
216
220
221private:
222 void setInGroup(QQmlListCompositor::Group group, bool inGroup);
223
224public:
229
231};
232
234
235#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
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
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)
QQmlDelegateModelItem * m_cacheItem
void filterGroupChanged()
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.
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.
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qvariant.h:65
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
GLuint object
[3]
GLboolean GLuint group
GLuint name
struct _cl_event * event
GLhandleARB obj
[2]
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define QML_ATTACHED(ATTACHED_TYPE)
static const QQmlJSScope * resolve(const QQmlJSScope *current, const QStringList &names)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
static constexpr size_t poolSize
Definition qstdweb.cpp:112
#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
view setModel(model)
[17] //! [18]
QSqlQueryModel * model
[16]
future cancel()
settings remove("monkey")
sem release()
list indexOf("B")
QGraphicsItem * item
QList< QTreeWidgetItem * > items
view create()