birthdayparty.cpp Example File
referenceexamples/binding/birthdayparty.cpp
#include "birthdayparty.h"
BirthdayPartyAttached::BirthdayPartyAttached(QObject *object)
: QObject(object)
{
}
QDate BirthdayPartyAttached::rsvp() const
{
return m_rsvp;
}
void BirthdayPartyAttached::setRsvp(const QDate &d)
{
if (d != m_rsvp) {
m_rsvp = d;
emit rsvpChanged();
}
}
BirthdayParty::BirthdayParty(QObject *parent)
: QObject(parent), m_host(nullptr)
{
}
Person *BirthdayParty::host() const
{
return m_host;
}
void BirthdayParty::setHost(Person *c)
{
if (c == m_host) return;
m_host = c;
emit hostChanged();
}
QQmlListProperty<Person> BirthdayParty::guests()
{
return QQmlListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
{
return m_guests.count();
}
Person *BirthdayParty::guest(int index) const
{
return m_guests.at(index);
}
void BirthdayParty::startParty()
{
QTime time = QTime::currentTime();
emit partyStarted(time);
}
QString BirthdayParty::announcement() const
{
return QString();
}
void BirthdayParty::setAnnouncement(const QString &speak)
{
qWarning() << qPrintable(speak);
}
BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
{
return new BirthdayPartyAttached(object);
}