diff options
author | Peter Yard <peter.yard@nokia.com> | 2010-04-27 00:39:42 (GMT) |
---|---|---|
committer | Peter Yard <peter.yard@nokia.com> | 2010-04-27 00:39:42 (GMT) |
commit | 88b2bf18c558d0e2f8a9268802f277212f17e61e (patch) | |
tree | d41ca52003037fba9b45605aa6d2ed86f73b940a /examples | |
parent | 4f3a7b5992b5aed67cced46d5d8c8c2f052dfb66 (diff) | |
parent | 09293f1d07b019dc7bfe95afb93364cc87774e82 (diff) | |
download | Qt-88b2bf18c558d0e2f8a9268802f277212f17e61e.zip Qt-88b2bf18c558d0e2f8a9268802f277212f17e61e.tar.gz Qt-88b2bf18c558d0e2f8a9268802f277212f17e61e.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Diffstat (limited to 'examples')
136 files changed, 1257 insertions, 539 deletions
diff --git a/examples/declarative/animations/animations.qmlproject b/examples/declarative/animations/animations.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/animations/animations.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/aspectratio/aspectratio.qmlproject b/examples/declarative/aspectratio/aspectratio.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/aspectratio/aspectratio.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/behaviors/behaviors.qmlproject b/examples/declarative/behaviors/behaviors.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/behaviors/behaviors.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/border-image/border-image.qmlproject b/examples/declarative/border-image/border-image.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/border-image/border-image.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/clocks/clocks.qmlproject b/examples/declarative/clocks/clocks.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/clocks/clocks.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/connections/connections.qmlproject b/examples/declarative/connections/connections.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/connections/connections.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro index 98ea6c4..e37c3d4 100644 --- a/examples/declarative/declarative.pro +++ b/examples/declarative/declarative.pro @@ -5,6 +5,7 @@ SUBDIRS = \ extending \ imageprovider \ objectlistmodel \ + stringlistmodel \ plugins \ proxywidgets diff --git a/examples/declarative/dial/dial.qmlproject b/examples/declarative/dial/dial.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/dial/dial.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml index eea528f..0e6e197 100644 --- a/examples/declarative/dynamic/dynamic.qml +++ b/examples/declarative/dynamic/dynamic.qml @@ -7,6 +7,34 @@ Item { //This is a desktop-sized example width: 1024; height: 512 property int activeSuns: 0 + + //This is the message that pops up when there's an error + Rectangle{ + id: dialog + opacity: 0 + anchors.centerIn: parent + width: dialogText.width + 6 + height: dialogText.height + 6 + border.color: 'black' + color: 'lightsteelblue' + z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. + function show(str){ + dialogText.text = str; + dialogAnim.start(); + } + Text{ + id: dialogText + x:3 + y:3 + font.pixelSize: 14 + } + SequentialAnimation{ + id: dialogAnim + NumberAnimation{target: dialog; property:"opacity"; to: 1; duration: 1000} + PauseAnimation{duration: 5000} + NumberAnimation{target: dialog; property:"opacity"; to: 0; duration: 1000} + } + } // sky Rectangle { id: sky @@ -114,7 +142,14 @@ Item { } Button { text: "Create" - onClicked: createQmlObject(qmlText.text, window, 'CustomObject'); + function makeCustom() { + try{ + Qt.createQmlObject(qmlText.text, window, 'CustomObject'); + }catch(err){ + dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message ); + } + } + onClicked: makeCustom(); } } } diff --git a/examples/declarative/dynamic/dynamic.qmlproject b/examples/declarative/dynamic/dynamic.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/dynamic/dynamic.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/dynamic/qml/itemCreation.js b/examples/declarative/dynamic/qml/itemCreation.js index ccc03aa..4fa0d9f 100644 --- a/examples/declarative/dynamic/qml/itemCreation.js +++ b/examples/declarative/dynamic/qml/itemCreation.js @@ -31,7 +31,7 @@ function loadComponent() { if (itemComponent != null) //Already loaded the component createItem(); - itemComponent = createComponent(itemButton.file); + itemComponent = Qt.createComponent(itemButton.file); //print(itemButton.file) if(itemComponent.isLoading){ component.statusChanged.connect(finishCreation); diff --git a/examples/declarative/effects/effects.qml b/examples/declarative/effects/effects.qml deleted file mode 100644 index feb7c69..0000000 --- a/examples/declarative/effects/effects.qml +++ /dev/null @@ -1,65 +0,0 @@ -import Qt 4.7 - -Rectangle { - width: 400; height: 200 - - Image { - id: blur - x: 5 - source: "pic.png" - - effect: Blur { - NumberAnimation on blurRadius { - id: blurEffect - running: false - from: 0; to: 10 - duration: 1000 - loops: Animation.Infinite - } - } - - MouseArea { anchors.fill: parent; onClicked: blurEffect.running = !blurEffect.running } - } - - Text { text: "Blur"; anchors.top: blur.bottom; anchors.horizontalCenter: blur.horizontalCenter } - - Image { - id: dropShadow - source: "pic.png" - x: 135 - - effect: DropShadow { - blurRadius: 3 - offset.x: 3 - - NumberAnimation on offset.y { - id: dropShadowEffect - from: 0; to: 10 - duration: 1000 - running: false - loops: Animation.Infinite - } - } - - MouseArea { anchors.fill: parent; onClicked: dropShadowEffect.running = !dropShadowEffect.running } - } - - Image { - id: colorize - source: "pic.png" - x: 265 - - effect: Colorize { color: "blue" } - } - - Text { text: "Colorize"; anchors.top: colorize.bottom; anchors.horizontalCenter: colorize.horizontalCenter } - - Text { text: "Drop Shadow"; anchors.top: dropShadow.bottom; anchors.horizontalCenter: dropShadow.horizontalCenter } - - Text { - y: 155; anchors.horizontalCenter: parent.horizontalCenter - text: "Clicking Blur or Drop Shadow will \ntoggle animation." - color: "black" - } - -} diff --git a/examples/declarative/effects/pic.png b/examples/declarative/effects/pic.png Binary files differdeleted file mode 100644 index 051e738..0000000 --- a/examples/declarative/effects/pic.png +++ /dev/null diff --git a/examples/declarative/examples.qmlproject b/examples/declarative/examples.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/examples.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/extending/adding/example.qml b/examples/declarative/extending/adding/example.qml index c608f94..dc891e7 100644 --- a/examples/declarative/extending/adding/example.qml +++ b/examples/declarative/extending/adding/example.qml @@ -1,6 +1,6 @@ +// ![0] import People 1.0 -// ![0] Person { name: "Bob Jones" shoeSize: 12 diff --git a/examples/declarative/extending/adding/main.cpp b/examples/declarative/extending/adding/main.cpp index b9e5aa3..7b33895 100644 --- a/examples/declarative/extending/adding/main.cpp +++ b/examples/declarative/extending/adding/main.cpp @@ -47,8 +47,9 @@ int main(int argc, char ** argv) { QCoreApplication app(argc, argv); - +//![0] qmlRegisterType<Person>("People", 1,0, "Person"); +//![0] QDeclarativeEngine engine; QDeclarativeComponent component(&engine, ":example.qml"); diff --git a/examples/declarative/extending/adding/person.h b/examples/declarative/extending/adding/person.h index fbaf2df..d6de9a9 100644 --- a/examples/declarative/extending/adding/person.h +++ b/examples/declarative/extending/adding/person.h @@ -43,12 +43,11 @@ #include <QObject> // ![0] -#include <qdeclarative.h> - -class Person : public QObject { -Q_OBJECT -Q_PROPERTY(QString name READ name WRITE setName) -Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) public: Person(QObject *parent = 0); @@ -57,11 +56,11 @@ public: int shoeSize() const; void setShoeSize(int); + private: QString m_name; int m_shoeSize; }; -QML_DECLARE_TYPE(Person); // ![0] #endif // PERSON_H 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 diff --git a/examples/declarative/extending/binding/binding.pro b/examples/declarative/extending/binding/binding.pro index 903712e..896ce25 100644 --- a/examples/declarative/extending/binding/binding.pro +++ b/examples/declarative/extending/binding/binding.pro @@ -8,10 +8,10 @@ QT += declarative SOURCES += main.cpp \ person.cpp \ birthdayparty.cpp \ - happybirthday.cpp + happybirthdaysong.cpp HEADERS += person.h \ birthdayparty.h \ - happybirthday.h + happybirthdaysong.h RESOURCES += binding.qrc target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/binding sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS binding.pro diff --git a/examples/declarative/extending/binding/birthdayparty.cpp b/examples/declarative/extending/binding/birthdayparty.cpp index e5be2b9..000bb1f 100644 --- a/examples/declarative/extending/binding/birthdayparty.cpp +++ b/examples/declarative/extending/binding/birthdayparty.cpp @@ -60,20 +60,20 @@ 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) { - if (c == m_celebrant) return; - m_celebrant = c; - emit celebrantChanged(); + if (c == m_host) return; + m_host = c; + emit hostChanged(); } QDeclarativeListProperty<Person> BirthdayParty::guests() @@ -97,12 +97,12 @@ void BirthdayParty::startParty() emit partyStarted(time); } -QString BirthdayParty::speaker() const +QString BirthdayParty::announcement() const { return QString(); } -void BirthdayParty::setSpeaker(const QString &speak) +void BirthdayParty::setAnnouncement(const QString &speak) { qWarning() << qPrintable(speak); } diff --git a/examples/declarative/extending/binding/birthdayparty.h b/examples/declarative/extending/binding/birthdayparty.h index 8486442..c3f033e 100644 --- a/examples/declarative/extending/binding/birthdayparty.h +++ b/examples/declarative/extending/binding/birthdayparty.h @@ -49,8 +49,8 @@ class BirthdayPartyAttached : public QObject { -Q_OBJECT -Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged) + Q_OBJECT + Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged) public: BirthdayPartyAttached(QObject *object); @@ -63,43 +63,41 @@ signals: private: QDate m_rsvp; }; -QML_DECLARE_TYPE(BirthdayPartyAttached) class BirthdayParty : public QObject { -Q_OBJECT + Q_OBJECT // ![0] -Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant NOTIFY celebrantChanged) + Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged) // ![0] -Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests) -Q_PROPERTY(QString speaker READ speaker WRITE setSpeaker) -Q_CLASSINFO("DefaultProperty", "guests") + Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests) + Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) + 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; Person *guest(int) const; - QString speaker() const; - void setSpeaker(const QString &); + QString announcement() const; + void setAnnouncement(const QString &); static BirthdayPartyAttached *qmlAttachedProperties(QObject *); void startParty(); signals: void partyStarted(const QTime &time); - void celebrantChanged(); + void hostChanged(); 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/binding/example.qml b/examples/declarative/extending/binding/example.qml index b66bc86..82eb3be 100644 --- a/examples/declarative/extending/binding/example.qml +++ b/examples/declarative/extending/binding/example.qml @@ -4,9 +4,9 @@ import People 1.0 BirthdayParty { id: theParty - speaker: HappyBirthday { name: theParty.celebrant.name } + HappyBirthdaySong on announcement { name: theParty.host.name } - celebrant: Boy { + host: Boy { name: "Bob Jones" shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } } @@ -15,7 +15,7 @@ BirthdayParty { Boy { - name: "Joan Hodges" + name: "Leo Hodges" BirthdayParty.rsvp: "2009-07-06" shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } } diff --git a/examples/declarative/extending/binding/happybirthday.cpp b/examples/declarative/extending/binding/happybirthdaysong.cpp index aa5f937..a40e7fb 100644 --- a/examples/declarative/extending/binding/happybirthday.cpp +++ b/examples/declarative/extending/binding/happybirthdaysong.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "happybirthday.h" +#include "happybirthdaysong.h" #include <QTimer> -HappyBirthday::HappyBirthday(QObject *parent) +HappyBirthdaySong::HappyBirthdaySong(QObject *parent) : QObject(parent), m_line(-1) { setName(QString()); @@ -50,17 +50,17 @@ HappyBirthday::HappyBirthday(QObject *parent) timer->start(1000); } -void HappyBirthday::setTarget(const QDeclarativeProperty &p) +void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) { m_target = p; } -QString HappyBirthday::name() const +QString HappyBirthdaySong::name() const { return m_name; } -void HappyBirthday::setName(const QString &name) +void HappyBirthdaySong::setName(const QString &name) { if (m_name == name) return; @@ -77,7 +77,7 @@ void HappyBirthday::setName(const QString &name) emit nameChanged(); } -void HappyBirthday::advance() +void HappyBirthdaySong::advance() { m_line = (m_line + 1) % m_lyrics.count(); diff --git a/examples/declarative/extending/binding/happybirthday.h b/examples/declarative/extending/binding/happybirthdaysong.h index eb2da5e..e825b86 100644 --- a/examples/declarative/extending/binding/happybirthday.h +++ b/examples/declarative/extending/binding/happybirthdaysong.h @@ -38,21 +38,21 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef HAPPYBIRTHDAY_H -#define HAPPYBIRTHDAY_H +#ifndef HAPPYBIRTHDAYSONG_H +#define HAPPYBIRTHDAYSONG_H #include <QDeclarativePropertyValueSource> #include <QDeclarativeProperty> -#include <qdeclarative.h> #include <QStringList> -class HappyBirthday : public QObject, public QDeclarativePropertyValueSource +class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource { -Q_OBJECT -Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + Q_INTERFACES(QDeclarativePropertyValueSource) public: - HappyBirthday(QObject *parent = 0); + HappyBirthdaySong(QObject *parent = 0); virtual void setTarget(const QDeclarativeProperty &); @@ -70,7 +70,6 @@ private: QDeclarativeProperty m_target; QString m_name; }; -QML_DECLARE_TYPE(HappyBirthday); -#endif // HAPPYBIRTHDAY_H +#endif // HAPPYBIRTHDAYSONG_H diff --git a/examples/declarative/extending/binding/main.cpp b/examples/declarative/extending/binding/main.cpp index ce6c50d..2495676 100644 --- a/examples/declarative/extending/binding/main.cpp +++ b/examples/declarative/extending/binding/main.cpp @@ -43,7 +43,7 @@ #include <QDeclarativeComponent> #include <QDebug> #include "birthdayparty.h" -#include "happybirthday.h" +#include "happybirthdaysong.h" #include "person.h" int main(int argc, char ** argv) @@ -51,7 +51,7 @@ int main(int argc, char ** argv) QCoreApplication app(argc, argv); qmlRegisterType<BirthdayPartyAttached>(); qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); - qmlRegisterType<HappyBirthday>("People", 1,0, "HappyBirthday"); + qmlRegisterType<HappyBirthdaySong>("People", 1,0, "HappyBirthdaySong"); qmlRegisterType<ShoeDescription>(); qmlRegisterType<Person>(); qmlRegisterType<Boy>("People", 1,0, "Boy"); @@ -61,10 +61,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/binding/person.h b/examples/declarative/extending/binding/person.h index 2d4ec12..2a68da0 100644 --- a/examples/declarative/extending/binding/person.h +++ b/examples/declarative/extending/binding/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 NOTIFY shoeChanged) -Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY shoeChanged) -Q_PROPERTY(QString brand READ brand WRITE setBrand NOTIFY shoeChanged) -Q_PROPERTY(qreal price READ price WRITE setPrice NOTIFY shoeChanged) +class ShoeDescription : public QObject +{ + Q_OBJECT + Q_PROPERTY(int size READ size WRITE setSize NOTIFY shoeChanged) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY shoeChanged) + Q_PROPERTY(QString brand READ brand WRITE setBrand NOTIFY shoeChanged) + Q_PROPERTY(qreal price READ price WRITE setPrice NOTIFY shoeChanged) public: ShoeDescription(QObject *parent = 0); @@ -74,13 +74,13 @@ 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 NOTIFY nameChanged) +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) // ![0] -Q_PROPERTY(ShoeDescription *shoe READ shoe CONSTANT) + Q_PROPERTY(ShoeDescription *shoe READ shoe CONSTANT) // ![0] public: Person(QObject *parent = 0); @@ -96,20 +96,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 diff --git a/examples/declarative/extending/coercion/birthdayparty.cpp b/examples/declarative/extending/coercion/birthdayparty.cpp index 523a42d..4f415a3 100644 --- a/examples/declarative/extending/coercion/birthdayparty.cpp +++ b/examples/declarative/extending/coercion/birthdayparty.cpp @@ -41,18 +41,18 @@ #include "birthdayparty.h" BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_celebrant(0) +: QObject(parent), m_host(0) { } -Person *BirthdayParty::celebrant() const +Person *BirthdayParty::host() const { - return m_celebrant; + return m_host; } -void BirthdayParty::setCelebrant(Person *c) +void BirthdayParty::setHost(Person *c) { - m_celebrant = c; + m_host = c; } QDeclarativeListProperty<Person> BirthdayParty::guests() diff --git a/examples/declarative/extending/coercion/birthdayparty.h b/examples/declarative/extending/coercion/birthdayparty.h index fffd407..ee77e9a 100644 --- a/examples/declarative/extending/coercion/birthdayparty.h +++ b/examples/declarative/extending/coercion/birthdayparty.h @@ -42,30 +42,29 @@ #define BIRTHDAYPARTY_H #include <QObject> -#include <qdeclarative.h> +#include <QDeclarativeListProperty> #include "person.h" class BirthdayParty : public QObject { -Q_OBJECT + Q_OBJECT // ![0] -Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant) -Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests) + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests) // ![0] public: BirthdayParty(QObject *parent = 0); - Person *celebrant() const; - void setCelebrant(Person *); + Person *host() const; + void setHost(Person *); QDeclarativeListProperty<Person> guests(); int guestCount() const; Person *guest(int) const; private: - Person *m_celebrant; + Person *m_host; QList<Person *> m_guests; }; -QML_DECLARE_TYPE(BirthdayParty); #endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/coercion/example.qml b/examples/declarative/extending/coercion/example.qml index 64d26b0..7b45950 100644 --- a/examples/declarative/extending/coercion/example.qml +++ b/examples/declarative/extending/coercion/example.qml @@ -2,12 +2,12 @@ import People 1.0 // ![0] BirthdayParty { - celebrant: Boy { + host: Boy { name: "Bob Jones" shoeSize: 12 } guests: [ - Boy { name: "Joan Hodges" }, + Boy { name: "Leo Hodges" }, Boy { name: "Jack Smith" }, Girl { name: "Anne Brown" } ] diff --git a/examples/declarative/extending/coercion/main.cpp b/examples/declarative/extending/coercion/main.cpp index 312aff9..2c7b545 100644 --- a/examples/declarative/extending/coercion/main.cpp +++ b/examples/declarative/extending/coercion/main.cpp @@ -60,10 +60,10 @@ int main(int argc, char ** argv) QDeclarativeComponent component(&engine, ":example.qml"); BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create()); - if (party && party->celebrant()) { - qWarning() << party->celebrant()->name() << "is having a birthday!"; + if (party && party->host()) { + qWarning() << party->host()->name() << "is having a birthday!"; - if (qobject_cast<Boy *>(party->celebrant())) + if (qobject_cast<Boy *>(party->host())) qWarning() << "He is inviting:"; else qWarning() << "She is inviting:"; diff --git a/examples/declarative/extending/coercion/person.h b/examples/declarative/extending/coercion/person.h index 298ffb1..1c95da7 100644 --- a/examples/declarative/extending/coercion/person.h +++ b/examples/declarative/extending/coercion/person.h @@ -42,12 +42,12 @@ #define PERSON_H #include <QObject> -#include <qdeclarative.h> -class Person : public QObject { -Q_OBJECT -Q_PROPERTY(QString name READ name WRITE setName) -Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) public: Person(QObject *parent = 0); @@ -60,22 +60,24 @@ private: QString m_name; int m_shoeSize; }; -QML_DECLARE_TYPE(Person); + // ![0] -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); + // ![0] #endif // PERSON_H diff --git a/examples/declarative/extending/default/birthdayparty.cpp b/examples/declarative/extending/default/birthdayparty.cpp index 523a42d..4f415a3 100644 --- a/examples/declarative/extending/default/birthdayparty.cpp +++ b/examples/declarative/extending/default/birthdayparty.cpp @@ -41,18 +41,18 @@ #include "birthdayparty.h" BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_celebrant(0) +: QObject(parent), m_host(0) { } -Person *BirthdayParty::celebrant() const +Person *BirthdayParty::host() const { - return m_celebrant; + return m_host; } -void BirthdayParty::setCelebrant(Person *c) +void BirthdayParty::setHost(Person *c) { - m_celebrant = c; + m_host = c; } QDeclarativeListProperty<Person> BirthdayParty::guests() diff --git a/examples/declarative/extending/default/birthdayparty.h b/examples/declarative/extending/default/birthdayparty.h index 49c20bd..9741040 100644 --- a/examples/declarative/extending/default/birthdayparty.h +++ b/examples/declarative/extending/default/birthdayparty.h @@ -42,31 +42,30 @@ #define BIRTHDAYPARTY_H #include <QObject> -#include <qdeclarative.h> +#include <QDeclarativeListProperty> #include "person.h" // ![0] 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; Person *guest(int) const; private: - Person *m_celebrant; + Person *m_host; QList<Person *> m_guests; }; // ![0] -QML_DECLARE_TYPE(BirthdayParty); #endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/default/example.qml b/examples/declarative/extending/default/example.qml index 58035f9..c0f3cbb 100644 --- a/examples/declarative/extending/default/example.qml +++ b/examples/declarative/extending/default/example.qml @@ -2,12 +2,12 @@ import People 1.0 // ![0] BirthdayParty { - celebrant: Boy { + host: Boy { name: "Bob Jones" shoeSize: 12 } - Boy { name: "Joan Hodges" } + Boy { name: "Leo Hodges" } Boy { name: "Jack Smith" } Girl { name: "Anne Brown" } } diff --git a/examples/declarative/extending/default/main.cpp b/examples/declarative/extending/default/main.cpp index 06282ad..2ffd180 100644 --- a/examples/declarative/extending/default/main.cpp +++ b/examples/declarative/extending/default/main.cpp @@ -58,10 +58,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/default/person.h b/examples/declarative/extending/default/person.h index b3eceaa..3e56860 100644 --- a/examples/declarative/extending/default/person.h +++ b/examples/declarative/extending/default/person.h @@ -42,12 +42,12 @@ #define PERSON_H #include <QObject> -#include <qdeclarative.h> -class Person : public QObject { -Q_OBJECT -Q_PROPERTY(QString name READ name WRITE setName) -Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) public: Person(QObject *parent = 0); @@ -60,20 +60,19 @@ private: QString m_name; int m_shoeSize; }; -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 diff --git a/examples/declarative/extending/extended/lineedit.cpp b/examples/declarative/extending/extended/lineedit.cpp index 417fbd9..0e521ec 100644 --- a/examples/declarative/extending/extended/lineedit.cpp +++ b/examples/declarative/extending/extended/lineedit.cpp @@ -102,4 +102,4 @@ void LineEditExtension::setBottomMargin(int m) m_lineedit->setTextMargins(l, t, r, m); } -QML_DECLARE_TYPE(QLineEdit); + diff --git a/examples/declarative/extending/extended/lineedit.h b/examples/declarative/extending/extended/lineedit.h index 9730b91..3a464b0 100644 --- a/examples/declarative/extending/extended/lineedit.h +++ b/examples/declarative/extending/extended/lineedit.h @@ -45,11 +45,11 @@ class LineEditExtension : public QObject { -Q_OBJECT -Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY marginsChanged) -Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY marginsChanged) -Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY marginsChanged) -Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY marginsChanged) + Q_OBJECT + Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY marginsChanged) + Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY marginsChanged) + Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY marginsChanged) + Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY marginsChanged) public: LineEditExtension(QObject *); diff --git a/examples/declarative/extending/extending.qmlproject b/examples/declarative/extending/extending.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/extending/extending.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/extending/grouped/birthdayparty.cpp b/examples/declarative/extending/grouped/birthdayparty.cpp index 523a42d..4f415a3 100644 --- a/examples/declarative/extending/grouped/birthdayparty.cpp +++ b/examples/declarative/extending/grouped/birthdayparty.cpp @@ -41,18 +41,18 @@ #include "birthdayparty.h" BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_celebrant(0) +: QObject(parent), m_host(0) { } -Person *BirthdayParty::celebrant() const +Person *BirthdayParty::host() const { - return m_celebrant; + return m_host; } -void BirthdayParty::setCelebrant(Person *c) +void BirthdayParty::setHost(Person *c) { - m_celebrant = c; + m_host = c; } QDeclarativeListProperty<Person> BirthdayParty::guests() diff --git a/examples/declarative/extending/grouped/birthdayparty.h b/examples/declarative/extending/grouped/birthdayparty.h index 42439c4..31d21b2 100644 --- a/examples/declarative/extending/grouped/birthdayparty.h +++ b/examples/declarative/extending/grouped/birthdayparty.h @@ -42,29 +42,29 @@ #define BIRTHDAYPARTY_H #include <QObject> -#include <qdeclarative.h> +#include <QDeclarativeListProperty> #include "person.h" 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; Person *guest(int) const; private: - Person *m_celebrant; + Person *m_host; QList<Person *> m_guests; }; -QML_DECLARE_TYPE(BirthdayParty); + #endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/grouped/example.qml b/examples/declarative/extending/grouped/example.qml index 55912ed..91b7a06 100644 --- a/examples/declarative/extending/grouped/example.qml +++ b/examples/declarative/extending/grouped/example.qml @@ -2,13 +2,13 @@ import People 1.0 // ![0] BirthdayParty { - celebrant: Boy { + host: Boy { name: "Bob Jones" shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } } Boy { - name: "Joan Hodges" + name: "Leo Hodges" shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } } // ![1] diff --git a/examples/declarative/extending/grouped/main.cpp b/examples/declarative/extending/grouped/main.cpp index b383a8b..baf32cf 100644 --- a/examples/declarative/extending/grouped/main.cpp +++ b/examples/declarative/extending/grouped/main.cpp @@ -59,10 +59,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/grouped/person.h b/examples/declarative/extending/grouped/person.h index 5ea2348..a031e69 100644 --- a/examples/declarative/extending/grouped/person.h +++ b/examples/declarative/extending/grouped/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,13 +71,13 @@ 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) +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) // ![1] -Q_PROPERTY(ShoeDescription *shoe READ shoe) + Q_PROPERTY(ShoeDescription *shoe READ shoe) // ![1] public: Person(QObject *parent = 0); @@ -90,20 +90,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 diff --git a/examples/declarative/extending/properties/birthdayparty.cpp b/examples/declarative/extending/properties/birthdayparty.cpp index 14fd6a3..27d17a1 100644 --- a/examples/declarative/extending/properties/birthdayparty.cpp +++ b/examples/declarative/extending/properties/birthdayparty.cpp @@ -41,19 +41,19 @@ #include "birthdayparty.h" BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_celebrant(0) +: QObject(parent), m_host(0) { } // ![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/properties/birthdayparty.h b/examples/declarative/extending/properties/birthdayparty.h index c4cb536..39ce9ba 100644 --- a/examples/declarative/extending/properties/birthdayparty.h +++ b/examples/declarative/extending/properties/birthdayparty.h @@ -42,36 +42,35 @@ #define BIRTHDAYPARTY_H #include <QObject> -#include <qdeclarative.h> +#include <QDeclarativeListProperty> #include "person.h" // ![0] class BirthdayParty : public QObject { -Q_OBJECT + Q_OBJECT // ![0] // ![1] -Q_PROPERTY(Person *celebrant READ celebrant WRITE setCelebrant) + Q_PROPERTY(Person *host READ host WRITE setHost) // ![1] // ![2] -Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests) + Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests) // ![2] // ![3] public: BirthdayParty(QObject *parent = 0); - Person *celebrant() const; - void setCelebrant(Person *); + Person *host() const; + void setHost(Person *); QDeclarativeListProperty<Person> guests(); int guestCount() const; Person *guest(int) const; private: - Person *m_celebrant; + Person *m_host; QList<Person *> m_guests; }; -QML_DECLARE_TYPE(BirthdayParty); // ![3] #endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/properties/example.qml b/examples/declarative/extending/properties/example.qml index 9594a84..35abdd6 100644 --- a/examples/declarative/extending/properties/example.qml +++ b/examples/declarative/extending/properties/example.qml @@ -2,12 +2,12 @@ import People 1.0 // ![0] BirthdayParty { - celebrant: Person { + host: Person { name: "Bob Jones" shoeSize: 12 } guests: [ - Person { name: "Joan Hodges" }, + Person { name: "Leo Hodges" }, Person { name: "Jack Smith" }, Person { name: "Anne Brown" } ] diff --git a/examples/declarative/extending/properties/main.cpp b/examples/declarative/extending/properties/main.cpp index 350f8bd..85e9584 100644 --- a/examples/declarative/extending/properties/main.cpp +++ b/examples/declarative/extending/properties/main.cpp @@ -56,8 +56,8 @@ 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!"; qWarning() << "They are inviting:"; for (int ii = 0; ii < party->guestCount(); ++ii) qWarning() << " " << party->guest(ii)->name(); diff --git a/examples/declarative/extending/properties/person.h b/examples/declarative/extending/properties/person.h index 860a607..0029b09 100644 --- a/examples/declarative/extending/properties/person.h +++ b/examples/declarative/extending/properties/person.h @@ -42,12 +42,12 @@ #define PERSON_H #include <QObject> -#include <qdeclarative.h> -class Person : public QObject { -Q_OBJECT -Q_PROPERTY(QString name READ name WRITE setName) -Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) +class Person : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) public: Person(QObject *parent = 0); @@ -60,6 +60,5 @@ private: QString m_name; int m_shoeSize; }; -QML_DECLARE_TYPE(Person); #endif // PERSON_H diff --git a/examples/declarative/extending/signal/birthdayparty.cpp b/examples/declarative/extending/signal/birthdayparty.cpp index 65ff530..740c8c9 100644 --- a/examples/declarative/extending/signal/birthdayparty.cpp +++ b/examples/declarative/extending/signal/birthdayparty.cpp @@ -57,18 +57,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/signal/birthdayparty.h b/examples/declarative/extending/signal/birthdayparty.h index bcdc513..ae4dd39 100644 --- a/examples/declarative/extending/signal/birthdayparty.h +++ b/examples/declarative/extending/signal/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; @@ -86,11 +85,9 @@ signals: // ![0] 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/signal/example.qml b/examples/declarative/extending/signal/example.qml index c7d4792..83d6a23 100644 --- a/examples/declarative/extending/signal/example.qml +++ b/examples/declarative/extending/signal/example.qml @@ -5,13 +5,13 @@ BirthdayParty { onPartyStarted: console.log("This party started rockin' at " + time); // ![0] - celebrant: Boy { + host: Boy { name: "Bob Jones" shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } } Boy { - name: "Joan Hodges" + name: "Leo Hodges" BirthdayParty.rsvp: "2009-07-06" shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } } diff --git a/examples/declarative/extending/signal/main.cpp b/examples/declarative/extending/signal/main.cpp index 1b23a46..453f688 100644 --- a/examples/declarative/extending/signal/main.cpp +++ b/examples/declarative/extending/signal/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/signal/person.h b/examples/declarative/extending/signal/person.h index 08caebf..2f444c5 100644 --- a/examples/declarative/extending/signal/person.h +++ b/examples/declarative/extending/signal/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 diff --git a/examples/declarative/extending/valuesource/birthdayparty.cpp b/examples/declarative/extending/valuesource/birthdayparty.cpp index 99d98be..b915f4f 100644 --- a/examples/declarative/extending/valuesource/birthdayparty.cpp +++ b/examples/declarative/extending/valuesource/birthdayparty.cpp @@ -57,18 +57,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() @@ -92,12 +92,12 @@ void BirthdayParty::startParty() emit partyStarted(time); } -QString BirthdayParty::speaker() const +QString BirthdayParty::announcement() const { return QString(); } -void BirthdayParty::setSpeaker(const QString &speak) +void BirthdayParty::setAnnouncement(const QString &speak) { qWarning() << qPrintable(speak); } diff --git a/examples/declarative/extending/valuesource/birthdayparty.h b/examples/declarative/extending/valuesource/birthdayparty.h index 819a200..5f25781 100644 --- a/examples/declarative/extending/valuesource/birthdayparty.h +++ b/examples/declarative/extending/valuesource/birthdayparty.h @@ -49,8 +49,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); @@ -60,30 +60,28 @@ 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_OBJECT + Q_PROPERTY(Person *host READ host WRITE setHost) + Q_PROPERTY(QDeclarativeListProperty<Person> guests READ guests) // ![0] -Q_PROPERTY(QString speaker READ speaker WRITE setSpeaker) + Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) // ![0] -Q_CLASSINFO("DefaultProperty", "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; Person *guest(int) const; - - QString speaker() const; - void setSpeaker(const QString &); + QString announcement() const; + void setAnnouncement(const QString &); static BirthdayPartyAttached *qmlAttachedProperties(QObject *); @@ -92,11 +90,9 @@ signals: void partyStarted(const QTime &time); 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/valuesource/example.qml b/examples/declarative/extending/valuesource/example.qml index 7cdf8c0..5b8c8af 100644 --- a/examples/declarative/extending/valuesource/example.qml +++ b/examples/declarative/extending/valuesource/example.qml @@ -2,19 +2,19 @@ import People 1.0 // ![0] BirthdayParty { - speaker: HappyBirthday { name: "Bob Jones" } + HappyBirthdaySong on announcement { name: "Bob Jones" } // ![0] onPartyStarted: console.log("This party started rockin' at " + time); - celebrant: Boy { + host: Boy { name: "Bob Jones" shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } } Boy { - name: "Joan Hodges" + name: "Leo Hodges" BirthdayParty.rsvp: "2009-07-06" shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } } diff --git a/examples/declarative/extending/valuesource/happybirthday.cpp b/examples/declarative/extending/valuesource/happybirthdaysong.cpp index 0dbbd6e..8ea5c2b 100644 --- a/examples/declarative/extending/valuesource/happybirthday.cpp +++ b/examples/declarative/extending/valuesource/happybirthdaysong.cpp @@ -38,10 +38,10 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "happybirthday.h" +#include "happybirthdaysong.h" #include <QTimer> -HappyBirthday::HappyBirthday(QObject *parent) +HappyBirthdaySong::HappyBirthdaySong(QObject *parent) : QObject(parent), m_line(-1) { setName(QString()); @@ -50,17 +50,17 @@ HappyBirthday::HappyBirthday(QObject *parent) timer->start(1000); } -void HappyBirthday::setTarget(const QDeclarativeProperty &p) +void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) { m_target = p; } -QString HappyBirthday::name() const +QString HappyBirthdaySong::name() const { return m_name; } -void HappyBirthday::setName(const QString &name) +void HappyBirthdaySong::setName(const QString &name) { m_name = name; @@ -72,7 +72,7 @@ void HappyBirthday::setName(const QString &name) m_lyrics << ""; } -void HappyBirthday::advance() +void HappyBirthdaySong::advance() { m_line = (m_line + 1) % m_lyrics.count(); diff --git a/examples/declarative/extending/valuesource/happybirthday.h b/examples/declarative/extending/valuesource/happybirthdaysong.h index b48c012..3d07909 100644 --- a/examples/declarative/extending/valuesource/happybirthday.h +++ b/examples/declarative/extending/valuesource/happybirthdaysong.h @@ -38,8 +38,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef HAPPYBIRTHDAY_H -#define HAPPYBIRTHDAY_H +#ifndef HAPPYBIRTHDAYSONG_H +#define HAPPYBIRTHDAYSONG_H #include <QDeclarativePropertyValueSource> #include <QDeclarativeProperty> @@ -48,14 +48,15 @@ #include <QStringList> // ![0] -class HappyBirthday : public QObject, public QDeclarativePropertyValueSource +class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource { -Q_OBJECT + Q_OBJECT + Q_INTERFACES(QDeclarativePropertyValueSource) // ![0] -Q_PROPERTY(QString name READ name WRITE setName) + Q_PROPERTY(QString name READ name WRITE setName) // ![1] public: - HappyBirthday(QObject *parent = 0); + HappyBirthdaySong(QObject *parent = 0); virtual void setTarget(const QDeclarativeProperty &); // ![1] @@ -74,7 +75,6 @@ private: // ![2] }; // ![2] -QML_DECLARE_TYPE(HappyBirthday); -#endif // HAPPYBIRTHDAY_H +#endif // HAPPYBIRTHDAYSONG_H diff --git a/examples/declarative/extending/valuesource/main.cpp b/examples/declarative/extending/valuesource/main.cpp index 2574917..00840ee 100644 --- a/examples/declarative/extending/valuesource/main.cpp +++ b/examples/declarative/extending/valuesource/main.cpp @@ -43,7 +43,7 @@ #include <QDeclarativeComponent> #include <QDebug> #include "birthdayparty.h" -#include "happybirthday.h" +#include "happybirthdaysong.h" #include "person.h" int main(int argc, char ** argv) @@ -52,7 +52,7 @@ int main(int argc, char ** argv) qmlRegisterType<BirthdayPartyAttached>(); qmlRegisterType<BirthdayParty>("People", 1,0, "BirthdayParty"); - qmlRegisterType<HappyBirthday>("People", 1,0, "HappyBirthday"); + qmlRegisterType<HappyBirthdaySong>("People", 1,0, "HappyBirthdaySong"); qmlRegisterType<ShoeDescription>(); qmlRegisterType<Person>(); qmlRegisterType<Boy>("People", 1,0, "Boy"); @@ -62,10 +62,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/valuesource/person.h b/examples/declarative/extending/valuesource/person.h index 08caebf..2f444c5 100644 --- a/examples/declarative/extending/valuesource/person.h +++ b/examples/declarative/extending/valuesource/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 diff --git a/examples/declarative/extending/valuesource/valuesource.pro b/examples/declarative/extending/valuesource/valuesource.pro index d3409b6..0626c98 100644 --- a/examples/declarative/extending/valuesource/valuesource.pro +++ b/examples/declarative/extending/valuesource/valuesource.pro @@ -8,10 +8,10 @@ QT += declarative SOURCES += main.cpp \ person.cpp \ birthdayparty.cpp \ - happybirthday.cpp + happybirthdaysong.cpp HEADERS += person.h \ birthdayparty.h \ - happybirthday.h + happybirthdaysong.h RESOURCES += valuesource.qrc target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/valuesource sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS valuesource.pro diff --git a/examples/declarative/fillmode/content/QtLogo.qml b/examples/declarative/fillmode/content/QtLogo.qml new file mode 100644 index 0000000..6dd714d --- /dev/null +++ b/examples/declarative/fillmode/content/QtLogo.qml @@ -0,0 +1,30 @@ +import Qt 4.7 + +Item { + id: qtLogo + + property alias fillMode: image.fillMode + property alias label: labelText.text + + width: ((window.width - 20) - ((grid.columns - 1) * grid.spacing)) / grid.columns + height: ((window.height - 20) - ((grid.rows - 1) * grid.spacing)) / grid.rows + + Column { + anchors.fill: parent + + Rectangle { + height: qtLogo.height - 30; width: qtLogo.width + border.color: "black"; clip: true + + Image { + id: image + anchors.fill: parent; smooth: true; source: "qt-logo.png" + } + } + + Text { + id: labelText; anchors.horizontalCenter: parent.horizontalCenter + height: 30; verticalAlignment: Text.AlignVCenter + } + } +} diff --git a/examples/declarative/fillmode/content/qt-logo.png b/examples/declarative/fillmode/content/qt-logo.png Binary files differnew file mode 100644 index 0000000..14ddf2a --- /dev/null +++ b/examples/declarative/fillmode/content/qt-logo.png diff --git a/examples/declarative/fillmode/face.png b/examples/declarative/fillmode/face.png Binary files differdeleted file mode 100644 index 9623b1a..0000000 --- a/examples/declarative/fillmode/face.png +++ /dev/null diff --git a/examples/declarative/fillmode/fillmode.qml b/examples/declarative/fillmode/fillmode.qml index e47fc9b..e5b0336 100644 --- a/examples/declarative/fillmode/fillmode.qml +++ b/examples/declarative/fillmode/fillmode.qml @@ -1,44 +1,22 @@ import Qt 4.7 +import "content" -Image { - width: 400 - height: 250 - source: "face.png" +Rectangle { + id: window - SequentialAnimation on fillMode { - loops: Animation.Infinite - PropertyAction { value: Image.Stretch } - PropertyAction { target: label; property: "text"; value: "Stretch" } - PauseAnimation { duration: 1000 } - PropertyAction { value: Image.PreserveAspectFit } - PropertyAction { target: label; property: "text"; value: "PreserveAspectFit" } - PauseAnimation { duration: 1000 } - PropertyAction { value: Image.PreserveAspectCrop } - PropertyAction { target: label; property: "text"; value: "PreserveAspectCrop" } - PauseAnimation { duration: 1000 } - PropertyAction { value: Image.Tile } - PropertyAction { target: label; property: "text"; value: "Tile" } - PauseAnimation { duration: 1000 } - PropertyAction { value: Image.TileHorizontally } - PropertyAction { target: label; property: "text"; value: "TileHorizontally" } - PauseAnimation { duration: 1000 } - PropertyAction { value: Image.TileVertically } - PropertyAction { target: label; property: "text"; value: "TileVertically" } - PauseAnimation { duration: 1000 } - } + width: 800; height: 480 + color: "#cdcdcd" - Text { - id: label - font.pointSize: 24 - color: "blue" - style: Text.Outline - styleColor: "white" - anchors.centerIn: parent - } + Grid { + id: grid + anchors { fill: parent; topMargin: 10; leftMargin: 10; rightMargin: 10; bottomMargin: 10 } + columns: 3; rows: 2; spacing: 20 - Rectangle { - border.color: "black" - color: "transparent" - anchors { fill: parent; rightMargin: 1; bottomMargin: 1 } + QtLogo { fillMode: Image.Stretch; label: "Stretch" } + QtLogo { fillMode: Image.PreserveAspectFit; label: "PreserveAspectFit" } + QtLogo { fillMode: Image.PreserveAspectCrop; label: "PreserveAspectCrop" } + QtLogo { fillMode: Image.Tile; label: "Tile" } + QtLogo { fillMode: Image.TileHorizontally; label: "TileHorizontally" } + QtLogo { fillMode: Image.TileVertically; label: "TileVertically" } } } diff --git a/examples/declarative/fillmode/fillmode.qmlproject b/examples/declarative/fillmode/fillmode.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/fillmode/fillmode.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/flipable/flipable.qmlproject b/examples/declarative/flipable/flipable.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/flipable/flipable.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/focus/Core/GridMenu.qml b/examples/declarative/focus/Core/GridMenu.qml index c37b17a..3f727fd 100644 --- a/examples/declarative/focus/Core/GridMenu.qml +++ b/examples/declarative/focus/Core/GridMenu.qml @@ -43,9 +43,7 @@ FocusScope { onClicked: { GridView.view.currentIndex = index - container.focus = true - gridMenu.focus = true - mainView.focus = true + container.forceFocus() } } diff --git a/examples/declarative/focus/Core/ListViewDelegate.qml b/examples/declarative/focus/Core/ListViewDelegate.qml index 96324d7..14e2548 100644 --- a/examples/declarative/focus/Core/ListViewDelegate.qml +++ b/examples/declarative/focus/Core/ListViewDelegate.qml @@ -1,45 +1,40 @@ import Qt 4.7 -Component { - Item { - id: container - x: 5; width: ListView.view.width - 10; height: 60 +Item { + id: container + x: 5; width: ListView.view.width - 10; height: 60 - Rectangle { - id: content - anchors.centerIn: parent; width: container.width - 40; height: container.height - 10 - color: "transparent" - smooth: true - radius: 10 + Rectangle { + id: content + anchors.centerIn: parent; width: container.width - 40; height: container.height - 10 + color: "transparent" + smooth: true + radius: 10 - Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 } - Text { - text: "List element " + (index + 1); color: "#193441"; font.bold: false; anchors.centerIn: parent - font.pixelSize: 14 - } + Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 } + Text { + text: "List element " + (index + 1); color: "#193441"; font.bold: false; anchors.centerIn: parent + font.pixelSize: 14 } + } - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true + MouseArea { + id: mouseArea + anchors.fill: parent + hoverEnabled: true - onClicked: { - ListView.view.currentIndex = index - container.focus = true - ListView.view.focus = true - listViews.focus = true - mainView.focus = true - } + onClicked: { + ListView.view.currentIndex = index + container.forceFocus() } + } - states: State { - name: "active"; when: container.focus == true - PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } - } + states: State { + name: "active"; when: container.focus == true + PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } + } - transitions: Transition { - NumberAnimation { properties: "scale"; duration: 100 } - } + transitions: Transition { + NumberAnimation { properties: "scale"; duration: 100 } } } diff --git a/examples/declarative/focus/Core/ListViews.qml b/examples/declarative/focus/Core/ListViews.qml index f4384c8..089f821 100644 --- a/examples/declarative/focus/Core/ListViews.qml +++ b/examples/declarative/focus/Core/ListViews.qml @@ -10,7 +10,7 @@ FocusScope { y: wantsFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20 focus: true KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2 - model: 10 + model: 10; cacheBuffer: 200 delegate: ListViewDelegate {} Behavior on y { @@ -22,7 +22,7 @@ FocusScope { id: list2 y: wantsFocus ? 10 : 40; x: parent.width / 3; width: parent.width / 3; height: parent.height - 20 KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3 - model: 10 + model: 10; cacheBuffer: 200 delegate: ListViewDelegate {} Behavior on y { @@ -34,7 +34,7 @@ FocusScope { id: list3 y: wantsFocus ? 10 : 40; x: 2 * parent.width / 3; width: parent.width / 3; height: parent.height - 20 KeyNavigation.up: gridMenu; KeyNavigation.left: list2 - model: 10 + model: 10; cacheBuffer: 200 delegate: ListViewDelegate {} Behavior on y { diff --git a/examples/declarative/focus/focus.qmlproject b/examples/declarative/focus/focus.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/focus/focus.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/fonts/fonts.qmlproject b/examples/declarative/fonts/fonts.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/fonts/fonts.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/gestures/gestures.qmlproject b/examples/declarative/gestures/gestures.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/gestures/gestures.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/gridview/gridview.qmlproject b/examples/declarative/gridview/gridview.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/gridview/gridview.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/imageprovider/imageprovider.qmlproject b/examples/declarative/imageprovider/imageprovider.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/imageprovider/imageprovider.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/images/images.qmlproject b/examples/declarative/images/images.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/images/images.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/layouts/layouts.qmlproject b/examples/declarative/layouts/layouts.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/layouts/layouts.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/listmodel-threaded/dataloader.js b/examples/declarative/listmodel-threaded/dataloader.js index eac7478..d720f09 100644 --- a/examples/declarative/listmodel-threaded/dataloader.js +++ b/examples/declarative/listmodel-threaded/dataloader.js @@ -1,14 +1,9 @@ // ![0] WorkerScript.onMessage = function(msg) { - console.log("Worker told to", msg.action); - if (msg.action == 'appendCurrentTime') { var data = {'time': new Date().toTimeString()}; msg.model.append(data); msg.model.sync(); // updates the changes to the list - - var msgToSend = {'msg': 'Model updated!'}; - WorkerScript.sendMessage(msgToSend); } } // ![0] diff --git a/examples/declarative/listmodel-threaded/listmodel-threaded.qmlproject b/examples/declarative/listmodel-threaded/listmodel-threaded.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/listmodel-threaded/listmodel-threaded.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/listmodel-threaded/timedisplay.qml b/examples/declarative/listmodel-threaded/timedisplay.qml index 80ac9fa..bad7010 100644 --- a/examples/declarative/listmodel-threaded/timedisplay.qml +++ b/examples/declarative/listmodel-threaded/timedisplay.qml @@ -15,9 +15,6 @@ ListView { WorkerScript { id: worker source: "dataloader.js" - onMessage: { - console.log("Worker said", messageObject.msg); - } } Timer { diff --git a/examples/declarative/listview/listview.qmlproject b/examples/declarative/listview/listview.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/listview/listview.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/mousearea/mousearea.qmlproject b/examples/declarative/mousearea/mousearea.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/mousearea/mousearea.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/objectlistmodel/objectlistmodel.qmlproject b/examples/declarative/objectlistmodel/objectlistmodel.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/objectlistmodel/objectlistmodel.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/package/package.qmlproject b/examples/declarative/package/package.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/package/package.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/parallax/parallax.qmlproject b/examples/declarative/parallax/parallax.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/parallax/parallax.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml index 8f5f290..4b38d45 100644 --- a/examples/declarative/parallax/qml/ParallaxView.qml +++ b/examples/declarative/parallax/qml/ParallaxView.qml @@ -21,7 +21,7 @@ Item { onCurrentIndexChanged: root.currentIndex = currentIndex orientation: "Horizontal" - overShoot: false + boundsBehavior: Flickable.DragOverBounds anchors.fill: parent model: VisualItemModel { id: visualModel } diff --git a/examples/declarative/plugins/README b/examples/declarative/plugins/README index 3ae256d..fe519f8 100644 --- a/examples/declarative/plugins/README +++ b/examples/declarative/plugins/README @@ -5,5 +5,5 @@ by a C++ plugin (providing the "Time" type), and by QML files (providing the To run: make install - qml plugins.qml + qml -I . plugins.qml diff --git a/examples/declarative/plugins/plugins.pro b/examples/declarative/plugins/plugins.pro index c409d39..b501ae3 100644 --- a/examples/declarative/plugins/plugins.pro +++ b/examples/declarative/plugins/plugins.pro @@ -3,7 +3,6 @@ DESTDIR = com/nokia/TimeExample TARGET = qtimeexampleqmlplugin CONFIG += qt plugin QT += declarative -VERSION = 1.0.0 SOURCES += plugin.cpp diff --git a/examples/declarative/plugins/plugins.qmlproject b/examples/declarative/plugins/plugins.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/plugins/plugins.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/progressbar/progressbar.qmlproject b/examples/declarative/progressbar/progressbar.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/progressbar/progressbar.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/proxywidgets/proxywidgets.cpp b/examples/declarative/proxywidgets/proxywidgets.cpp index 47d0cb9..067eb2c 100644 --- a/examples/declarative/proxywidgets/proxywidgets.cpp +++ b/examples/declarative/proxywidgets/proxywidgets.cpp @@ -94,6 +94,4 @@ public: #include "proxywidgets.moc" -QML_DECLARE_TYPE(MyPushButton) - Q_EXPORT_PLUGIN2(proxywidgetsplugin, ProxyWidgetsPlugin); diff --git a/examples/declarative/proxywidgets/proxywidgets.pro b/examples/declarative/proxywidgets/proxywidgets.pro index eb85191..cb07d80 100644 --- a/examples/declarative/proxywidgets/proxywidgets.pro +++ b/examples/declarative/proxywidgets/proxywidgets.pro @@ -3,7 +3,6 @@ DESTDIR = ProxyWidgets TARGET = proxywidgetsplugin CONFIG += qt plugin QT += declarative -VERSION = 1.0.0 SOURCES += proxywidgets.cpp diff --git a/examples/declarative/proxywidgets/proxywidgets.qmlproject b/examples/declarative/proxywidgets/proxywidgets.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/proxywidgets/proxywidgets.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/scrollbar/scrollbar.qmlproject b/examples/declarative/scrollbar/scrollbar.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/scrollbar/scrollbar.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/searchbox/searchbox.qmlproject b/examples/declarative/searchbox/searchbox.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/searchbox/searchbox.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/slideswitch/slideswitch.qmlproject b/examples/declarative/slideswitch/slideswitch.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/slideswitch/slideswitch.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/sql/sql.qmlproject b/examples/declarative/sql/sql.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/sql/sql.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/states/states.qmlproject b/examples/declarative/states/states.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/states/states.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/stringlistmodel/main.cpp b/examples/declarative/stringlistmodel/main.cpp new file mode 100644 index 0000000..abbffa7 --- /dev/null +++ b/examples/declarative/stringlistmodel/main.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> + +#include <qdeclarativeengine.h> +#include <qdeclarativecontext.h> +#include <qdeclarative.h> +#include <qdeclarativeitem.h> +#include <qdeclarativeview.h> + + +/* + This example illustrates exposing a QStringList as a + model in QML +*/ + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + QDeclarativeView view; + + QStringList dataList; + dataList.append("Item 1"); + dataList.append("Item 2"); + dataList.append("Item 3"); + dataList.append("Item 4"); + + QDeclarativeContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); + + view.setSource(QUrl("qrc:view.qml")); + view.show(); + + return app.exec(); +} + diff --git a/examples/declarative/stringlistmodel/stringlistmodel.pro b/examples/declarative/stringlistmodel/stringlistmodel.pro new file mode 100644 index 0000000..23dc481 --- /dev/null +++ b/examples/declarative/stringlistmodel/stringlistmodel.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = stringlistmodel +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp +RESOURCES += stringlistmodel.qrc diff --git a/examples/declarative/stringlistmodel/stringlistmodel.qrc b/examples/declarative/stringlistmodel/stringlistmodel.qrc new file mode 100644 index 0000000..17e9301 --- /dev/null +++ b/examples/declarative/stringlistmodel/stringlistmodel.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>view.qml</file> +</qresource> +</RCC> diff --git a/examples/declarative/stringlistmodel/view.qml b/examples/declarative/stringlistmodel/view.qml new file mode 100644 index 0000000..41c03d9 --- /dev/null +++ b/examples/declarative/stringlistmodel/view.qml @@ -0,0 +1,15 @@ +import Qt 4.7 + +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Rectangle { + height: 25 + width: 100 + Text { text: modelData } + } + } +} diff --git a/examples/declarative/tabwidget/tabwidget.qmlproject b/examples/declarative/tabwidget/tabwidget.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/tabwidget/tabwidget.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/tic-tac-toe/content/pics/board.png b/examples/declarative/tic-tac-toe/content/pics/board.png Binary files differindex 29118a9..7e5b7ba 100644 --- a/examples/declarative/tic-tac-toe/content/pics/board.png +++ b/examples/declarative/tic-tac-toe/content/pics/board.png diff --git a/examples/declarative/tic-tac-toe/tic-tac-toe.qmlproject b/examples/declarative/tic-tac-toe/tic-tac-toe.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/tic-tac-toe/tic-tac-toe.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/tutorials/samegame/samegame1/Block.qml b/examples/declarative/tutorials/samegame/samegame1/Block.qml index a535235..a23654b 100644 --- a/examples/declarative/tutorials/samegame/samegame1/Block.qml +++ b/examples/declarative/tutorials/samegame/samegame1/Block.qml @@ -1,9 +1,9 @@ //![0] import Qt 4.7 -Item { +Item { id: block - + Image { id: img anchors.fill: parent diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml index e8034ac..e84b1ce 100644 --- a/examples/declarative/tutorials/samegame/samegame1/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame1/Button.qml @@ -18,9 +18,9 @@ Rectangle { GradientStop { position: 0.0 color: { - if (mouseArea.pressed) + if (mouseArea.pressed) return activePalette.dark - else + else return activePalette.light } } diff --git a/examples/declarative/tutorials/samegame/samegame2/Block.qml b/examples/declarative/tutorials/samegame/samegame2/Block.qml index 88b3d79..4e71e60 100644 --- a/examples/declarative/tutorials/samegame/samegame2/Block.qml +++ b/examples/declarative/tutorials/samegame/samegame2/Block.qml @@ -1,8 +1,8 @@ import Qt 4.7 -Item { +Item { id: block - + Image { id: img anchors.fill: parent diff --git a/examples/declarative/tutorials/samegame/samegame2/Button.qml b/examples/declarative/tutorials/samegame/samegame2/Button.qml index 8d322de5..737d886 100644 --- a/examples/declarative/tutorials/samegame/samegame2/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame2/Button.qml @@ -17,9 +17,9 @@ Rectangle { GradientStop { position: 0.0 color: { - if (mouseArea.pressed) + if (mouseArea.pressed) return activePalette.dark - else + else return activePalette.light } } diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.js b/examples/declarative/tutorials/samegame/samegame2/samegame.js index 9809c1d..81da31b 100644 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame2/samegame.js @@ -35,7 +35,7 @@ function startNewGame() { function createBlock(column, row) { if (component == null) - component = createComponent("Block.qml"); + component = Qt.createComponent("Block.qml"); // Note that if Block.qml was not a local file, component.isReady would be // false and we should wait for the component's statusChanged() signal to diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml index 7a17d16..a7d1fba 100644 --- a/examples/declarative/tutorials/samegame/samegame2/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame2/samegame.qml @@ -31,7 +31,7 @@ Rectangle { //![1] Button { anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter } - text: "New Game" + text: "New Game" onClicked: SameGame.startNewGame() } //![1] diff --git a/examples/declarative/tutorials/samegame/samegame3/Block.qml b/examples/declarative/tutorials/samegame/samegame3/Block.qml index dd0fb48..7411259 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Block.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Block.qml @@ -1,11 +1,11 @@ //![0] import Qt 4.7 -Item { +Item { id: block property int type: 0 - + Image { id: img diff --git a/examples/declarative/tutorials/samegame/samegame3/Button.qml b/examples/declarative/tutorials/samegame/samegame3/Button.qml index 8d322de5..737d886 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Button.qml @@ -17,9 +17,9 @@ Rectangle { GradientStop { position: 0.0 color: { - if (mouseArea.pressed) + if (mouseArea.pressed) return activePalette.dark - else + else return activePalette.light } } diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml index be3a7b7..15b3b2f 100644 --- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml +++ b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml @@ -21,7 +21,7 @@ Rectangle { border.width: 1 opacity: 0 - Behavior on opacity { + Behavior on opacity { NumberAnimation { duration: 1000 } } diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js index c12def7..eaf47d9 100644 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame3/samegame.js @@ -32,7 +32,7 @@ function startNewGame() { function createBlock(column, row) { if (component == null) - component = createComponent("Block.qml"); + component = Qt.createComponent("Block.qml"); // Note that if Block.qml was not a local file, component.isReady would be // false and we should wait for the component's statusChanged() signal to diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml index bc5f2f8..50f9d5d 100644 --- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml @@ -52,7 +52,7 @@ Rectangle { Button { anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter } - text: "New Game" + text: "New Game" onClicked: SameGame.startNewGame() } diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml index d3a9df7..d6ef2e5 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml @@ -17,21 +17,21 @@ Item { //![1] //![2] - Image { + Image { id: img anchors.fill: parent source: { if (type == 0) return "../../shared/pics/redStone.png"; - else if (type == 1) + else if (type == 1) return "../../shared/pics/blueStone.png"; else return "../../shared/pics/greenStone.png"; } opacity: 0 - Behavior on opacity { + Behavior on opacity { NumberAnimation { properties:"opacity"; duration: 200 } } } @@ -41,7 +41,7 @@ Item { Particles { id: particles - width: 1; height: 1 + width: 1; height: 1 anchors.centerIn: parent emissionRate: 0 diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml index 8d322de5..737d886 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml @@ -17,9 +17,9 @@ Rectangle { GradientStop { position: 0.0 color: { - if (mouseArea.pressed) + if (mouseArea.pressed) return activePalette.dark - else + else return activePalette.light } } diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml index adb3f9e..6848534 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml @@ -20,7 +20,7 @@ Rectangle { border.width: 1 opacity: 0 - Behavior on opacity { + Behavior on opacity { NumberAnimation { duration: 1000 } } diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js index 7800b6e..c527f66 100755 --- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js @@ -43,7 +43,7 @@ function startNewGame() { function createBlock(column, row) { if (component == null) - component = createComponent("content/BoomBlock.qml"); + component = Qt.createComponent("content/BoomBlock.qml"); // Note that if Block.qml was not a local file, component.isReady would be // false and we should wait for the component's statusChanged() signal to diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame.qml b/examples/declarative/tutorials/samegame/samegame4/samegame.qml index b2a490d..404af0a 100644 --- a/examples/declarative/tutorials/samegame/samegame4/samegame.qml +++ b/examples/declarative/tutorials/samegame/samegame4/samegame.qml @@ -73,7 +73,7 @@ Rectangle { Button { anchors { left: parent.left; leftMargin: 3; verticalCenter: parent.verticalCenter } - text: "New Game" + text: "New Game" onClicked: SameGame.startNewGame() } diff --git a/examples/declarative/tutorials/tutorials.qmlproject b/examples/declarative/tutorials/tutorials.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/tutorials/tutorials.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/tvtennis/tvtennis.qmlproject b/examples/declarative/tvtennis/tvtennis.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/tvtennis/tvtennis.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/velocity/velocity.qmlproject b/examples/declarative/velocity/velocity.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/velocity/velocity.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/webview/webview.qmlproject b/examples/declarative/webview/webview.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/webview/webview.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/workerscript/workerscript.qmlproject b/examples/declarative/workerscript/workerscript.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/workerscript/workerscript.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/xmldata/xmldata.qmlproject b/examples/declarative/xmldata/xmldata.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/xmldata/xmldata.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/xmlhttprequest/xmlhttprequest.qmlproject b/examples/declarative/xmlhttprequest/xmlhttprequest.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/xmlhttprequest/xmlhttprequest.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/graphicsview/diagramscene/diagramitem.cpp b/examples/graphicsview/diagramscene/diagramitem.cpp index ee028bb..41534d1 100644 --- a/examples/graphicsview/diagramscene/diagramitem.cpp +++ b/examples/graphicsview/diagramscene/diagramitem.cpp @@ -82,6 +82,7 @@ DiagramItem::DiagramItem(DiagramType diagramType, QMenu *contextMenu, setPolygon(myPolygon); setFlag(QGraphicsItem::ItemIsMovable, true); setFlag(QGraphicsItem::ItemIsSelectable, true); + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); } //! [0] diff --git a/examples/script/qstetrix/qstetrix.pro b/examples/script/qstetrix/qstetrix.pro index 3db66ab..65d5a67 100644 --- a/examples/script/qstetrix/qstetrix.pro +++ b/examples/script/qstetrix/qstetrix.pro @@ -5,7 +5,6 @@ HEADERS = tetrixboard.h SOURCES = main.cpp \ tetrixboard.cpp -FORMS = tetrixwindow.ui RESOURCES = tetrix.qrc contains(QT_CONFIG, scripttools): QT += scripttools diff --git a/examples/xmlpatterns/recipes/recipes.qrc b/examples/xmlpatterns/recipes/recipes.qrc index 2f375ee..65b6615 100644 --- a/examples/xmlpatterns/recipes/recipes.qrc +++ b/examples/xmlpatterns/recipes/recipes.qrc @@ -1,6 +1,5 @@ <!DOCTYPE RCC><RCC version="1.0"> <qresource> - <file>forms/querywidget.ui</file> <file>files/cookbook.xml</file> <file>files/allRecipes.xq</file> <file>files/liquidIngredientsInSoup.xq</file> |