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.cpp6
-rw-r--r--examples/declarative/extending/valuesource/birthdayparty.h6
-rw-r--r--examples/declarative/extending/valuesource/happybirthday.cpp3
-rw-r--r--examples/declarative/extending/valuesource/happybirthday.h11
-rw-r--r--examples/declarative/extending/valuesource/main.cpp17
-rw-r--r--examples/declarative/extending/valuesource/person.cpp4
-rw-r--r--examples/declarative/extending/valuesource/person.h2
7 files changed, 26 insertions, 23 deletions
diff --git a/examples/declarative/extending/valuesource/birthdayparty.cpp b/examples/declarative/extending/valuesource/birthdayparty.cpp
index a5b3fab..99d98be 100644
--- a/examples/declarative/extending/valuesource/birthdayparty.cpp
+++ b/examples/declarative/extending/valuesource/birthdayparty.cpp
@@ -55,7 +55,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d)
m_rsvp = d;
}
-QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached);
BirthdayParty::BirthdayParty(QObject *parent)
: QObject(parent), m_celebrant(0)
@@ -72,9 +71,9 @@ void BirthdayParty::setCelebrant(Person *c)
m_celebrant = c;
}
-QmlListProperty<Person> BirthdayParty::guests()
+QDeclarativeListProperty<Person> BirthdayParty::guests()
{
- return QmlListProperty<Person>(this, m_guests);
+ return QDeclarativeListProperty<Person>(this, m_guests);
}
int BirthdayParty::guestCount() const
@@ -108,4 +107,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object)
return new BirthdayPartyAttached(object);
}
-QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
diff --git a/examples/declarative/extending/valuesource/birthdayparty.h b/examples/declarative/extending/valuesource/birthdayparty.h
index b5a0522..819a200 100644
--- a/examples/declarative/extending/valuesource/birthdayparty.h
+++ b/examples/declarative/extending/valuesource/birthdayparty.h
@@ -44,7 +44,7 @@
#include <QObject>
#include <QDate>
#include <QDebug>
-#include <qml.h>
+#include <qdeclarative.h>
#include "person.h"
class BirthdayPartyAttached : public QObject
@@ -66,7 +66,7 @@ class BirthdayParty : public QObject
{
Q_OBJECT
Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant)
-Q_PROPERTY(QmlListProperty<Person> guests READ guests)
+Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests)
// ![0]
Q_PROPERTY(QString speaker READ speaker WRITE setSpeaker)
// ![0]
@@ -77,7 +77,7 @@ public:
Person *celebrant() const;
void setCelebrant(Person *);
- QmlListProperty<Person> guests();
+ QDeclarativeListProperty<Person> guests();
int guestCount() const;
Person *guest(int) const;
diff --git a/examples/declarative/extending/valuesource/happybirthday.cpp b/examples/declarative/extending/valuesource/happybirthday.cpp
index fbbc9e9..7b9d05a 100644
--- a/examples/declarative/extending/valuesource/happybirthday.cpp
+++ b/examples/declarative/extending/valuesource/happybirthday.cpp
@@ -50,7 +50,7 @@ HappyBirthday::HappyBirthday(QObject *parent)
timer->start(1000);
}
-void HappyBirthday::setTarget(const QmlMetaProperty &p)
+void HappyBirthday::setTarget(const QDeclarativeMetaProperty &p)
{
m_target = p;
}
@@ -79,4 +79,3 @@ void HappyBirthday::advance()
m_target.write(m_lyrics.at(m_line));
}
-QML_DEFINE_TYPE(People, 1,0, HappyBirthday, HappyBirthday);
diff --git a/examples/declarative/extending/valuesource/happybirthday.h b/examples/declarative/extending/valuesource/happybirthday.h
index c02a7d7..3e68c35 100644
--- a/examples/declarative/extending/valuesource/happybirthday.h
+++ b/examples/declarative/extending/valuesource/happybirthday.h
@@ -41,13 +41,14 @@
#ifndef HAPPYBIRTHDAY_H
#define HAPPYBIRTHDAY_H
-#include <QmlPropertyValueSource>
-#include <qml.h>
+#include <QDeclarativePropertyValueSource>
+#include <QDeclarativeMetaProperty>
+#include <qdeclarative.h>
#include <QStringList>
// ![0]
-class HappyBirthday : public QObject, public QmlPropertyValueSource
+class HappyBirthday : public QObject, public QDeclarativePropertyValueSource
{
Q_OBJECT
// ![0]
@@ -56,7 +57,7 @@ Q_PROPERTY(QString name READ name WRITE setName)
public:
HappyBirthday(QObject *parent = 0);
- virtual void setTarget(const QmlMetaProperty &);
+ virtual void setTarget(const QDeclarativeMetaProperty &);
// ![1]
QString name() const;
@@ -68,7 +69,7 @@ private slots:
private:
int m_line;
QStringList m_lyrics;
- QmlMetaProperty m_target;
+ QDeclarativeMetaProperty m_target;
QString m_name;
// ![2]
};
diff --git a/examples/declarative/extending/valuesource/main.cpp b/examples/declarative/extending/valuesource/main.cpp
index ba38e82..873f8c9 100644
--- a/examples/declarative/extending/valuesource/main.cpp
+++ b/examples/declarative/extending/valuesource/main.cpp
@@ -39,18 +39,27 @@
**
****************************************************************************/
#include <QCoreApplication>
-#include <QmlEngine>
-#include <QmlComponent>
+#include <QDeclarativeEngine>
+#include <QDeclarativeComponent>
#include <QDebug>
#include "birthdayparty.h"
+#include "happybirthday.h"
#include "person.h"
int main(int argc, char ** argv)
{
QCoreApplication app(argc, argv);
- QmlEngine engine;
- QmlComponent component(&engine, ":example.qml");
+ QML_REGISTER_NOCREATE_TYPE(BirthdayPartyAttached);
+ QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty);
+ QML_REGISTER_TYPE(People, 1,0, HappyBirthday, HappyBirthday);
+ QML_REGISTER_NOCREATE_TYPE(ShoeDescription);
+ QML_REGISTER_NOCREATE_TYPE(Person);
+ QML_REGISTER_TYPE(People, 1,0, Boy, Boy);
+ QML_REGISTER_TYPE(People, 1,0, Girl, Girl);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, ":example.qml");
BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create());
if (party && party->celebrant()) {
diff --git a/examples/declarative/extending/valuesource/person.cpp b/examples/declarative/extending/valuesource/person.cpp
index 909505a..0a9e508 100644
--- a/examples/declarative/extending/valuesource/person.cpp
+++ b/examples/declarative/extending/valuesource/person.cpp
@@ -84,7 +84,6 @@ void ShoeDescription::setPrice(qreal p)
{
m_price = p;
}
-QML_DEFINE_NOCREATE_TYPE(ShoeDescription);
Person::Person(QObject *parent)
: QObject(parent)
@@ -106,18 +105,15 @@ ShoeDescription *Person::shoe()
return &m_shoe;
}
-QML_DEFINE_NOCREATE_TYPE(Person);
Boy::Boy(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Boy, Boy);
Girl::Girl(QObject * parent)
: Person(parent)
{
}
-QML_DEFINE_TYPE(People, 1,0, Girl, Girl);
diff --git a/examples/declarative/extending/valuesource/person.h b/examples/declarative/extending/valuesource/person.h
index dd03091..0f86d8b 100644
--- a/examples/declarative/extending/valuesource/person.h
+++ b/examples/declarative/extending/valuesource/person.h
@@ -43,7 +43,7 @@
#include <QObject>
#include <QColor>
-#include <qml.h>
+#include <qdeclarative.h>
class ShoeDescription : public QObject {
Q_OBJECT