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 QQUICKLOADER_P_P_H
5#define QQUICKLOADER_P_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 "qquickloader_p.h"
19#include "qquickimplicitsizeitem_p_p.h"
20#include "qquickitemchangelistener_p.h"
21#include <qqmlincubator.h>
22
23#include <private/qv4staticvalue_p.h>
24#include <private/qv4persistent_p.h>
25
26QT_BEGIN_NAMESPACE
27
28
29class QQuickLoaderPrivate;
30class QQmlV4Function;
31class QQuickLoaderIncubator : public QQmlIncubator
32{
33public:
34 QQuickLoaderIncubator(QQuickLoaderPrivate *l, IncubationMode mode) : QQmlIncubator(mode), loader(l) {}
35
36protected:
37 void statusChanged(Status) override;
38 void setInitialState(QObject *) override;
39
40private:
41 QQuickLoaderPrivate *loader;
42};
43
44class QQmlContext;
45class QQuickLoaderPrivate : public QQuickImplicitSizeItemPrivate, public QQuickItemChangeListener
46{
47 Q_DECLARE_PUBLIC(QQuickLoader)
48
49public:
50 QQuickLoaderPrivate();
51 ~QQuickLoaderPrivate();
52
53 void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &oldGeometry) override;
54 void itemImplicitWidthChanged(QQuickItem *) override;
55 void itemImplicitHeightChanged(QQuickItem *) override;
56 void clear();
57 void initResize();
58 void load();
59
60 void incubatorStateChanged(QQmlIncubator::Status status);
61 void setInitialState(QObject *o);
62 void disposeInitialPropertyValues();
63 QQuickLoader::Status computeStatus() const;
64 void updateStatus();
65 void createComponent();
66
67 qreal getImplicitWidth() const override;
68 qreal getImplicitHeight() const override;
69
70 QUrl source;
71 QQuickItem *item;
72 QObject *object;
73 QQmlStrongJSQObjectReference<QQmlComponent> component;
74 QQmlContext *itemContext;
75 QQuickLoaderIncubator *incubator;
76 QV4::PersistentValue initialPropertyValues;
77 QV4::PersistentValue qmlCallingContext;
78 bool updatingSize: 1;
79 bool active : 1;
80 bool loadingFromSource : 1;
81 bool asynchronous : 1;
82 // We need to use char instead of QQuickLoader::Status
83 // as otherwise the size of the class would increase
84 // on 32-bit systems, as sizeof(Status) == sizeof(int)
85 // and sizeof(int) > remaining padding on 32 bit
86 char status;
87
88 void _q_sourceLoaded();
89 void _q_updateSize(bool loaderGeometryChanged = true);
90};
91
92QT_END_NAMESPACE
93
94#endif // QQUICKLOADER_P_P_H
95

source code of qtdeclarative/src/quick/items/qquickloader_p_p.h