summaryrefslogtreecommitdiffstats
path: root/examples/declarative/extending/attached
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/extending/attached')
-rw-r--r--examples/declarative/extending/attached/birthdayparty.cpp10
-rw-r--r--examples/declarative/extending/attached/birthdayparty.h20
-rw-r--r--examples/declarative/extending/attached/example.qml10
-rw-r--r--examples/declarative/extending/attached/main.cpp6
-rw-r--r--examples/declarative/extending/attached/person.h37
5 files changed, 41 insertions, 42 deletions
diff --git a/examples/declarative/extending/attached/birthdayparty.cpp b/examples/declarative/extending/attached/birthdayparty.cpp
index d4f2675..7fa1748 100644
--- a/examples/declarative/extending/attached/birthdayparty.cpp
+++ b/examples/declarative/extending/attached/birthdayparty.cpp
@@ -56,18 +56,18 @@ void BirthdayPartyAttached::setRsvp(const QDate &d)
}
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/attached/birthdayparty.h b/examples/declarative/extending/attached/birthdayparty.h
index d8ca2e1..1c66f8c 100644
--- a/examples/declarative/extending/attached/birthdayparty.h
+++ b/examples/declarative/extending/attached/birthdayparty.h
@@ -48,8 +48,8 @@
class BirthdayPartyAttached : public QObject
{
-Q_OBJECT
-Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp)
+ Q_OBJECT
+ Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp)
public:
BirthdayPartyAttached(QObject *object);
@@ -59,19 +59,18 @@ public:
private:
QDate m_rsvp;
};
-QML_DECLARE_TYPE(BirthdayPartyAttached)
class BirthdayParty : public QObject
{
-Q_OBJECT
-Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
-Q_CLASSINFO("DefaultProperty", "guests")
+ Q_OBJECT
+ Q_PROPERTY(Person *host READ host WRITE setHost)
+ Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
+ Q_CLASSINFO("DefaultProperty", "guests")
public:
BirthdayParty(QObject *parent = 0);
- Person *celebrant() const;
- void setCelebrant(Person *);
+ Person *host() const;
+ void setHost(Person *);
QDeclarativeListProperty<Person> guests();
int guestCount() const;
@@ -79,11 +78,10 @@ public:
static BirthdayPartyAttached *qmlAttachedProperties(QObject *);
private:
- Person *m_celebrant;
+ Person *m_host;
QList<Person *> m_guests;
};
QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES)
-QML_DECLARE_TYPE(BirthdayParty)
#endif // BIRTHDAYPARTY_H
diff --git a/examples/declarative/extending/attached/example.qml b/examples/declarative/extending/attached/example.qml
index 952eb93..50f0a32 100644
--- a/examples/declarative/extending/attached/example.qml
+++ b/examples/declarative/extending/attached/example.qml
@@ -1,16 +1,17 @@
import People 1.0
BirthdayParty {
- celebrant: Boy {
+ host: Boy {
name: "Bob Jones"
shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 }
}
// ![1]
Boy {
- name: "Joan Hodges"
- BirthdayParty.rsvp: "2009-07-06"
+ name: "Leo Hodges"
shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 }
+
+ BirthdayParty.rsvp: "2009-07-06"
}
// ![1]
Boy {
@@ -19,11 +20,12 @@ BirthdayParty {
}
Girl {
name: "Anne Brown"
- BirthdayParty.rsvp: "2009-07-01"
shoe.size: 7
shoe.color: "red"
shoe.brand: "Marc Jacobs"
shoe.price: 699.99
+
+ BirthdayParty.rsvp: "2009-07-01"
}
}
diff --git a/examples/declarative/extending/attached/main.cpp b/examples/declarative/extending/attached/main.cpp
index fd2d525..f1055ae 100644
--- a/examples/declarative/extending/attached/main.cpp
+++ b/examples/declarative/extending/attached/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/attached/person.h b/examples/declarative/extending/attached/person.h
index 08caebf..2f444c5 100644
--- a/examples/declarative/extending/attached/person.h
+++ b/examples/declarative/extending/attached/person.h
@@ -43,14 +43,14 @@
#include <QObject>
#include <QColor>
-#include <qdeclarative.h>
-class ShoeDescription : public QObject {
-Q_OBJECT
-Q_PROPERTY(int size READ size WRITE setSize)
-Q_PROPERTY(QColor color READ color WRITE setColor)
-Q_PROPERTY(QString brand READ brand WRITE setBrand)
-Q_PROPERTY(qreal price READ price WRITE setPrice)
+class ShoeDescription : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int size READ size WRITE setSize)
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ Q_PROPERTY(QString brand READ brand WRITE setBrand)
+ Q_PROPERTY(qreal price READ price WRITE setPrice)
public:
ShoeDescription(QObject *parent = 0);
@@ -71,12 +71,12 @@ private:
QString m_brand;
qreal m_price;
};
-QML_DECLARE_TYPE(ShoeDescription);
-class Person : public QObject {
-Q_OBJECT
-Q_PROPERTY(QString name READ name WRITE setName)
-Q_PROPERTY(ShoeDescription *shoe READ shoe)
+class Person : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(ShoeDescription *shoe READ shoe)
public:
Person(QObject *parent = 0);
@@ -88,20 +88,19 @@ private:
QString m_name;
ShoeDescription m_shoe;
};
-QML_DECLARE_TYPE(Person);
-class Boy : public Person {
-Q_OBJECT
+class Boy : public Person
+{
+ Q_OBJECT
public:
Boy(QObject * parent = 0);
};
-QML_DECLARE_TYPE(Boy);
-class Girl : public Person {
-Q_OBJECT
+class Girl : public Person
+{
+ Q_OBJECT
public:
Girl(QObject * parent = 0);
};
-QML_DECLARE_TYPE(Girl);
#endif // PERSON_H