summaryrefslogtreecommitdiffstats
path: root/examples/declarative/extending/valuesource
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/extending/valuesource')
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.cpp14
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.h9
-rw-r--r--examples/declarative/extending/valuesource/main.cpp4
3 files changed, 20 insertions, 7 deletions
diff --git a/examples/declarative/extending/valuesource/birthdayparty.cpp b/examples/declarative/extending/valuesource/birthdayparty.cpp
index b483f68..a5b3fab 100644
--- a/examples/declarative/extending/valuesource/birthdayparty.cpp
+++ b/examples/declarative/extending/valuesource/birthdayparty.cpp
@@ -72,9 +72,19 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlList<Person *> *BirthdayParty::guests()
+QmlListProperty<Person> BirthdayParty::guests()
{
- return &m_guests;
+ return QmlListProperty<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()
diff --git a/examples/declarative/extending/valuesource/birthdayparty.h b/examples/declarative/extending/valuesource/birthdayparty.h
index e7ca461..b5a0522 100644
--- a/examples/declarative/extending/valuesource/birthdayparty.h
+++ b/examples/declarative/extending/valuesource/birthdayparty.h
@@ -66,7 +66,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlList<Person *> *guests READ guests)
+Q_PROPERTY(QmlListProperty<Person> guests READ guests)
// ![0]
Q_PROPERTY(QString speaker READ speaker WRITE setSpeaker)
// ![0]
@@ -77,7 +77,10 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlList<Person *> *guests();
+ QmlListProperty<Person> guests();
+ int guestCount() const;
+ Person *guest(int) const;
+
QString speaker() const;
void setSpeaker(const QString &);
@@ -90,7 +93,7 @@ signals:
private:
Person *m_celebrant;
- QmlConcreteList<Person *> m_guests;
+ QList<Person *> m_guests;
};
QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES)
diff --git a/examples/declarative/extending/valuesource/main.cpp b/examples/declarative/extending/valuesource/main.cpp
index 4ad9929..ba38e82 100644
--- a/examples/declarative/extending/valuesource/main.cpp
+++ b/examples/declarative/extending/valuesource/main.cpp
@@ -61,8 +61,8 @@ int main(int argc, char ** argv)
else
qWarning() << "She is inviting:";
- for (int ii = 0; ii < party->guests()->count(); ++ii) {
- Person *guest = party->guests()->at(ii);
+ for (int ii = 0; ii < party->guestCount(); ++ii) {
+ Person *guest = party->guest(ii);
QDate rsvpDate;
QObject *attached =