diff options
Diffstat (limited to 'examples/qml/referenceexamples/properties')
-rw-r--r-- | examples/qml/referenceexamples/properties/birthdayparty.cpp | 24 | ||||
-rw-r--r-- | examples/qml/referenceexamples/properties/birthdayparty.h | 4 |
2 files changed, 27 insertions, 1 deletions
diff --git a/examples/qml/referenceexamples/properties/birthdayparty.cpp b/examples/qml/referenceexamples/properties/birthdayparty.cpp index 9abb08dbd9..fe6abab3f5 100644 --- a/examples/qml/referenceexamples/properties/birthdayparty.cpp +++ b/examples/qml/referenceexamples/properties/birthdayparty.cpp @@ -71,7 +71,9 @@ QQmlListProperty<Person> BirthdayParty::guests() &BirthdayParty::appendGuest, &BirthdayParty::guestCount, &BirthdayParty::guest, - &BirthdayParty::clearGuests}; + &BirthdayParty::clearGuests, + &BirthdayParty::replaceGuest, + &BirthdayParty::removeLastGuest}; } void BirthdayParty::appendGuest(Person* p) { @@ -93,6 +95,16 @@ void BirthdayParty::clearGuests() { m_guests.clear(); } +void BirthdayParty::replaceGuest(int index, Person *p) +{ + m_guests[index] = p; +} + +void BirthdayParty::removeLastGuest() +{ + m_guests.removeLast(); +} + // ![0] void BirthdayParty::appendGuest(QQmlListProperty<Person>* list, Person* p) { @@ -103,6 +115,16 @@ void BirthdayParty::clearGuests(QQmlListProperty<Person>* list) { reinterpret_cast< BirthdayParty* >(list->data)->clearGuests(); } +void BirthdayParty::replaceGuest(QQmlListProperty<Person> *list, int i, Person *p) +{ + reinterpret_cast< BirthdayParty* >(list->data)->replaceGuest(i, p); +} + +void BirthdayParty::removeLastGuest(QQmlListProperty<Person> *list) +{ + reinterpret_cast< BirthdayParty* >(list->data)->removeLastGuest(); +} + Person* BirthdayParty::guest(QQmlListProperty<Person>* list, int i) { return reinterpret_cast< BirthdayParty* >(list->data)->guest(i); } diff --git a/examples/qml/referenceexamples/properties/birthdayparty.h b/examples/qml/referenceexamples/properties/birthdayparty.h index fb8b63a79d..a5704972cc 100644 --- a/examples/qml/referenceexamples/properties/birthdayparty.h +++ b/examples/qml/referenceexamples/properties/birthdayparty.h @@ -79,12 +79,16 @@ public: int guestCount() const; Person *guest(int) const; void clearGuests(); + void replaceGuest(int, Person*); + void removeLastGuest(); private: static void appendGuest(QQmlListProperty<Person>*, Person*); static int guestCount(QQmlListProperty<Person>*); static Person* guest(QQmlListProperty<Person>*, int); static void clearGuests(QQmlListProperty<Person>*); + static void replaceGuest(QQmlListProperty<Person>*, int, Person*); + static void removeLastGuest(QQmlListProperty<Person>*); Person *m_host; QVector<Person *> m_guests; |