summaryrefslogtreecommitdiffstats
path: root/examples/declarative/extending/coercion
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/extending/coercion')
-rw-r--r--examples/declarative/extending/coercion/birthdayparty.cpp10
-rw-r--r--examples/declarative/extending/coercion/birthdayparty.h14
-rw-r--r--examples/declarative/extending/coercion/example.qml4
-rw-r--r--examples/declarative/extending/coercion/main.cpp6
-rw-r--r--examples/declarative/extending/coercion/person.h20
5 files changed, 28 insertions, 26 deletions
diff --git a/examples/declarative/extending/coercion/birthdayparty.cpp b/examples/declarative/extending/coercion/birthdayparty.cpp
index 523a42d..4f415a3 100644
--- a/examples/declarative/extending/coercion/birthdayparty.cpp
+++ b/examples/declarative/extending/coercion/birthdayparty.cpp
@@ -41,18 +41,18 @@
#include "birthdayparty.h"
BirthdayParty::BirthdayParty(QObject *parent)
-: QObject(parent), m_celebrant(0)
+: QObject(parent), m_host(0)
{
}
-Person *BirthdayParty::celebrant() const
+Person *BirthdayParty::host() const
{
- return m_celebrant;
+ return m_host;
}
-void BirthdayParty::setCelebrant(Person *c)
+void BirthdayParty::setHost(Person *c)
{
- m_celebrant = c;
+ m_host = c;
}
QDeclarativeListProperty<Person> BirthdayParty::guests()
diff --git a/examples/declarative/extending/coercion/birthdayparty.h b/examples/declarative/extending/coercion/birthdayparty.h
index a5d14f9..ee77e9a 100644
--- a/examples/declarative/extending/coercion/birthdayparty.h
+++ b/examples/declarative/extending/coercion/birthdayparty.h
@@ -42,28 +42,28 @@
#define BIRTHDAYPARTY_H
#include <QObject>
-#include <qdeclarative.h>
+#include <QDeclarativeListProperty>
#include "person.h"
class BirthdayParty : public QObject
{
-Q_OBJECT
+ Q_OBJECT
// ![0]
-Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+ Q_PROPERTY(Person *host READ host WRITE setHost)
+ Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
// ![0]
public:
BirthdayParty(QObject *parent = 0);
- Person *celebrant() const;
- void setCelebrant(Person *);
+ Person *host() const;
+ void setHost(Person *);
QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
private:
- Person *m_celebrant;
+ Person *m_host;
QList<Person *> m_guests;
};
diff --git a/examples/declarative/extending/coercion/example.qml b/examples/declarative/extending/coercion/example.qml
index 64d26b0..7b45950 100644
--- a/examples/declarative/extending/coercion/example.qml
+++ b/examples/declarative/extending/coercion/example.qml
@@ -2,12 +2,12 @@ import People 1.0
// ![0]
BirthdayParty {
- celebrant: Boy {
+ host: Boy {
name: "Bob Jones"
shoeSize: 12
}
guests: [
- Boy { name: "Joan Hodges" },
+ Boy { name: "Leo Hodges" },
Boy { name: "Jack Smith" },
Girl { name: "Anne Brown" }
]
diff --git a/examples/declarative/extending/coercion/main.cpp b/examples/declarative/extending/coercion/main.cpp
index 312aff9..2c7b545 100644
--- a/examples/declarative/extending/coercion/main.cpp
+++ b/examples/declarative/extending/coercion/main.cpp
@@ -60,10 +60,10 @@ int main(int argc, char ** argv)
QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
- if (party && party->celebrant()) {
- qWarning() << party->celebrant()->name() << "is having a birthday!";
+ if (party && party->host()) {
+ qWarning() << party->host()->name() << "is having a birthday!";
- if (qobject_cast<Boy *>(party->celebrant()))
+ if (qobject_cast<Boy *>(party->host()))
qWarning() << "He is inviting:";
else
qWarning() << "She is inviting:";
diff --git a/examples/declarative/extending/coercion/person.h b/examples/declarative/extending/coercion/person.h
index 861f135..1c95da7 100644
--- a/examples/declarative/extending/coercion/person.h
+++ b/examples/declarative/extending/coercion/person.h
@@ -42,12 +42,12 @@
#define PERSON_H
#include <QObject>
-#include <qdeclarative.h>
-class Person : public QObject {
-Q_OBJECT
-Q_PROPERTY(QString name READ name WRITE setName)
-Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize)
+class Person : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize)
public:
Person(QObject *parent = 0);
@@ -63,15 +63,17 @@ private:
// ![0]
-class Boy : public Person {
-Q_OBJECT
+class Boy : public Person
+{
+ Q_OBJECT
public:
Boy(QObject * parent = 0);
};
-class Girl : public Person {
-Q_OBJECT
+class Girl : public Person
+{
+ Q_OBJECT
public:
Girl(QObject * parent = 0);
};