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
qqmltableinstancemodel_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 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 QQMLTABLEINSTANCEMODEL_P_H
5#define QQMLTABLEINSTANCEMODEL_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 <QtQmlModels/private/qqmldelegatemodel_p.h>
19#include <QtQmlModels/private/qqmldelegatemodel_p_p.h>
20
21#include <QtCore/qpointer.h>
22
23QT_REQUIRE_CONFIG(qml_table_model);
24
26
29
49
50class Q_QMLMODELS_EXPORT QQmlTableInstanceModel : public QQmlInstanceModel
51{
53
54public:
56 ~QQmlTableInstanceModel() override;
57
58 void useImportVersion(QTypeRevision version);
59
60 int count() const override { return m_adaptorModel.count(); }
61 int rows() const { return m_adaptorModel.rowCount(); }
62 int columns() const { return m_adaptorModel.columnCount(); }
63
64 bool isValid() const override { return true; }
65
66 bool canFetchMore() const { return m_adaptorModel.canFetchMore(); }
67 void fetchMore() { m_adaptorModel.fetchMore(); }
68
69 QVariant model() const;
70 void setModel(const QVariant &model);
71
72 QQmlComponent *delegate() const;
73 void setDelegate(QQmlComponent *);
74
75 const QAbstractItemModel *abstractItemModel() const override;
76
78 ReleaseFlags release(QObject *object, ReusableFlag reusable = NotReusable) override;
79 void dispose(QObject *object);
80 void cancel(int) override;
81
82 void drainReusableItemsPool(int maxPoolTime) override;
83 int poolSize() override { return m_reusableItemsPool.size(); }
84 void reuseItem(QQmlDelegateModelItem *item, int newModelIndex);
85
86 QQmlIncubator::Status incubationStatus(int index) override;
87
88 bool setRequiredProperty(int index, const QString &name, const QVariant &value) final;
89
90 QVariant variantValue(int, const QString &) override { Q_UNREACHABLE_RETURN(QVariant()); }
91 void setWatchedRoles(const QList<QByteArray> &) override { Q_UNREACHABLE(); }
92 int indexOf(QObject *, QObject *) const override { Q_UNREACHABLE_RETURN(0); }
93
94private:
95 enum DestructionMode {
96 Deferred,
97 Immediate
98 };
99
100 QQmlComponent *resolveDelegate(int index);
101
102 QQmlAdaptorModel m_adaptorModel;
103 QQmlAbstractDelegateComponent *m_delegateChooser = nullptr;
104 QQmlComponent *m_delegate = nullptr;
105 QPointer<QQmlContext> m_qmlContext;
106 QQmlRefPointer<QQmlDelegateModelItemMetaType> m_metaType;
107
108 QHash<int, QQmlDelegateModelItem *> m_modelItems;
109 QQmlReusableDelegateModelItemsPool m_reusableItemsPool;
110 QList<QQmlIncubator *> m_finishedIncubationTasks;
111
112 void incubateModelItem(QQmlDelegateModelItem *modelItem, QQmlIncubator::IncubationMode incubationMode);
113 void incubatorStatusChanged(QQmlTableInstanceModelIncubationTask *dmIncubationTask, QQmlIncubator::Status status);
114 void deleteIncubationTaskLater(QQmlIncubator *incubationTask);
115 void deleteAllFinishedIncubationTasks();
116 QQmlDelegateModelItem *resolveModelItem(int index);
117 void destroyModelItem(QQmlDelegateModelItem *modelItem, DestructionMode mode);
118
119 void dataChangedCallback(const QModelIndex &begin, const QModelIndex &end, const QVector<int> &roles);
120 void modelAboutToBeResetCallback();
121
122 static bool isDoneIncubating(QQmlDelegateModelItem *modelItem);
123 static void deleteModelItemLater(QQmlDelegateModelItem *modelItem);
124
126};
127
129
130#endif // QQMLTABLEINSTANCEMODEL_P_H
DarwinBluetooth::DeviceInquiryDelegate * m_delegate
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
The QQmlComponent class encapsulates a QML component definition.
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
The QQmlIncubator class allows QML objects to be created asynchronously.
void clear()
Clears the incubator.
IncubationMode
Specifies the mode the incubator operates in.
Status status() const
Return the current status of the incubator.
Status
Specifies the status of the QQmlIncubator.
void statusChanged(Status status) override
Called when the status of the incubator changes.
QQmlTableInstanceModelIncubationTask(QQmlTableInstanceModel *tableInstanceModel, QQmlDelegateModelItem *modelItemToIncubate, IncubationMode mode)
void setInitialState(QObject *object) override
Called after the object is first created, but before complex property bindings are evaluated and,...
int indexOf(QObject *, QObject *) const override
bool isValid() const override
void setWatchedRoles(const QList< QByteArray > &) override
QVariant variantValue(int, const QString &) override
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
\inmodule QtCore
Definition qvariant.h:65
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum mode
GLuint index
[2]
GLuint GLuint end
GLuint object
[3]
GLuint name
QQmlContext * qmlContext(const QObject *obj)
Definition qqml.cpp:75
static bool isDoneIncubating(QQmlIncubator::Status status)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT
view setModel(model)
[17] //! [18]
QSqlQueryModel * model
[16]
future cancel()
QObject::connect nullptr
sem release()
QGraphicsItem * item