1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWAYLANDQUICKCHILDREN_H
5#define QWAYLANDQUICKCHILDREN_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 <QtWaylandCompositor/qtwaylandcompositorglobal.h>
19#if QT_CONFIG(wayland_compositor_quick)
20#include <QtQml/QQmlListProperty>
21#include <QtCore/QList>
22#endif
23
24QT_BEGIN_NAMESPACE
25
26#if QT_CONFIG(wayland_compositor_quick)
27#define Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(className) \
28 Q_PROPERTY(QQmlListProperty<QObject> data READ data DESIGNABLE false) \
29 Q_CLASSINFO("DefaultProperty", "data") \
30 public: \
31 QQmlListProperty<QObject> data() \
32 { \
33 return QQmlListProperty<QObject>(this, this, \
34 &className::appendFunction, \
35 &className::countFunction, \
36 &className::atFunction, \
37 &className::clearFunction); \
38 } \
39 static void appendFunction(QQmlListProperty<QObject> *list, QObject *object) \
40 { \
41 static_cast<className *>(list->data)->m_children.append(object); \
42 } \
43 static qsizetype countFunction(QQmlListProperty<QObject> *list) \
44 { \
45 return static_cast<className *>(list->data)->m_children.size(); \
46 } \
47 static QObject *atFunction(QQmlListProperty<QObject> *list, qsizetype index) \
48 { \
49 return static_cast<className *>(list->data)->m_children.at(index); \
50 } \
51 static void clearFunction(QQmlListProperty<QObject> *list) \
52 { \
53 static_cast<className *>(list->data)->m_children.clear(); \
54 } \
55 private: \
56 QList<QObject *> m_children;
57#else
58#define Q_WAYLAND_COMPOSITOR_DECLARE_QUICK_CHILDREN(className)
59#endif
60
61QT_END_NAMESPACE
62
63#endif // QWAYLANDQUICKCHILDREN_H
64

source code of qtwayland/src/compositor/compositor_api/qwaylandquickchildren.h