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
qqmlinstantiator_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 Research In Motion.
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 QQMLINSTANTIATOR_P_P_H
6#define QQMLINSTANTIATOR_P_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
20#include <QObject>
21#include <private/qobject_p.h>
22#include <private/qqmlchangeset_p.h>
23#include <private/qqmlobjectmodel_p.h>
24
25#include <QtCore/qpointer.h>
26
28
30
31class Q_QMLMODELS_EXPORT QQmlInstantiatorPrivate : public QObjectPrivate
32{
33 Q_DECLARE_PUBLIC(QQmlInstantiator)
34
35public:
36 QQmlInstantiatorPrivate();
37
38 void clear();
39 void regenerate();
40 void _q_createdItem(int, QObject *);
41 void _q_modelUpdated(const QQmlChangeSet &, bool);
42 QObject *modelObject(int index, bool async);
43
44 static QQmlInstantiatorPrivate *get(QQmlInstantiator *instantiator) { return instantiator->d_func(); }
45 static const QQmlInstantiatorPrivate *get(const QQmlInstantiator *instantiator) { return instantiator->d_func(); }
46
47 void connectModel(QQmlInstantiator *q, QQmlDelegateModelPointer *model)
48 {
49 Q_UNUSED(q);
50 QQmlInstanceModel *instanceModel = model->instanceModel();
51 if (!instanceModel)
52 return;
53 QObjectPrivate::connect(instanceModel, &QQmlInstanceModel::modelUpdated,
54 this, &QQmlInstantiatorPrivate::_q_modelUpdated);
55 QObjectPrivate::connect(instanceModel, &QQmlInstanceModel::createdItem,
56 this, &QQmlInstantiatorPrivate::_q_createdItem);
57 if (ownModel) {
58 QObject::connect(model->delegateModel(), &QQmlDelegateModel::modelChanged,
59 q, &QQmlInstantiator::modelChanged);
60 }
61
62 regenerate();
63 }
64
65 void disconnectModel(QQmlInstantiator *q, QQmlDelegateModelPointer *model)
66 {
67 Q_UNUSED(q);
68 QQmlInstanceModel *instanceModel = model->instanceModel();
69 if (!instanceModel)
70 return;
71 QObjectPrivate::disconnect(instanceModel, &QQmlInstanceModel::modelUpdated,
72 this, &QQmlInstantiatorPrivate::_q_modelUpdated);
73 QObjectPrivate::disconnect(instanceModel, &QQmlInstanceModel::createdItem,
74 this, &QQmlInstantiatorPrivate::_q_createdItem);
75 if (ownModel) {
76 QObject::disconnect(model->delegateModel(), &QQmlDelegateModel::modelChanged,
77 q, &QQmlInstantiator::modelChanged);
78 }
79 }
80
81 QPointer<QQmlInstanceModel> model;
82 QVector<QPointer<QObject>> objects;
83 QQmlComponent *delegate = nullptr;
84 int requestedIndex = -1;
85 bool componentComplete:1;
86 bool active:1;
87 bool async:1;
88 bool ownModel:1;
89 QQmlDelegateModel::DelegateModelAccess delegateModelAccess = QQmlDelegateModel::Qt5ReadWrite;
90};
91
92QT_END_NAMESPACE
93
94#endif // QQMLCREATOR_P_P_H
QT_REQUIRE_CONFIG(qml_delegate_model)
QT_REQUIRE_CONFIG(thread)