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 QQMLINCUBATOR_H |
5 | #define QQMLINCUBATOR_H |
6 | |
7 | #include <QtQml/qtqmlglobal.h> |
8 | #include <QtQml/qqmlerror.h> |
9 | #include <atomic> |
10 | |
11 | QT_BEGIN_NAMESPACE |
12 | |
13 | |
14 | class QQmlEngine; |
15 | class QQmlPropertyData; |
16 | class QVariant; |
17 | |
18 | class QQmlIncubatorPrivate; |
19 | class Q_QML_EXPORT QQmlIncubator |
20 | { |
21 | Q_DISABLE_COPY(QQmlIncubator) |
22 | public: |
23 | enum IncubationMode { |
24 | Asynchronous, |
25 | AsynchronousIfNested, |
26 | Synchronous |
27 | }; |
28 | enum Status { |
29 | Null, |
30 | Ready, |
31 | Loading, |
32 | Error |
33 | }; |
34 | |
35 | QQmlIncubator(IncubationMode = Asynchronous); |
36 | virtual ~QQmlIncubator(); |
37 | |
38 | void clear(); |
39 | void forceCompletion(); |
40 | |
41 | bool isNull() const; |
42 | bool isReady() const; |
43 | bool isError() const; |
44 | bool isLoading() const; |
45 | |
46 | QList<QQmlError> errors() const; |
47 | |
48 | IncubationMode incubationMode() const; |
49 | |
50 | Status status() const; |
51 | |
52 | QObject *object() const; |
53 | |
54 | void setInitialProperties(const QVariantMap &initialProperties); |
55 | |
56 | protected: |
57 | virtual void statusChanged(Status); |
58 | virtual void setInitialState(QObject *); |
59 | |
60 | private: |
61 | friend class QQmlComponent; |
62 | friend class QQmlEnginePrivate; |
63 | friend class QQmlIncubatorPrivate; |
64 | QQmlIncubatorPrivate *d; |
65 | }; |
66 | |
67 | class QQmlEnginePrivate; |
68 | class Q_QML_EXPORT QQmlIncubationController |
69 | { |
70 | Q_DISABLE_COPY(QQmlIncubationController) |
71 | public: |
72 | QQmlIncubationController(); |
73 | virtual ~QQmlIncubationController(); |
74 | |
75 | QQmlEngine *engine() const; |
76 | int incubatingObjectCount() const; |
77 | |
78 | void incubateFor(int msecs); |
79 | void incubateWhile(std::atomic<bool> *flag, int msecs = 0); |
80 | |
81 | protected: |
82 | virtual void incubatingObjectCountChanged(int); |
83 | |
84 | private: |
85 | friend class QQmlEngine; |
86 | friend class QQmlEnginePrivate; |
87 | friend class QQmlIncubatorPrivate; |
88 | QQmlEnginePrivate *d; |
89 | }; |
90 | |
91 | QT_END_NAMESPACE |
92 | |
93 | #endif // QQMLINCUBATOR_H |
94 |