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#include <QtQmlModels/private/qtqmlmodelsglobal_p.h>
21
22QT_REQUIRE_CONFIG(qml_object_model);
23
24QT_BEGIN_NAMESPACE
25
26class QQmlInstantiatorPrivate;
27class Q_QMLMODELS_PRIVATE_EXPORT QQmlInstantiator : public QObject, public QQmlParserStatus
28{
29 Q_OBJECT
30 Q_INTERFACES(QQmlParserStatus)
31
32 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged FINAL)
33 Q_PROPERTY(bool asynchronous READ isAsync WRITE setAsync NOTIFY asynchronousChanged FINAL)
34 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged FINAL)
35 Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
36 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
37 Q_PROPERTY(QObject *object READ object NOTIFY objectChanged FINAL)
38 Q_CLASSINFO("DefaultProperty", "delegate")
39 QML_NAMED_ELEMENT(Instantiator)
40 QML_ADDED_IN_VERSION(2, 1)
41
42public:
43 QQmlInstantiator(QObject *parent = nullptr);
44 ~QQmlInstantiator();
45
46 bool isActive() const;
47 void setActive(bool newVal);
48
49 bool isAsync() const;
50 void setAsync(bool newVal);
51
52 int count() const;
53
54 QQmlComponent* delegate();
55 void setDelegate(QQmlComponent* c);
56
57 QVariant model() const;
58 void setModel(const QVariant &v);
59
60 QObject *object() const;
61
62 Q_INVOKABLE QObject *objectAt(int index) const;
63
64 void classBegin() override;
65 void componentComplete() override;
66
67Q_SIGNALS:
68 void modelChanged();
69 void delegateChanged();
70 void countChanged();
71 void objectChanged();
72 void activeChanged();
73 void asynchronousChanged();
74
75 void objectAdded(int index, QObject* object);
76 void objectRemoved(int index, QObject* object);
77
78private:
79 Q_DISABLE_COPY(QQmlInstantiator)
80 Q_DECLARE_PRIVATE(QQmlInstantiator)
81 Q_PRIVATE_SLOT(d_func(), void _q_createdItem(int, QObject *))
82 Q_PRIVATE_SLOT(d_func(), void _q_modelUpdated(const QQmlChangeSet &, bool))
83};
84
85QT_END_NAMESPACE
86
87#endif // QQMLCREATOR_P_H
88

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