| 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 QQUICKPACKAGE_H |
| 5 | #define QQUICKPACKAGE_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 <qqml.h> |
| 19 | #include <QtQmlModels/private/qtqmlmodelsglobal_p.h> |
| 20 | |
| 21 | QT_REQUIRE_CONFIG(qml_delegate_model); |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | class QQuickPackagePrivate; |
| 26 | class QQuickPackageAttached; |
| 27 | class Q_QMLMODELS_EXPORT QQuickPackage : public QObject |
| 28 | { |
| 29 | Q_OBJECT |
| 30 | Q_DECLARE_PRIVATE(QQuickPackage) |
| 31 | |
| 32 | Q_CLASSINFO("DefaultProperty", "data") |
| 33 | QML_NAMED_ELEMENT(Package) |
| 34 | QML_ADDED_IN_VERSION(2, 0) |
| 35 | QML_ATTACHED(QQuickPackageAttached) |
| 36 | Q_PROPERTY(QQmlListProperty<QObject> data READ data) |
| 37 | |
| 38 | public: |
| 39 | QQuickPackage(QObject *parent=nullptr); |
| 40 | |
| 41 | QQmlListProperty<QObject> data(); |
| 42 | |
| 43 | QObject *part(const QString & = QString()); |
| 44 | bool hasPart(const QString &); |
| 45 | |
| 46 | static QQuickPackageAttached *qmlAttachedProperties(QObject *); |
| 47 | }; |
| 48 | |
| 49 | class QQuickPackageAttached : public QObject |
| 50 | { |
| 51 | Q_OBJECT |
| 52 | Q_PROPERTY(QString name READ name WRITE setName FINAL) |
| 53 | public: |
| 54 | QQuickPackageAttached(QObject *parent); |
| 55 | virtual ~QQuickPackageAttached(); |
| 56 | |
| 57 | QString name() const; |
| 58 | void setName(const QString &n); |
| 59 | |
| 60 | static QHash<QObject *, QQuickPackageAttached *> attached; |
| 61 | private: |
| 62 | QString _name; |
| 63 | }; |
| 64 | |
| 65 | QT_END_NAMESPACE |
| 66 | |
| 67 | #endif // QQUICKPACKAGE_H |
| 68 |
