// Copyright (C) 2021 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause #ifndef BIRTHDAYPARTY_H #define BIRTHDAYPARTY_H #include #include #include #include "person.h" // ![0] class BirthdayParty : public QObject { Q_OBJECT // ![0] // ![1] Q_PROPERTY(Person *host READ host WRITE setHost) // ![1] // ![2] Q_PROPERTY(QQmlListProperty guests READ guests) // ![2] // ![3] QML_ELEMENT public: using QObject::QObject; Person *host() const; void setHost(Person *); QQmlListProperty guests(); void appendGuest(Person *); qsizetype guestCount() const; Person *guest(qsizetype) const; void clearGuests(); void replaceGuest(qsizetype, Person *); void removeLastGuest(); private: static void appendGuest(QQmlListProperty *, Person *); static qsizetype guestCount(QQmlListProperty *); static Person* guest(QQmlListProperty *, qsizetype); static void clearGuests(QQmlListProperty *); static void replaceGuest(QQmlListProperty *, qsizetype, Person *); static void removeLastGuest(QQmlListProperty *); Person *m_host = nullptr; QList m_guests; }; // ![3] #endif // BIRTHDAYPARTY_H