5#include <QtQml/QQmlEngine>
6#include <QtQml/QQmlIncubator>
7#include <QtQuick/QQuickItem>
13class PoolIncubator :
public QQmlIncubator {
15 PoolIncubator(Pool* p, qint64
id, IncubationMode mode);
18 void statusChanged(Status)
override;
19 void setInitialState(QObject*)
override;
26class Pool :
public QObject {
30 Q_PROPERTY(
bool async READ async WRITE setAsync NOTIFY asyncChanged FINAL)
32 friend class PoolIncubator;
35 Pool(QObject* parent =
nullptr);
38 Q_INVOKABLE
void add(QQmlComponent* comp,
const QVariantMap&,
bool cache);
39 Q_INVOKABLE
void add(
const QUrl& url,
const QVariantMap&,
bool cache);
40 Q_INVOKABLE
void addFromModule(
const QString& uri,
const QString& typeName,
const QVariantMap&,
43 Q_INVOKABLE
void addWithKey(
const QString& key, QQmlComponent* comp,
const QVariantMap&,
45 Q_INVOKABLE
void addWithKey(
const QString& key,
const QUrl& url,
const QVariantMap&,
47 Q_INVOKABLE
void addFromModuleWithKey(
const QString& key,
const QString& uri,
48 const QString& typeName,
const QVariantMap&,
bool cache);
50 Q_SIGNAL
void objectAdded(QObject* obj,
bool is_cache);
52 auto async() const ->
bool;
54 Q_SIGNAL
void asyncChanged(
bool);
56 Q_INVOKABLE
bool removeObject(QObject*);
59 Q_SIGNAL
void queueAdded(qint64);
60 Q_SLOT
void onQueueAdded(qint64);
61 Q_SLOT
void onUncacheObjectDeleted(QObject*);
68 QPointer<QQmlComponent> component {};
69 PoolIncubator* incubator {
nullptr };
72 void incubatorStateChanged(qint64
id, QQmlIncubator::Status status);
73 void setInitialState(QObject* o);
74 auto genSerial() const -> qint64;
75 void onComponentProgress(qint64
id, qreal);
76 void onComponentLoaded(qint64
id);
77 auto createComponent() -> QQmlComponent*;
78 auto tryCache(QStringView,
bool) ->
bool;
80 using task_iterator = std::map<qint64, Task>::iterator;
81 void clearTask(task_iterator);
83 mutable qint64 m_serial;
84 std::map<qint64, Task> m_tasks;
85 std::map<QString, QPointer<QObject>, std::less<>> m_objs;
86 std::set<QObject*> m_uncache_objs;