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
4#ifndef QQMLINSTANTIATOR_P_H
5#define QQMLINSTANTIATOR_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 <QtQml/qqmlcomponent.h>
19#include <QtQml/qqmlparserstatus.h>
20
21#include <private/qqmldelegatemodel_p.h>
22#include <private/qtqmlmodelsglobal_p.h>
23
24QT_REQUIRE_CONFIG(qml_object_model);
25
26QT_BEGIN_NAMESPACE
27
28class QQmlInstantiatorPrivate;
29class Q_QMLMODELS_EXPORT QQmlInstantiator : public QObject, public QQmlParserStatus
30{
31 Q_OBJECT
32 Q_INTERFACES(QQmlParserStatus)
33
34 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
35 Q_PROPERTY(bool asynchronous READ isAsync WRITE setAsync NOTIFY asynchronousChanged)
36 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged)
37 Q_PROPERTY(int count READ count NOTIFY countChanged)
38 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged)
39 Q_PROPERTY(QObject *object READ object NOTIFY objectChanged)
40#if QT_CONFIG(qml_delegate_model)
41 Q_PROPERTY(QQmlDelegateModel::DelegateModelAccess delegateModelAccess READ delegateModelAccess
42 WRITE setDelegateModelAccess NOTIFY delegateModelAccessChanged REVISION(6, 10) FINAL)
43#endif
44 Q_CLASSINFO("DefaultProperty", "delegate")
45 QML_NAMED_ELEMENT(Instantiator)
46 QML_ADDED_IN_VERSION(2, 1)
47
48public:
49 QQmlInstantiator(QObject *parent = nullptr);
50 ~QQmlInstantiator();
51
52 bool isActive() const;
53 void setActive(bool newVal);
54
55 bool isAsync() const;
56 void setAsync(bool newVal);
57
58 int count() const;
59
60 QQmlComponent* delegate();
61 void setDelegate(QQmlComponent* c);
62
63 QVariant model() const;
64 void setModel(const QVariant &v);
65
66#if QT_CONFIG(qml_delegate_model)
67 QQmlDelegateModel::DelegateModelAccess delegateModelAccess() const;
68 void setDelegateModelAccess(QQmlDelegateModel::DelegateModelAccess delegateModelAccess);
69#endif
70
71 QObject *object() const;
72
73 Q_INVOKABLE QObject *objectAt(int index) const;
74
75 void classBegin() override;
76 void componentComplete() override;
77
78Q_SIGNALS:
79 void modelChanged();
80 void delegateChanged();
81 void countChanged();
82 void objectChanged();
83 void activeChanged();
84 void asynchronousChanged();
85
86 void objectAdded(int index, QObject* object);
87 void objectRemoved(int index, QObject* object);
88
89#if QT_CONFIG(qml_delegate_model)
90 Q_REVISION(6, 10) void delegateModelAccessChanged();
91#endif
92
93private:
94 Q_DISABLE_COPY(QQmlInstantiator)
95 Q_DECLARE_PRIVATE(QQmlInstantiator)
96 Q_PRIVATE_SLOT(d_func(), void _q_createdItem(int, QObject *))
97 Q_PRIVATE_SLOT(d_func(), void _q_modelUpdated(const QQmlChangeSet &, bool))
98};
99
100QT_END_NAMESPACE
101
102#endif // QQMLCREATOR_P_H
103

source code of qtdeclarative/src/qmlmodels/qqmlinstantiator_p.h