2023-03-17 14:42:47 +00:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
2022-05-13 13:12:05 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2021-11-02 08:04:21 +00:00
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#ifndef BIRTHDAYPARTY_H
|
|
|
|
#define BIRTHDAYPARTY_H
|
|
|
|
|
2023-03-17 14:42:47 +00:00
|
|
|
#include "person.h"
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
#include <QObject>
|
2012-02-16 04:43:03 +00:00
|
|
|
#include <QQmlListProperty>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
class BirthdayParty : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2023-03-17 14:42:47 +00:00
|
|
|
Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged FINAL)
|
|
|
|
Q_PROPERTY(QQmlListProperty<Person> guests READ guests NOTIFY guestsChanged FINAL)
|
|
|
|
Q_CLASSINFO("DefaultProperty", "guests")
|
2019-09-12 15:03:52 +00:00
|
|
|
QML_ELEMENT
|
2011-04-27 10:05:43 +00:00
|
|
|
public:
|
2021-11-02 08:04:21 +00:00
|
|
|
using QObject::QObject;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
Person *host() const;
|
|
|
|
void setHost(Person *);
|
|
|
|
|
2012-02-16 04:43:03 +00:00
|
|
|
QQmlListProperty<Person> guests();
|
2021-11-02 08:04:21 +00:00
|
|
|
void appendGuest(Person *);
|
2020-11-09 09:46:07 +00:00
|
|
|
qsizetype guestCount() const;
|
|
|
|
Person *guest(qsizetype) const;
|
2017-03-02 16:16:09 +00:00
|
|
|
void clearGuests();
|
2021-11-02 08:04:21 +00:00
|
|
|
void replaceGuest(qsizetype, Person *);
|
2019-11-25 15:10:04 +00:00
|
|
|
void removeLastGuest();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2023-03-17 14:42:47 +00:00
|
|
|
signals:
|
|
|
|
void hostChanged();
|
|
|
|
void guestsChanged();
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
private:
|
2023-03-17 14:42:47 +00:00
|
|
|
static void appendGuest(QQmlListProperty<Person> *list, Person *);
|
2021-11-02 08:04:21 +00:00
|
|
|
static qsizetype guestCount(QQmlListProperty<Person> *);
|
2023-03-17 14:42:47 +00:00
|
|
|
static Person *guest(QQmlListProperty<Person> *, qsizetype);
|
2021-11-02 08:04:21 +00:00
|
|
|
static void clearGuests(QQmlListProperty<Person> *);
|
|
|
|
static void replaceGuest(QQmlListProperty<Person> *, qsizetype, Person *);
|
|
|
|
static void removeLastGuest(QQmlListProperty<Person> *);
|
2017-03-02 16:16:09 +00:00
|
|
|
|
2021-11-02 08:04:21 +00:00
|
|
|
Person *m_host = nullptr;
|
2020-06-22 10:12:52 +00:00
|
|
|
QList<Person *> m_guests;
|
2011-04-27 10:05:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BIRTHDAYPARTY_H
|