diff options
Diffstat (limited to 'examples')
87 files changed, 481 insertions, 357 deletions
diff --git a/examples/declarative/animations/easing.qml b/examples/declarative/animations/easing.qml index 9b5bcc6..8f2655e 100644 --- a/examples/declarative/animations/easing.qml +++ b/examples/declarative/animations/easing.qml @@ -6,47 +6,47 @@ Rectangle { ListModel { id: easingTypes - ListElement { type: "easeLinear"; ballColor: "DarkRed" } - ListElement { type: "easeInQuad"; ballColor: "IndianRed" } - ListElement { type: "easeOutQuad"; ballColor: "Salmon" } - ListElement { type: "easeInOutQuad"; ballColor: "Tomato" } - ListElement { type: "easeOutInQuad"; ballColor: "DarkOrange" } - ListElement { type: "easeInCubic"; ballColor: "Gold" } - ListElement { type: "easeOutCubic"; ballColor: "Yellow" } - ListElement { type: "easeInOutCubic"; ballColor: "PeachPuff" } - ListElement { type: "easeOutInCubic"; ballColor: "Thistle" } - ListElement { type: "easeInQuart"; ballColor: "Orchid" } - ListElement { type: "easeOutQuart"; ballColor: "Purple" } - ListElement { type: "easeInOutQuart"; ballColor: "SlateBlue" } - ListElement { type: "easeOutInQuart"; ballColor: "Chartreuse" } - ListElement { type: "easeInQuint"; ballColor: "LimeGreen" } - ListElement { type: "easeOutQuint"; ballColor: "SeaGreen" } - ListElement { type: "easeInOutQuint"; ballColor: "DarkGreen" } - ListElement { type: "easeOutInQuint"; ballColor: "Olive" } - ListElement { type: "easeInSine"; ballColor: "DarkSeaGreen" } - ListElement { type: "easeOutSine"; ballColor: "Teal" } - ListElement { type: "easeInOutSine"; ballColor: "Turquoise" } - ListElement { type: "easeOutInSine"; ballColor: "SteelBlue" } - ListElement { type: "easeInExpo"; ballColor: "SkyBlue" } - ListElement { type: "easeOutExpo"; ballColor: "RoyalBlue" } - ListElement { type: "easeInOutExpo"; ballColor: "MediumBlue" } - ListElement { type: "easeOutInExpo"; ballColor: "MidnightBlue" } - ListElement { type: "easeInCirc"; ballColor: "CornSilk" } - ListElement { type: "easeOutCirc"; ballColor: "Bisque" } - ListElement { type: "easeInOutCirc"; ballColor: "RosyBrown" } - ListElement { type: "easeOutInCirc"; ballColor: "SandyBrown" } - ListElement { type: "easeInElastic"; ballColor: "DarkGoldenRod" } - ListElement { type: "easeOutElastic"; ballColor: "Chocolate" } - ListElement { type: "easeInOutElastic"; ballColor: "SaddleBrown" } - ListElement { type: "easeOutInElastic"; ballColor: "Brown" } - ListElement { type: "easeInBack"; ballColor: "Maroon" } - ListElement { type: "easeOutBack"; ballColor: "LavenderBlush" } - ListElement { type: "easeInOutBack"; ballColor: "MistyRose" } - ListElement { type: "easeOutInBack"; ballColor: "Gainsboro" } - ListElement { type: "easeOutBounce"; ballColor: "Silver" } - ListElement { type: "easeInBounce"; ballColor: "DimGray" } - ListElement { type: "easeInOutBounce"; ballColor: "SlateGray" } - ListElement { type: "easeOutInBounce"; ballColor: "DarkSlateGray" } + ListElement { type: "Linear"; ballColor: "DarkRed" } + ListElement { type: "InQuad"; ballColor: "IndianRed" } + ListElement { type: "OutQuad"; ballColor: "Salmon" } + ListElement { type: "InOutQuad"; ballColor: "Tomato" } + ListElement { type: "OutInQuad"; ballColor: "DarkOrange" } + ListElement { type: "InCubic"; ballColor: "Gold" } + ListElement { type: "OutCubic"; ballColor: "Yellow" } + ListElement { type: "InOutCubic"; ballColor: "PeachPuff" } + ListElement { type: "OutInCubic"; ballColor: "Thistle" } + ListElement { type: "InQuart"; ballColor: "Orchid" } + ListElement { type: "OutQuart"; ballColor: "Purple" } + ListElement { type: "InOutQuart"; ballColor: "SlateBlue" } + ListElement { type: "OutInQuart"; ballColor: "Chartreuse" } + ListElement { type: "InQuint"; ballColor: "LimeGreen" } + ListElement { type: "OutQuint"; ballColor: "SeaGreen" } + ListElement { type: "InOutQuint"; ballColor: "DarkGreen" } + ListElement { type: "OutInQuint"; ballColor: "Olive" } + ListElement { type: "InSine"; ballColor: "DarkSeaGreen" } + ListElement { type: "OutSine"; ballColor: "Teal" } + ListElement { type: "InOutSine"; ballColor: "Turquoise" } + ListElement { type: "OutInSine"; ballColor: "SteelBlue" } + ListElement { type: "InExpo"; ballColor: "SkyBlue" } + ListElement { type: "OutExpo"; ballColor: "RoyalBlue" } + ListElement { type: "InOutExpo"; ballColor: "MediumBlue" } + ListElement { type: "OutInExpo"; ballColor: "MidnightBlue" } + ListElement { type: "InCirc"; ballColor: "CornSilk" } + ListElement { type: "OutCirc"; ballColor: "Bisque" } + ListElement { type: "InOutCirc"; ballColor: "RosyBrown" } + ListElement { type: "OutInCirc"; ballColor: "SandyBrown" } + ListElement { type: "InElastic"; ballColor: "DarkGoldenRod" } + ListElement { type: "OutElastic"; ballColor: "Chocolate" } + ListElement { type: "InOutElastic"; ballColor: "SaddleBrown" } + ListElement { type: "OutInElastic"; ballColor: "Brown" } + ListElement { type: "InBack"; ballColor: "Maroon" } + ListElement { type: "OutBack"; ballColor: "LavenderBlush" } + ListElement { type: "InOutBack"; ballColor: "MistyRose" } + ListElement { type: "OutInBack"; ballColor: "Gainsboro" } + ListElement { type: "OutBounce"; ballColor: "Silver" } + ListElement { type: "InBounce"; ballColor: "DimGray" } + ListElement { type: "InOutBounce"; ballColor: "SlateGray" } + ListElement { type: "OutInBounce"; ballColor: "DarkSlateGray" } } Component { @@ -80,8 +80,8 @@ Rectangle { transitions: Transition { ParallelAnimation { - NumberAnimation { properties: "x"; easing: type; duration: 1000 } - ColorAnimation { properties: "color"; easing: type; duration: 1000 } + NumberAnimation { properties: "x"; easing.type: type; duration: 1000 } + ColorAnimation { properties: "color"; easing.type: type; duration: 1000 } } } } @@ -89,7 +89,7 @@ Rectangle { } Flickable { - anchors.fill: parent; viewportHeight: layout.height + anchors.fill: parent; contentHeight: layout.height Column { id: layout anchors.left: parent.left; anchors.right: parent.right diff --git a/examples/declarative/animations/property-animation.qml b/examples/declarative/animations/property-animation.qml index 9f76ee5..537ee26 100644 --- a/examples/declarative/animations/property-animation.qml +++ b/examples/declarative/animations/property-animation.qml @@ -45,16 +45,16 @@ Item { y: SequentialAnimation { repeat: true - // Move from minHeight to maxHeight in 300ms, using the easeOutExpo easing function + // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function NumberAnimation { from: smiley.minHeight; to: smiley.maxHeight - easing: "easeOutExpo"; duration: 300 + easing.type: "OutExpo"; duration: 300 } - // Then move back to minHeight in 1 second, using the easeOutBounce easing function + // Then move back to minHeight in 1 second, using the OutBounce easing function NumberAnimation { from: smiley.maxHeight; to: smiley.minHeight - easing: "easeOutBounce"; duration: 1000 + easing.type: "OutBounce"; duration: 1000 } // Then pause for 500ms diff --git a/examples/declarative/behaviours/test.qml b/examples/declarative/behaviours/test.qml index fc3f4bf..8fffd59 100644 --- a/examples/declarative/behaviours/test.qml +++ b/examples/declarative/behaviours/test.qml @@ -64,7 +64,8 @@ Rectangle { property: "y" from: 0 to: 10 - easing: "easeOutBounce(amplitude:30)" + easing.type: "OutBounce" + easing.amplitude: 30 duration: 250 } NumberAnimation { @@ -72,7 +73,8 @@ Rectangle { property: "y" from: 10 to: 0 - easing: "easeOutBounce(amplitude:30)" + easing.type: "OutBounce" + easing.amplitude: 30 duration: 250 } } diff --git a/examples/declarative/border-image/content/MyBorderImage.qml b/examples/declarative/border-image/content/MyBorderImage.qml index a57acc7..ca886e9 100644 --- a/examples/declarative/border-image/content/MyBorderImage.qml +++ b/examples/declarative/border-image/content/MyBorderImage.qml @@ -19,14 +19,14 @@ Item { width: SequentialAnimation { repeat: true - NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing: "easeInOutQuad"} - NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing: "easeInOutQuad" } + NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing.type: "InOutQuad"} + NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing.type: "InOutQuad" } } height: SequentialAnimation { repeat: true - NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing: "easeInOutQuad"} - NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing: "easeInOutQuad" } + NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing.type: "InOutQuad"} + NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing.type: "InOutQuad" } } border.top: container.margin diff --git a/examples/declarative/connections/connections.qml b/examples/declarative/connections/connections.qml index 07f71bb..4692343 100644 --- a/examples/declarative/connections/connections.qml +++ b/examples/declarative/connections/connections.qml @@ -5,16 +5,12 @@ Rectangle { id: window; color: "#646464" width: 640; height: 480 - function turnLeft() { - image.rotation -= 90 - } - function turnRight() { - image.rotation += 90 - } + property int angle: 0 Image { id: image; source: "content/bg1.jpg"; anchors.centerIn: parent; transformOrigin: Item.Center - rotation: Behavior { NumberAnimation { easing: "easeOutCubic"; duration: 300 } } + rotation: window.angle + rotation: Behavior { NumberAnimation { easing.type: "OutCubic"; duration: 300 } } } Button { @@ -26,6 +22,6 @@ Rectangle { anchors { right: parent.right; bottom: parent.bottom; rightMargin: 10; bottomMargin: 10 } } - Connection { sender: leftButton; signal: "clicked()"; script: window.turnLeft() } - Connection { sender: rightButton; signal: "clicked()"; script: window.turnRight() } + Connections { target: leftButton; onClicked: window.angle -= 90 } + Connections { target: rightButton; onClicked: window.angle += 90 } } diff --git a/examples/declarative/extending/adding/main.cpp b/examples/declarative/extending/adding/main.cpp index 74ea35c..76e0736 100644 --- a/examples/declarative/extending/adding/main.cpp +++ b/examples/declarative/extending/adding/main.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ #include <QCoreApplication> -#include <QmlEngine> -#include <QmlComponent> +#include <QDeclarativeEngine> +#include <QDeclarativeComponent> #include <QDebug> #include "person.h" @@ -48,8 +48,10 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QmlEngine engine; - QmlComponent component(&engine, ":example.qml"); + QML_REGISTER_TYPE(People, 1,0, Person, Person); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); Person *person = qobject_cast<Person *>(component.create()); if (person) { qWarning() << "The person's name is" << person->name(); diff --git a/examples/declarative/extending/adding/person.cpp b/examples/declarative/extending/adding/person.cpp index 9efa2b8..cdf08e0 100644 --- a/examples/declarative/extending/adding/person.cpp +++ b/examples/declarative/extending/adding/person.cpp @@ -66,5 +66,4 @@ void Person::setShoeSize(int s) m_shoeSize = s; } -QML_DEFINE_TYPE(People, 1,0, Person, Person); // ![0] diff --git a/examples/declarative/extending/adding/person.h b/examples/declarative/extending/adding/person.h index 691766b..fbaf2df 100644 --- a/examples/declarative/extending/adding/person.h +++ b/examples/declarative/extending/adding/person.h @@ -43,7 +43,7 @@ #include <QObject> // ![0] -#include <qml.h> +#include <qdeclarative.h> class Person : public QObject { Q_OBJECT diff --git a/examples/declarative/extending/attached/birthdayparty.cpp b/examples/declarative/extending/attached/birthdayparty.cpp index ffdda57..d4f2675 100644 --- a/examples/declarative/extending/attached/birthdayparty.cpp +++ b/examples/declarative/extending/attached/birthdayparty.cpp @@ -55,8 +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 +70,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 @@ -92,4 +90,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) return new BirthdayPartyAttached(object); } -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/attached/birthdayparty.h b/examples/declarative/extending/attached/birthdayparty.h index 9ba0f8b..d8ca2e1 100644 --- a/examples/declarative/extending/attached/birthdayparty.h +++ b/examples/declarative/extending/attached/birthdayparty.h @@ -43,7 +43,7 @@ #include <QObject> #include <QDate> -#include <qml.h> +#include <qdeclarative.h> #include "person.h" class BirthdayPartyAttached : public QObject @@ -65,7 +65,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) Q_CLASSINFO("DefaultProperty", "guests") public: BirthdayParty(QObject *parent = 0); @@ -73,7 +73,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/attached/main.cpp b/examples/declarative/extending/attached/main.cpp index 27a9287..684d8d3 100644 --- a/examples/declarative/extending/attached/main.cpp +++ b/examples/declarative/extending/attached/main.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ #include <QCoreApplication> -#include <QmlEngine> -#include <QmlComponent> +#include <QDeclarativeEngine> +#include <QDeclarativeComponent> #include <QDebug> #include "birthdayparty.h" #include "person.h" @@ -49,8 +49,15 @@ 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_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/attached/person.cpp b/examples/declarative/extending/attached/person.cpp index 909505a..0a9e508 100644 --- a/examples/declarative/extending/attached/person.cpp +++ b/examples/declarative/extending/attached/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/attached/person.h b/examples/declarative/extending/attached/person.h index dd03091..0f86d8b 100644 --- a/examples/declarative/extending/attached/person.h +++ b/examples/declarative/extending/attached/person.h @@ -43,7 +43,7 @@ #include <QObject> #include <QColor> -#include <qml.h> +#include <qdeclarative.h> class ShoeDescription : public QObject { Q_OBJECT diff --git a/examples/declarative/extending/binding/birthdayparty.cpp b/examples/declarative/extending/binding/birthdayparty.cpp index 62b9c7b..e5be2b9 100644 --- a/examples/declarative/extending/binding/birthdayparty.cpp +++ b/examples/declarative/extending/binding/birthdayparty.cpp @@ -58,7 +58,6 @@ void BirthdayPartyAttached::setRsvp(const QDate &d) } } -QML_DEFINE_NOCREATE_TYPE(BirthdayPartyAttached); BirthdayParty::BirthdayParty(QObject *parent) : QObject(parent), m_celebrant(0) @@ -77,9 +76,9 @@ void BirthdayParty::setCelebrant(Person *c) emit celebrantChanged(); } -QmlListProperty<Person> BirthdayParty::guests() +QDeclarativeListProperty<Person> BirthdayParty::guests() { - return QmlListProperty<Person>(this, m_guests); + return QDeclarativeListProperty<Person>(this, m_guests); } int BirthdayParty::guestCount() const @@ -113,4 +112,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) return new BirthdayPartyAttached(object); } -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/binding/birthdayparty.h b/examples/declarative/extending/binding/birthdayparty.h index 8bdb76a..8486442 100644 --- a/examples/declarative/extending/binding/birthdayparty.h +++ b/examples/declarative/extending/binding/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 @@ -71,7 +71,7 @@ Q_OBJECT // ![0] Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant NOTIFY celebrantChanged) // ![0] -Q_PROPERTY(QmlListProperty<Person> guests READ guests) +Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests) Q_PROPERTY(QString speaker READ speaker WRITE setSpeaker) Q_CLASSINFO("DefaultProperty", "guests") public: @@ -80,7 +80,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/binding/happybirthday.cpp b/examples/declarative/extending/binding/happybirthday.cpp index 38f3c08..7d4d021 100644 --- a/examples/declarative/extending/binding/happybirthday.cpp +++ b/examples/declarative/extending/binding/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; } @@ -84,4 +84,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/binding/happybirthday.h b/examples/declarative/extending/binding/happybirthday.h index 852bec7..ee4d1ec 100644 --- a/examples/declarative/extending/binding/happybirthday.h +++ b/examples/declarative/extending/binding/happybirthday.h @@ -41,20 +41,20 @@ #ifndef HAPPYBIRTHDAY_H #define HAPPYBIRTHDAY_H -#include <QmlPropertyValueSource> -#include <QmlMetaProperty> -#include <qml.h> +#include <QDeclarativePropertyValueSource> +#include <QDeclarativeMetaProperty> +#include <qdeclarative.h> #include <QStringList> -class HappyBirthday : public QObject, public QmlPropertyValueSource +class HappyBirthday : public QObject, public QDeclarativePropertyValueSource { Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) public: HappyBirthday(QObject *parent = 0); - virtual void setTarget(const QmlMetaProperty &); + virtual void setTarget(const QDeclarativeMetaProperty &); QString name() const; void setName(const QString &); @@ -67,7 +67,7 @@ signals: private: int m_line; QStringList m_lyrics; - QmlMetaProperty m_target; + QDeclarativeMetaProperty m_target; QString m_name; }; QML_DECLARE_TYPE(HappyBirthday); diff --git a/examples/declarative/extending/binding/main.cpp b/examples/declarative/extending/binding/main.cpp index ba38e82..873f8c9 100644 --- a/examples/declarative/extending/binding/main.cpp +++ b/examples/declarative/extending/binding/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/binding/person.cpp b/examples/declarative/extending/binding/person.cpp index 50fb754..9a2248f 100644 --- a/examples/declarative/extending/binding/person.cpp +++ b/examples/declarative/extending/binding/person.cpp @@ -100,7 +100,6 @@ void ShoeDescription::setPrice(qreal p) m_price = p; emit shoeChanged(); } -QML_DEFINE_NOCREATE_TYPE(ShoeDescription); Person::Person(QObject *parent) : QObject(parent) @@ -126,18 +125,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/binding/person.h b/examples/declarative/extending/binding/person.h index e8aa6a8..1bec71c 100644 --- a/examples/declarative/extending/binding/person.h +++ b/examples/declarative/extending/binding/person.h @@ -43,7 +43,7 @@ #include <QObject> #include <QColor> -#include <qml.h> +#include <qdeclarative.h> class ShoeDescription : public QObject { Q_OBJECT diff --git a/examples/declarative/extending/coercion/birthdayparty.cpp b/examples/declarative/extending/coercion/birthdayparty.cpp index 15a4ca9..523a42d 100644 --- a/examples/declarative/extending/coercion/birthdayparty.cpp +++ b/examples/declarative/extending/coercion/birthdayparty.cpp @@ -55,9 +55,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 @@ -70,4 +70,3 @@ Person *BirthdayParty::guest(int index) const return m_guests.at(index); } -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/coercion/birthdayparty.h b/examples/declarative/extending/coercion/birthdayparty.h index 5a9eb08..fffd407 100644 --- a/examples/declarative/extending/coercion/birthdayparty.h +++ b/examples/declarative/extending/coercion/birthdayparty.h @@ -42,7 +42,7 @@ #define BIRTHDAYPARTY_H #include <QObject> -#include <qml.h> +#include <qdeclarative.h> #include "person.h" class BirthdayParty : public QObject @@ -50,7 +50,7 @@ class BirthdayParty : public QObject Q_OBJECT // ![0] Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant) -Q_PROPERTY(QmlListProperty<Person> guests READ guests) +Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests) // ![0] public: BirthdayParty(QObject *parent = 0); @@ -58,7 +58,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/coercion/main.cpp b/examples/declarative/extending/coercion/main.cpp index ccbee83..1e2209f 100644 --- a/examples/declarative/extending/coercion/main.cpp +++ b/examples/declarative/extending/coercion/main.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ #include <QCoreApplication> -#include <QmlEngine> -#include <QmlComponent> +#include <QDeclarativeEngine> +#include <QDeclarativeComponent> #include <QDebug> #include "birthdayparty.h" #include "person.h" @@ -49,8 +49,15 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QmlEngine engine; - QmlComponent component(&engine, ":example.qml"); + QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); +// ![0] + QML_REGISTER_NOCREATE_TYPE(Person); +// ![0] + 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/coercion/person.cpp b/examples/declarative/extending/coercion/person.cpp index 9eef8f7..5b5203a 100644 --- a/examples/declarative/extending/coercion/person.cpp +++ b/examples/declarative/extending/coercion/person.cpp @@ -65,22 +65,16 @@ void Person::setShoeSize(int s) m_shoeSize = s; } -// ![0] -QML_DEFINE_NOCREATE_TYPE(Person); -// ![0] - // ![1] 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); // ![1] diff --git a/examples/declarative/extending/coercion/person.h b/examples/declarative/extending/coercion/person.h index 9bb9a3d..298ffb1 100644 --- a/examples/declarative/extending/coercion/person.h +++ b/examples/declarative/extending/coercion/person.h @@ -42,7 +42,7 @@ #define PERSON_H #include <QObject> -#include <qml.h> +#include <qdeclarative.h> class Person : public QObject { Q_OBJECT diff --git a/examples/declarative/extending/default/birthdayparty.cpp b/examples/declarative/extending/default/birthdayparty.cpp index 15a4ca9..523a42d 100644 --- a/examples/declarative/extending/default/birthdayparty.cpp +++ b/examples/declarative/extending/default/birthdayparty.cpp @@ -55,9 +55,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 @@ -70,4 +70,3 @@ Person *BirthdayParty::guest(int index) const return m_guests.at(index); } -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/default/birthdayparty.h b/examples/declarative/extending/default/birthdayparty.h index f25f8c2..49c20bd 100644 --- a/examples/declarative/extending/default/birthdayparty.h +++ b/examples/declarative/extending/default/birthdayparty.h @@ -42,7 +42,7 @@ #define BIRTHDAYPARTY_H #include <QObject> -#include <qml.h> +#include <qdeclarative.h> #include "person.h" // ![0] @@ -50,7 +50,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) Q_CLASSINFO("DefaultProperty", "guests") public: BirthdayParty(QObject *parent = 0); @@ -58,7 +58,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/default/main.cpp b/examples/declarative/extending/default/main.cpp index ccbee83..7d7f8a1 100644 --- a/examples/declarative/extending/default/main.cpp +++ b/examples/declarative/extending/default/main.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ #include <QCoreApplication> -#include <QmlEngine> -#include <QmlComponent> +#include <QDeclarativeEngine> +#include <QDeclarativeComponent> #include <QDebug> #include "birthdayparty.h" #include "person.h" @@ -49,8 +49,13 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QmlEngine engine; - QmlComponent component(&engine, ":example.qml"); + QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); + 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/default/person.cpp b/examples/declarative/extending/default/person.cpp index a0b4960..69216d3 100644 --- a/examples/declarative/extending/default/person.cpp +++ b/examples/declarative/extending/default/person.cpp @@ -65,18 +65,15 @@ void Person::setShoeSize(int s) m_shoeSize = s; } -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/default/person.h b/examples/declarative/extending/default/person.h index 884dda3..b3eceaa 100644 --- a/examples/declarative/extending/default/person.h +++ b/examples/declarative/extending/default/person.h @@ -42,7 +42,7 @@ #define PERSON_H #include <QObject> -#include <qml.h> +#include <qdeclarative.h> class Person : public QObject { Q_OBJECT diff --git a/examples/declarative/extending/extended/lineedit.cpp b/examples/declarative/extending/extended/lineedit.cpp index ec86aad..417fbd9 100644 --- a/examples/declarative/extending/extended/lineedit.cpp +++ b/examples/declarative/extending/extended/lineedit.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ #include "lineedit.h" -#include <qml.h> +#include <qdeclarative.h> LineEditExtension::LineEditExtension(QObject *object) : QObject(object), m_lineedit(static_cast<QLineEdit *>(object)) @@ -103,4 +103,3 @@ void LineEditExtension::setBottomMargin(int m) } QML_DECLARE_TYPE(QLineEdit); -QML_DEFINE_EXTENDED_TYPE(People, 1,0, QLineEdit, QLineEdit, LineEditExtension); diff --git a/examples/declarative/extending/extended/main.cpp b/examples/declarative/extending/extended/main.cpp index 9376af7..5cbeea3 100644 --- a/examples/declarative/extending/extended/main.cpp +++ b/examples/declarative/extending/extended/main.cpp @@ -39,17 +39,20 @@ ** ****************************************************************************/ #include <QApplication> -#include <QmlEngine> -#include <QmlComponent> +#include <QDeclarativeEngine> +#include <QDeclarativeComponent> #include <QDebug> #include <QLineEdit> +#include "lineedit.h" int main(int argc, char ** argv) { QApplication app(argc, argv); - QmlEngine engine; - QmlComponent component(&engine, ":example.qml"); + QML_REGISTER_EXTENDED_TYPE(People, 1,0, QLineEdit, QLineEdit, LineEditExtension); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); QLineEdit *edit = qobject_cast<QLineEdit *>(component.create()); if (edit) { diff --git a/examples/declarative/extending/extending.pro b/examples/declarative/extending/extending.pro new file mode 100644 index 0000000..169c7ab --- /dev/null +++ b/examples/declarative/extending/extending.pro @@ -0,0 +1,13 @@ +TEMPLATE = subdirs + +SUBDIRS += \ + adding \ + attached \ + binding \ + coercion \ + default \ + extended \ + grouped \ + properties \ + signal \ + valuesource diff --git a/examples/declarative/extending/grouped/birthdayparty.cpp b/examples/declarative/extending/grouped/birthdayparty.cpp index 15a4ca9..523a42d 100644 --- a/examples/declarative/extending/grouped/birthdayparty.cpp +++ b/examples/declarative/extending/grouped/birthdayparty.cpp @@ -55,9 +55,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 @@ -70,4 +70,3 @@ Person *BirthdayParty::guest(int index) const return m_guests.at(index); } -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/grouped/birthdayparty.h b/examples/declarative/extending/grouped/birthdayparty.h index fd0d955..42439c4 100644 --- a/examples/declarative/extending/grouped/birthdayparty.h +++ b/examples/declarative/extending/grouped/birthdayparty.h @@ -42,14 +42,14 @@ #define BIRTHDAYPARTY_H #include <QObject> -#include <qml.h> +#include <qdeclarative.h> #include "person.h" 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) Q_CLASSINFO("DefaultProperty", "guests") public: BirthdayParty(QObject *parent = 0); @@ -57,7 +57,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/grouped/main.cpp b/examples/declarative/extending/grouped/main.cpp index 79aaab5..15a0bb5 100644 --- a/examples/declarative/extending/grouped/main.cpp +++ b/examples/declarative/extending/grouped/main.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ #include <QCoreApplication> -#include <QmlEngine> -#include <QmlComponent> +#include <QDeclarativeEngine> +#include <QDeclarativeComponent> #include <QDebug> #include "birthdayparty.h" #include "person.h" @@ -49,8 +49,14 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QmlEngine engine; - QmlComponent component(&engine, ":example.qml"); + QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); + 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/grouped/person.cpp b/examples/declarative/extending/grouped/person.cpp index 909505a..0a9e508 100644 --- a/examples/declarative/extending/grouped/person.cpp +++ b/examples/declarative/extending/grouped/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/grouped/person.h b/examples/declarative/extending/grouped/person.h index 89ccedc..5dab378 100644 --- a/examples/declarative/extending/grouped/person.h +++ b/examples/declarative/extending/grouped/person.h @@ -43,7 +43,7 @@ #include <QObject> #include <QColor> -#include <qml.h> +#include <qdeclarative.h> class ShoeDescription : public QObject { Q_OBJECT diff --git a/examples/declarative/extending/properties/birthdayparty.cpp b/examples/declarative/extending/properties/birthdayparty.cpp index 23e6e58..14fd6a3 100644 --- a/examples/declarative/extending/properties/birthdayparty.cpp +++ b/examples/declarative/extending/properties/birthdayparty.cpp @@ -56,9 +56,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 @@ -72,4 +72,3 @@ Person *BirthdayParty::guest(int index) const } // ![0] -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/properties/birthdayparty.h b/examples/declarative/extending/properties/birthdayparty.h index e5d316c..c4cb536 100644 --- a/examples/declarative/extending/properties/birthdayparty.h +++ b/examples/declarative/extending/properties/birthdayparty.h @@ -42,7 +42,7 @@ #define BIRTHDAYPARTY_H #include <QObject> -#include <qml.h> +#include <qdeclarative.h> #include "person.h" // ![0] @@ -54,7 +54,7 @@ Q_OBJECT Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant) // ![1] // ![2] -Q_PROPERTY(QmlListProperty<Person> guests READ guests) +Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests) // ![2] // ![3] public: @@ -63,7 +63,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/properties/main.cpp b/examples/declarative/extending/properties/main.cpp index 97d7905..ce69ad2 100644 --- a/examples/declarative/extending/properties/main.cpp +++ b/examples/declarative/extending/properties/main.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ #include <QCoreApplication> -#include <QmlEngine> -#include <QmlComponent> +#include <QDeclarativeEngine> +#include <QDeclarativeComponent> #include <QDebug> #include "birthdayparty.h" #include "person.h" @@ -49,8 +49,11 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - QmlEngine engine; - QmlComponent component(&engine, ":example.qml"); + QML_REGISTER_TYPE(People, 1,0, BirthdayParty, BirthdayParty); + QML_REGISTER_TYPE(People, 1,0, Person, Person); + + QDeclarativeEngine engine; + QDeclarativeComponent component(&engine, ":example.qml"); BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create()); if (party && party->celebrant()) { diff --git a/examples/declarative/extending/properties/person.cpp b/examples/declarative/extending/properties/person.cpp index d1b8bf4..92c54f5 100644 --- a/examples/declarative/extending/properties/person.cpp +++ b/examples/declarative/extending/properties/person.cpp @@ -65,4 +65,3 @@ void Person::setShoeSize(int s) m_shoeSize = s; } -QML_DEFINE_TYPE(People, 1,0, Person, Person); diff --git a/examples/declarative/extending/properties/person.h b/examples/declarative/extending/properties/person.h index 8d665f0..860a607 100644 --- a/examples/declarative/extending/properties/person.h +++ b/examples/declarative/extending/properties/person.h @@ -42,7 +42,7 @@ #define PERSON_H #include <QObject> -#include <qml.h> +#include <qdeclarative.h> class Person : public QObject { Q_OBJECT diff --git a/examples/declarative/extending/signal/birthdayparty.cpp b/examples/declarative/extending/signal/birthdayparty.cpp index d8686f0..65ff530 100644 --- a/examples/declarative/extending/signal/birthdayparty.cpp +++ b/examples/declarative/extending/signal/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 @@ -98,4 +97,3 @@ BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) return new BirthdayPartyAttached(object); } -QML_DEFINE_TYPE(People, 1,0, BirthdayParty, BirthdayParty); diff --git a/examples/declarative/extending/signal/birthdayparty.h b/examples/declarative/extending/signal/birthdayparty.h index 30ed43b..bcdc513 100644 --- a/examples/declarative/extending/signal/birthdayparty.h +++ b/examples/declarative/extending/signal/birthdayparty.h @@ -43,7 +43,7 @@ #include <QObject> #include <QDate> -#include <qml.h> +#include <qdeclarative.h> #include "person.h" class BirthdayPartyAttached : public QObject @@ -65,7 +65,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) Q_CLASSINFO("DefaultProperty", "guests") public: BirthdayParty(QObject *parent = 0); @@ -73,7 +73,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/signal/main.cpp b/examples/declarative/extending/signal/main.cpp index eb3bb4b..afc1a66 100644 --- a/examples/declarative/extending/signal/main.cpp +++ b/examples/declarative/extending/signal/main.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ #include <QCoreApplication> -#include <QmlEngine> -#include <QmlComponent> +#include <QDeclarativeEngine> +#include <QDeclarativeComponent> #include <QDebug> #include "birthdayparty.h" #include "person.h" @@ -49,8 +49,15 @@ 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_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/signal/person.cpp b/examples/declarative/extending/signal/person.cpp index 909505a..0a9e508 100644 --- a/examples/declarative/extending/signal/person.cpp +++ b/examples/declarative/extending/signal/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/signal/person.h b/examples/declarative/extending/signal/person.h index dd03091..0f86d8b 100644 --- a/examples/declarative/extending/signal/person.h +++ b/examples/declarative/extending/signal/person.h @@ -43,7 +43,7 @@ #include <QObject> #include <QColor> -#include <qml.h> +#include <qdeclarative.h> class ShoeDescription : public QObject { Q_OBJECT 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 diff --git a/examples/declarative/fonts/hello.qml b/examples/declarative/fonts/hello.qml index c682477..fcc9580 100644 --- a/examples/declarative/fonts/hello.qml +++ b/examples/declarative/fonts/hello.qml @@ -11,7 +11,7 @@ Rectangle { font.letterSpacing: SequentialAnimation { repeat: true; - NumberAnimation { from: 100; to: 300; easing: "easeInQuad"; duration: 3000 } + NumberAnimation { from: 100; to: 300; easing.type: "InQuad"; duration: 3000 } ScriptAction { script: { container.y = (screen.height / 4) + (Math.random() * screen.height / 2) container.x = (screen.width / 4) + (Math.random() * screen.width / 2) diff --git a/examples/declarative/imageprovider/main.cpp b/examples/declarative/imageprovider/main.cpp index 9526105..d9d4c1a 100644 --- a/examples/declarative/imageprovider/main.cpp +++ b/examples/declarative/imageprovider/main.cpp @@ -41,22 +41,22 @@ #include <QApplication> -#include <qmlengine.h> -#include <qmlcontext.h> -#include <qml.h> -#include <qmlgraphicsitem.h> -#include <qmlimageprovider.h> -#include <qmlview.h> +#include <qdeclarativeengine.h> +#include <qdeclarativecontext.h> +#include <qdeclarative.h> +#include <qdeclarativeitem.h> +#include <qdeclarativeimageprovider.h> +#include <qdeclarativeview.h> #include <QImage> #include <QPainter> /* - This example illustrates using a QmlImageProvider to serve + This example illustrates using a QDeclarativeImageProvider to serve images asynchronously. */ //![0] -class ColorImageProvider : public QmlImageProvider +class ColorImageProvider : public QDeclarativeImageProvider { public: // This is run in a low priority thread. @@ -74,8 +74,7 @@ int main(int argc, char ** argv) { QApplication app(argc, argv); - QmlView view; - view.setSource(QUrl("qrc:view.qml")); + QDeclarativeView view; view.engine()->addImageProvider("colors", new ColorImageProvider); @@ -88,10 +87,10 @@ int main(int argc, char ** argv) dataList.append("image://colors/purple"); dataList.append("image://colors/yellow"); - QmlContext *ctxt = view.rootContext(); + QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); - view.execute(); + view.setSource(QUrl("qrc:view.qml")); view.show(); return app.exec(); diff --git a/examples/declarative/layouts/Button.qml b/examples/declarative/layouts/Button.qml index 0bdb9fc..7cbf68a 100644 --- a/examples/declarative/layouts/Button.qml +++ b/examples/declarative/layouts/Button.qml @@ -17,6 +17,6 @@ Rectangle { border.color: "black"; color: "steelblue"; radius: 5; width: pix.wid transitions: Transition{ - NumberAnimation { properties:"x,left"; easing:"easeInOutQuad"; duration:200 } + NumberAnimation { properties:"x,left"; easing.type:"InOutQuad"; duration:200 } } } diff --git a/examples/declarative/layouts/positioners.qml b/examples/declarative/layouts/positioners.qml index fefd964..7146702 100644 --- a/examples/declarative/layouts/positioners.qml +++ b/examples/declarative/layouts/positioners.qml @@ -11,12 +11,12 @@ Rectangle { y: 0 move: Transition { NumberAnimation { - properties: "y"; easing: "easeOutBounce" + properties: "y"; easing.type: "OutBounce" } } add: Transition { NumberAnimation { - properties: "y"; easing: "easeOutQuad" + properties: "y"; easing.type: "OutQuad" } } Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } @@ -35,12 +35,12 @@ Rectangle { y: 300 move: Transition { NumberAnimation { - properties: "x"; easing: "easeOutBounce" + properties: "x"; easing.type: "OutBounce" } } add: Transition { NumberAnimation { - properties: "x"; easing: "easeOutQuad" + properties: "x"; easing.type: "OutQuad" } } Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } @@ -101,13 +101,13 @@ Rectangle { move: Transition { NumberAnimation { - properties: "x,y"; easing: "easeOutBounce" + properties: "x,y"; easing.type: "OutBounce" } } add: Transition { NumberAnimation { - properties: "x,y"; easing: "easeOutBounce" + properties: "x,y"; easing.type: "OutBounce" } } @@ -136,13 +136,13 @@ Rectangle { move: Transition { NumberAnimation { - properties: "x,y"; easing: "easeOutBounce" + properties: "x,y"; easing.type: "OutBounce" } } add: Transition { NumberAnimation { - properties: "x,y"; easing: "easeOutBounce" + properties: "x,y"; easing.type: "OutBounce" } } Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml index f848be0..b76a9ab 100644 --- a/examples/declarative/listview/recipes.qml +++ b/examples/declarative/listview/recipes.qml @@ -81,7 +81,7 @@ Rectangle { Flickable { id: flick anchors.top: methodTitle.bottom; anchors.bottom: parent.bottom - width: parent.width; viewportHeight: methodText.height; clip: true + width: parent.width; contentHeight: methodText.height; clip: true Text { id: methodText; text: method; wrap: true; width: details.width } } Image { @@ -114,7 +114,7 @@ Rectangle { // Make the detailed view fill the entire list area PropertyChanges { target: wrapper; height: list.height } // Move the list so that this item is at the top. - PropertyChanges { target: wrapper.ListView.view; explicit: true; viewportY: wrapper.y } + PropertyChanges { target: wrapper.ListView.view; explicit: true; contentY: wrapper.y } // Disallow flicking while we're in detailed view PropertyChanges { target: wrapper.ListView.view; interactive: false } } @@ -124,7 +124,7 @@ Rectangle { ParallelAnimation { ColorAnimation { property: "color"; duration: 500 } NumberAnimation { - duration: 300; properties: "detailsOpacity,x,viewportY,height,width" + duration: 300; properties: "detailsOpacity,x,contentY,height,width" } } } diff --git a/examples/declarative/objectlistmodel/main.cpp b/examples/declarative/objectlistmodel/main.cpp index 9e38bea..b210570 100644 --- a/examples/declarative/objectlistmodel/main.cpp +++ b/examples/declarative/objectlistmodel/main.cpp @@ -41,11 +41,11 @@ #include <QApplication> -#include <qmlengine.h> -#include <qmlcontext.h> -#include <qml.h> -#include <qmlgraphicsitem.h> -#include <qmlview.h> +#include <qdeclarativeengine.h> +#include <qdeclarativecontext.h> +#include <qdeclarative.h> +#include <qdeclarativeitem.h> +#include <qdeclarativeview.h> #include "dataobject.h" @@ -58,8 +58,7 @@ int main(int argc, char ** argv) { QApplication app(argc, argv); - QmlView view; - view.setSource(QUrl("qrc:view.qml")); + QDeclarativeView view; QList<QObject*> dataList; dataList.append(new DataObject("Item 1", "red")); @@ -67,10 +66,10 @@ int main(int argc, char ** argv) dataList.append(new DataObject("Item 3", "blue")); dataList.append(new DataObject("Item 4", "yellow")); - QmlContext *ctxt = view.rootContext(); + QDeclarativeContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); - view.execute(); + view.setSource(QUrl("qrc:view.qml")); view.show(); return app.exec(); diff --git a/examples/declarative/package/Delegate.qml b/examples/declarative/package/Delegate.qml new file mode 100644 index 0000000..4109633 --- /dev/null +++ b/examples/declarative/package/Delegate.qml @@ -0,0 +1,44 @@ +import Qt 4.6 + +//![0] +Package { + Text { id: listDelegate; width: 200; height: 25; text: "Empty"; Package.name: "list" } + Text { id: gridDelegate; width: 100; height: 50; text: "Empty"; Package.name: "grid" } + + Rectangle { + id: wrapper + width: 200; height: 25 + color: "lightsteelblue" + Text { text: display; anchors.centerIn: parent } + MouseRegion { + anchors.fill: parent + onClicked: { + if (wrapper.state == "inList") + wrapper.state = "inGrid"; + else + wrapper.state = "inList"; + } + } + state: "inList" + states: [ + State { + name: 'inList' + ParentChange { target: wrapper; parent: listDelegate } + }, + State { + name: 'inGrid' + ParentChange { target: wrapper; parent: gridDelegate } + PropertyChanges { target: wrapper; x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height } + } + ] + transitions: [ + Transition { + SequentialAnimation { + ParentAction { target: wrapper } + NumberAnimation { targets: wrapper; properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } +} +//![0] diff --git a/examples/declarative/package/view.qml b/examples/declarative/package/view.qml new file mode 100644 index 0000000..07bba0c --- /dev/null +++ b/examples/declarative/package/view.qml @@ -0,0 +1,35 @@ +import Qt 4.6 + +Item { + width: 400 + height: 200 + + ListModel { + id: myModel + ListElement { display: "One" } + ListElement { display: "Two" } + ListElement { display: "Three" } + ListElement { display: "Four" } + ListElement { display: "Five" } + ListElement { display: "Six" } + ListElement { display: "Seven" } + ListElement { display: "Eight" } + } + //![0] + VisualDataModel { + id: visualModel + delegate: Delegate {} + model: myModel + } + + ListView { + width: 200; height:200 + model: visualModel.parts.list + } + GridView { + x: 200; width: 200; height:200 + cellHeight: 50 + model: visualModel.parts.grid + } + //![0] +} diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml index 811891b..5e58100 100644 --- a/examples/declarative/parallax/qml/ParallaxView.qml +++ b/examples/declarative/parallax/qml/ParallaxView.qml @@ -10,8 +10,8 @@ Item { Image { id: background fillMode: Image.TileHorizontally - x: -list.viewportX / 2 - width: Math.max(list.viewportWidth, parent.width) + x: -list.contentX / 2 + width: Math.max(list.contentWidth, parent.width) } ListView { diff --git a/examples/declarative/parallax/qml/Smiley.qml b/examples/declarative/parallax/qml/Smiley.qml index fc5b4fe..81eadda 100644 --- a/examples/declarative/parallax/qml/Smiley.qml +++ b/examples/declarative/parallax/qml/Smiley.qml @@ -27,16 +27,16 @@ Item { y: SequentialAnimation { repeat: true - // Move from minHeight to maxHeight in 300ms, using the easeOutExpo easing function + // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function NumberAnimation { from: smiley.minHeight; to: smiley.maxHeight - easing: "easeOutExpo"; duration: 300 + easing.type: "OutExpo"; duration: 300 } - // Then move back to minHeight in 1 second, using the easeOutBounce easing function + // Then move back to minHeight in 1 second, using the OutBounce easing function NumberAnimation { from: smiley.maxHeight; to: smiley.minHeight - easing: "easeOutBounce"; duration: 1000 + easing.type: "OutBounce"; duration: 1000 } // Then pause for 500ms diff --git a/examples/declarative/plugins/files/Clock.qml b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml index 01ec686..01ec686 100644 --- a/examples/declarative/plugins/files/Clock.qml +++ b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml diff --git a/examples/declarative/plugins/files/center.png b/examples/declarative/plugins/com/nokia/TimeExample/center.png Binary files differindex 7fbd802..7fbd802 100644 --- a/examples/declarative/plugins/files/center.png +++ b/examples/declarative/plugins/com/nokia/TimeExample/center.png diff --git a/examples/declarative/plugins/files/clock.png b/examples/declarative/plugins/com/nokia/TimeExample/clock.png Binary files differindex 462edac..462edac 100644 --- a/examples/declarative/plugins/files/clock.png +++ b/examples/declarative/plugins/com/nokia/TimeExample/clock.png diff --git a/examples/declarative/plugins/files/hour.png b/examples/declarative/plugins/com/nokia/TimeExample/hour.png Binary files differindex f8061a1..f8061a1 100644 --- a/examples/declarative/plugins/files/hour.png +++ b/examples/declarative/plugins/com/nokia/TimeExample/hour.png diff --git a/examples/declarative/plugins/files/minute.png b/examples/declarative/plugins/com/nokia/TimeExample/minute.png Binary files differindex 1297ec7..1297ec7 100644 --- a/examples/declarative/plugins/files/minute.png +++ b/examples/declarative/plugins/com/nokia/TimeExample/minute.png diff --git a/examples/declarative/plugins/com/nokia/TimeExample/qmldir b/examples/declarative/plugins/com/nokia/TimeExample/qmldir new file mode 100644 index 0000000..e9ef115 --- /dev/null +++ b/examples/declarative/plugins/com/nokia/TimeExample/qmldir @@ -0,0 +1,2 @@ +Clock 1.0 Clock.qml +plugin qtimeexampleqmlplugin diff --git a/examples/declarative/plugins/plugin.cpp b/examples/declarative/plugins/plugin.cpp index 820d4eb..741f68a 100644 --- a/examples/declarative/plugins/plugin.cpp +++ b/examples/declarative/plugins/plugin.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include <QtDeclarative/qmlmoduleplugin.h> -#include <QtDeclarative/qml.h> +#include <QtDeclarative/QDeclarativeExtensionPlugin> +#include <QtDeclarative/qdeclarative.h> #include <qdebug.h> #include <qdatetime.h> #include <qbasictimer.h> @@ -140,19 +140,14 @@ MinuteTimer *Time::timer=0; QML_DECLARE_TYPE(Time); -class QExampleQmlPlugin : public QmlModulePlugin +class QExampleQmlPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT public: - QStringList keys() const - { - return QStringList() << QLatin1String("com.nokia.TimeExample"); - } - - void defineModule(const QString& uri) + void registerTypes(const char *uri) { Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); - qmlRegisterType<Time>("com.nokia.TimeExample", 1, 0, "Time", "Time"); + qmlRegisterType<Time>(uri, 1, 0, "Time"); } }; diff --git a/examples/declarative/plugins/plugins.pro b/examples/declarative/plugins/plugins.pro index 84ab8da..c925cea 100644 --- a/examples/declarative/plugins/plugins.pro +++ b/examples/declarative/plugins/plugins.pro @@ -1,15 +1,27 @@ TEMPLATE = lib +DESTDIR = com/nokia/TimeExample TARGET = qtimeexampleqmlplugin CONFIG += qt plugin QT += declarative +VERSION = 1.0.0 SOURCES += plugin.cpp -target.path += $$[QT_INSTALL_PLUGINS]/qmlmodules -sources.files += files/Clock.qml files/qmldir files/background.png files/center.png files/clock-night.png files/clock.png files/hour.png files/minute.png -sources.path += $$[QT_INSTALL_DATA]/qml/com/nokia/TimeExample -INSTALLS += target sources +qdeclarativesources.files += \ + com/nokia/TimeExample/qdeclarativedir \ + com/nokia/TimeExample/center.png \ + com/nokia/TimeExample/clock.png \ + com/nokia/TimeExample/Clock.qml \ + com/nokia/TimeExample/hour.png \ + com/nokia/TimeExample/minute.png +qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample -VERSION=1.0.0 +sources.files += plugins.pro plugin.cpp plugins.qml +sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins +target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample + +INSTALLS += qdeclarativesources sources target + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) diff --git a/examples/declarative/plugins/plugins.qml b/examples/declarative/plugins/plugins.qml index dbeb001..44b552b 100644 --- a/examples/declarative/plugins/plugins.qml +++ b/examples/declarative/plugins/plugins.qml @@ -1,5 +1,4 @@ import com.nokia.TimeExample 1.0 // import types from the plugin -import 'files' // import types from the 'files' directory Clock { // this class is defined in QML (files/Clock.qml) diff --git a/examples/declarative/progressbar/progressbars.qml b/examples/declarative/progressbar/progressbars.qml index fdd4ca7..6530c3d 100644 --- a/examples/declarative/progressbar/progressbars.qml +++ b/examples/declarative/progressbar/progressbars.qml @@ -6,7 +6,7 @@ Rectangle { width: 600; height: 405; color: "#edecec" Flickable { - anchors.fill: parent; viewportHeight: column.height + 20 + anchors.fill: parent; contentHeight: column.height + 20 Column { id: column; x: 10; y: 10; spacing: 10 Repeater { diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml index 536a8b7..84763d2 100644 --- a/examples/declarative/scrollbar/display.qml +++ b/examples/declarative/scrollbar/display.qml @@ -10,9 +10,10 @@ Rectangle { Image { id: picture source: "pics/niagara_falls.jpg" + asynchronous: true } - viewportWidth: picture.width - viewportHeight: picture.height + contentWidth: picture.width + contentHeight: picture.height // Only show the scrollbars when the view is moving. states: [ State { diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml index 930f471..758aee6 100644 --- a/examples/declarative/slideswitch/content/Switch.qml +++ b/examples/declarative/slideswitch/content/Switch.qml @@ -66,7 +66,7 @@ Item { //![7] transitions: Transition { - NumberAnimation { properties: "x"; easing: "easeInOutQuad"; duration: 200 } + NumberAnimation { properties: "x"; easing.type: "InOutQuad"; duration: 200 } } //![7] } diff --git a/examples/declarative/sql/hello.qml b/examples/declarative/sql/hello.qml index 96e0675..277dfeb 100644 --- a/examples/declarative/sql/hello.qml +++ b/examples/declarative/sql/hello.qml @@ -3,7 +3,7 @@ import Qt 4.6 Text { Script { function findGreetings() { - var db = openDatabaseSync("QmlExampleDB", "1.0", "The Example QML SQL!", 1000000); + var db = openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000); db.transaction( function(tx) { diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml index 48d5f60..8ad61ad 100644 --- a/examples/declarative/states/transitions.qml +++ b/examples/declarative/states/transitions.qml @@ -51,16 +51,16 @@ Rectangle { // transitions define how the properties change. transitions: [ // When transitioning to 'Position1' move x,y over a duration of 1 second, - // with easeOutBounce easing function. + // with OutBounce easing function. Transition { from: "*"; to: "Position1" - NumberAnimation { properties: "x,y"; easing: "easeOutBounce"; duration: 1000 } + NumberAnimation { properties: "x,y"; easing.type: "OutBounce"; duration: 1000 } }, // When transitioning to 'Position2' move x,y over a duration of 2 seconds, - // with easeInOutQuad easing function. + // with InOutQuad easing function. Transition { from: "*"; to: "Position2" - NumberAnimation { properties: "x,y"; easing: "easeInOutQuad"; duration: 2000 } + NumberAnimation { properties: "x,y"; easing.type: "InOutQuad"; duration: 2000 } }, // For any other state changes move x,y linearly over duration of 200ms. Transition { diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml index 9eaa009..b8a4f77 100644 --- a/examples/declarative/tutorials/helloworld/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/tutorial3.qml @@ -28,7 +28,7 @@ Rectangle { transitions: Transition { from: ""; to: "down"; reversible: true ParallelAnimation { - NumberAnimation { properties: "y,rotation"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: "InOutQuad" } ColorAnimation { duration: 500 } } } diff --git a/examples/declarative/velocity/velocity.qml b/examples/declarative/velocity/velocity.qml index 50d69d8..0d1881e 100644 --- a/examples/declarative/velocity/velocity.qml +++ b/examples/declarative/velocity/velocity.qml @@ -96,7 +96,7 @@ Rectangle { } Flickable { id: flickable - anchors.fill: parent; viewportWidth: lay.width + anchors.fill: parent; contentWidth: lay.width Row { id: lay Repeater { diff --git a/examples/declarative/webview/qml-in-html.qml b/examples/declarative/webview/qdeclarative-in-html.qml index a2f2f2a..77180ec 100644 --- a/examples/declarative/webview/qml-in-html.qml +++ b/examples/declarative/webview/qdeclarative-in-html.qml @@ -6,8 +6,8 @@ Rectangle { Flickable { width: parent.width height: parent.height/2 - viewportWidth: web.width*web.scale - viewportHeight: web.height*web.scale + contentWidth: web.width*web.scale + contentHeight: web.height*web.scale WebView { id: web width: 250 diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml index b80e29c..f7c269c 100644 --- a/examples/declarative/xmldata/yahoonews.qml +++ b/examples/declarative/xmldata/yahoonews.qml @@ -61,7 +61,7 @@ Rectangle { transitions: Transition { from: "*"; to: "Details"; reversible: true SequentialAnimation { - NumberAnimation { duration: 200; properties: "height"; easing: "easeOutQuad" } + NumberAnimation { duration: 200; properties: "height"; easing.type: "OutQuad" } NumberAnimation { duration: 200; properties: "opacity" } } } diff --git a/examples/network/http/httpwindow.cpp b/examples/network/http/httpwindow.cpp index 95fc82f..ec7cd33 100644 --- a/examples/network/http/httpwindow.cpp +++ b/examples/network/http/httpwindow.cpp @@ -49,9 +49,9 @@ HttpWindow::HttpWindow(QWidget *parent) : QDialog(parent) { #ifndef QT_NO_OPENSSL - urlLineEdit = new QLineEdit("https://"); + urlLineEdit = new QLineEdit("https://qt.nokia.com/"); #else - urlLineEdit = new QLineEdit("http://"); + urlLineEdit = new QLineEdit("http://qt.nokia.com/"); #endif urlLabel = new QLabel(tr("&URL:")); @@ -70,21 +70,14 @@ HttpWindow::HttpWindow(QWidget *parent) progressDialog = new QProgressDialog(this); - http = new QHttp(this); - connect(urlLineEdit, SIGNAL(textChanged(QString)), this, SLOT(enableDownloadButton())); - connect(http, SIGNAL(requestFinished(int,bool)), - this, SLOT(httpRequestFinished(int,bool))); - connect(http, SIGNAL(dataReadProgress(int,int)), - this, SLOT(updateDataReadProgress(int,int))); - connect(http, SIGNAL(responseHeaderReceived(QHttpResponseHeader)), - this, SLOT(readResponseHeader(QHttpResponseHeader))); - connect(http, SIGNAL(authenticationRequired(QString,quint16,QAuthenticator*)), - this, SLOT(slotAuthenticationRequired(QString,quint16,QAuthenticator*))); + + connect(&qnam, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), + this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*))); #ifndef QT_NO_OPENSSL - connect(http, SIGNAL(sslErrors(QList<QSslError>)), - this, SLOT(sslErrors(QList<QSslError>))); + connect(&qnam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), + this, SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); #endif connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload())); connect(downloadButton, SIGNAL(clicked()), this, SLOT(downloadFile())); @@ -104,9 +97,21 @@ HttpWindow::HttpWindow(QWidget *parent) urlLineEdit->setFocus(); } +void HttpWindow::startRequest(QUrl url) +{ + reply = qnam.get(QNetworkRequest(url)); + connect(reply, SIGNAL(finished()), + this, SLOT(httpFinished())); + connect(reply, SIGNAL(readyRead()), + this, SLOT(httpReadyRead())); + connect(reply, SIGNAL(downloadProgress(qint64,qint64)), + this, SLOT(updateDataReadProgress(qint64,qint64))); +} + void HttpWindow::downloadFile() { - QUrl url(urlLineEdit->text()); + url = urlLineEdit->text(); + QFileInfo fileInfo(url.path()); QString fileName = fileInfo.fileName(); if (fileName.isEmpty()) @@ -132,35 +137,26 @@ void HttpWindow::downloadFile() return; } - QHttp::ConnectionMode mode = url.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp; - http->setHost(url.host(), mode, url.port() == -1 ? 0 : url.port()); - - if (!url.userName().isEmpty()) - http->setUser(url.userName(), url.password()); - - httpRequestAborted = false; - QByteArray path = QUrl::toPercentEncoding(url.path(), "!$&'()*+,;=:@/"); - if (path.isEmpty()) - path = "/"; - httpGetId = http->get(path, file); progressDialog->setWindowTitle(tr("HTTP")); progressDialog->setLabelText(tr("Downloading %1.").arg(fileName)); downloadButton->setEnabled(false); + + // schedule the request + httpRequestAborted = false; + startRequest(url); } void HttpWindow::cancelDownload() { statusLabel->setText(tr("Download canceled.")); httpRequestAborted = true; - http->abort(); + reply->abort(); downloadButton->setEnabled(true); } -void HttpWindow::httpRequestFinished(int requestId, bool error) +void HttpWindow::httpFinished() { - if (requestId != httpGetId) - return; if (httpRequestAborted) { if (file) { file->close(); @@ -168,54 +164,58 @@ void HttpWindow::httpRequestFinished(int requestId, bool error) delete file; file = 0; } - + reply->deleteLater(); progressDialog->hide(); return; } - if (requestId != httpGetId) - return; - progressDialog->hide(); + file->flush(); file->close(); - if (error) { + + QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (reply->error()) { file->remove(); QMessageBox::information(this, tr("HTTP"), tr("Download failed: %1.") - .arg(http->errorString())); + .arg(reply->errorString())); + downloadButton->setEnabled(true); + } else if (!redirectionTarget.isNull()) { + QUrl newUrl = url.resolved(redirectionTarget.toUrl()); + if (QMessageBox::question(this, tr("HTTP"), + tr("Redirect to %1 ?").arg(newUrl.toString()), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + url = newUrl; + reply->deleteLater(); + file->open(QIODevice::WriteOnly); + file->resize(0); + startRequest(url); + return; + } } else { QString fileName = QFileInfo(QUrl(urlLineEdit->text()).path()).fileName(); statusLabel->setText(tr("Downloaded %1 to current directory.").arg(fileName)); + downloadButton->setEnabled(true); } - downloadButton->setEnabled(true); + reply->deleteLater(); + reply = 0; delete file; file = 0; } -void HttpWindow::readResponseHeader(const QHttpResponseHeader &responseHeader) +void HttpWindow::httpReadyRead() { - switch (responseHeader.statusCode()) { - case 200: // Ok - case 301: // Moved Permanently - case 302: // Found - case 303: // See Other - case 307: // Temporary Redirect - // these are not error conditions - break; - - default: - QMessageBox::information(this, tr("HTTP"), - tr("Download failed: %1.") - .arg(responseHeader.reasonPhrase())); - httpRequestAborted = true; - progressDialog->hide(); - http->abort(); - } + // this slot gets called everytime the QNetworkReply has new data. + // We read all of its new data and write it into the file. + // That way we use less RAM than when reading it at the finished() + // signal of the QNetworkReply + if (file) + file->write(reply->readAll()); } -void HttpWindow::updateDataReadProgress(int bytesRead, int totalBytes) +void HttpWindow::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes) { if (httpRequestAborted) return; @@ -229,14 +229,19 @@ void HttpWindow::enableDownloadButton() downloadButton->setEnabled(!urlLineEdit->text().isEmpty()); } -void HttpWindow::slotAuthenticationRequired(const QString &hostName, quint16, QAuthenticator *authenticator) +void HttpWindow::slotAuthenticationRequired(QNetworkReply*,QAuthenticator *authenticator) { QDialog dlg; Ui::Dialog ui; ui.setupUi(&dlg); dlg.adjustSize(); - ui.siteDescription->setText(tr("%1 at %2").arg(authenticator->realm()).arg(hostName)); - + ui.siteDescription->setText(tr("%1 at %2").arg(authenticator->realm()).arg(url.host())); + + // Did the URL have information? Fill the UI + // This is only relevant if the URL-supplied credentials were wrong + ui.userEdit->setText(url.userName()); + ui.passwordEdit->setText(url.password()); + if (dlg.exec() == QDialog::Accepted) { authenticator->setUser(ui.userEdit->text()); authenticator->setPassword(ui.passwordEdit->text()); @@ -244,7 +249,7 @@ void HttpWindow::slotAuthenticationRequired(const QString &hostName, quint16, QA } #ifndef QT_NO_OPENSSL -void HttpWindow::sslErrors(const QList<QSslError> &errors) +void HttpWindow::sslErrors(QNetworkReply*,const QList<QSslError> &errors) { QString errorString; foreach (const QSslError &error, errors) { @@ -253,10 +258,10 @@ void HttpWindow::sslErrors(const QList<QSslError> &errors) errorString += error.errorString(); } - if (QMessageBox::warning(this, tr("HTTP Example"), + if (QMessageBox::warning(this, tr("HTTP"), tr("One or more SSL errors has occurred: %1").arg(errorString), QMessageBox::Ignore | QMessageBox::Abort) == QMessageBox::Ignore) { - http->ignoreSslErrors(); + reply->ignoreSslErrors(); } } #endif diff --git a/examples/network/http/httpwindow.h b/examples/network/http/httpwindow.h index 9dca8a5..83898af 100644 --- a/examples/network/http/httpwindow.h +++ b/examples/network/http/httpwindow.h @@ -43,18 +43,21 @@ #define HTTPWINDOW_H #include <QDialog> +#include <QNetworkAccessManager> +#include <QUrl> QT_BEGIN_NAMESPACE class QDialogButtonBox; class QFile; -class QHttp; -class QHttpResponseHeader; class QLabel; class QLineEdit; class QProgressDialog; class QPushButton; class QSslError; class QAuthenticator; +class QNetworkReply; + + QT_END_NAMESPACE class HttpWindow : public QDialog @@ -64,16 +67,18 @@ class HttpWindow : public QDialog public: HttpWindow(QWidget *parent = 0); + void startRequest(QUrl url); + private slots: void downloadFile(); void cancelDownload(); - void httpRequestFinished(int requestId, bool error); - void readResponseHeader(const QHttpResponseHeader &responseHeader); - void updateDataReadProgress(int bytesRead, int totalBytes); + void httpFinished(); + void httpReadyRead(); + void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes); void enableDownloadButton(); - void slotAuthenticationRequired(const QString &, quint16, QAuthenticator *); + void slotAuthenticationRequired(QNetworkReply*,QAuthenticator *); #ifndef QT_NO_OPENSSL - void sslErrors(const QList<QSslError> &errors); + void sslErrors(QNetworkReply*,const QList<QSslError> &errors); #endif private: @@ -85,7 +90,9 @@ private: QPushButton *quitButton; QDialogButtonBox *buttonBox; - QHttp *http; + QUrl url; + QNetworkAccessManager qnam; + QNetworkReply *reply; QFile *file; int httpGetId; bool httpRequestAborted; diff --git a/examples/network/http/main.cpp b/examples/network/http/main.cpp index ecbe100..817b2be 100644 --- a/examples/network/http/main.cpp +++ b/examples/network/http/main.cpp @@ -46,7 +46,6 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - qWarning("The usage of QHttp is not recommended anymore, please use QNetworkAccessManager."); HttpWindow httpWin; httpWin.show(); return httpWin.exec(); diff --git a/examples/network/loopback/dialog.cpp b/examples/network/loopback/dialog.cpp index 27cff31..b504e36 100644 --- a/examples/network/loopback/dialog.cpp +++ b/examples/network/loopback/dialog.cpp @@ -44,12 +44,12 @@ #include "dialog.h" -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) static const int TotalBytes = 50 * 1024 * 1024; #else static const int TotalBytes = 5 * 1024 * 1024; #endif -static const int PayloadSize = 65536; +static const int PayloadSize = 64 * 1024; // 64 KB Dialog::Dialog(QWidget *parent) : QDialog(parent) @@ -130,6 +130,7 @@ void Dialog::acceptConnection() void Dialog::startTransfer() { + // called when the TCP client connected to the loopback server bytesToWrite = TotalBytes - (int)tcpClient.write(QByteArray(PayloadSize, '@')); clientStatusLabel->setText(tr("Connected")); } @@ -155,8 +156,11 @@ void Dialog::updateServerProgress() void Dialog::updateClientProgress(qint64 numBytes) { + // callen when the TCP client has written some bytes bytesWritten += (int)numBytes; - if (bytesToWrite > 0) + + // only write more if not finished and when the Qt write buffer is below a certain size. + if (bytesToWrite > 0 && tcpClient.bytesToWrite() <= 4*PayloadSize) bytesToWrite -= (int)tcpClient.write(QByteArray(qMin(bytesToWrite, PayloadSize), '@')); clientProgressBar->setMaximum(TotalBytes); |