summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-04-27 16:42:14 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-04-27 16:42:14 (GMT)
commita17339e943f21bb6c6e16884f716dd9ab8f94938 (patch)
treef75b19e3a5f9d436c00c6b269488414513d943c5 /examples
parentc78fb096c31df3b7d3cd9018f26518f59f4fde65 (diff)
parentba97ea29d33acf9ab421f4d8ef5202ec83231d7e (diff)
downloadQt-a17339e943f21bb6c6e16884f716dd9ab8f94938.zip
Qt-a17339e943f21bb6c6e16884f716dd9ab8f94938.tar.gz
Qt-a17339e943f21bb6c6e16884f716dd9ab8f94938.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (30 commits) Ensure text document is created before we access it. Plugins documentation. Fix update issue when an item has an effect and child. Fix QDeclarativeTextInput and QGraphicsView in regards of input methods hints. Disallow "Qt" as namespace import Don't "adjust" the z value of a delegate that has been cached. Correctly inherit extension properties Autotests More QDeclarativeNetworkAccessManagerFactory doc clarification. Fix QDeclarativeNetworkAccessManagerFactory docs. Don't crash on invalid model remove signal. Ensure scheduled layout can occur before testing. Fix remaining 4.6 type registrations (to 4.7). doc anchor margins vs. anchor (line) state/animation. These examples should not be included in this test Unify naming of settings / UI to be "Qt Qml Runtime" Improved error messages for type resolving, new debug option Link to example files from tutorial pages Add tutorial for writing QML extensions no export in plugin ...
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/dynamic/qml/itemCreation.js6
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/app.qml17
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro5
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/main.cpp58
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/musician.cpp67
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/musician.h69
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/app.qml19
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro5
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/main.cpp58
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/musician.cpp75
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/musician.h82
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/app.qml31
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro5
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/main.cpp58
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp77
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/musician.h83
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml13
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro7
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp57
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h64
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp67
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp68
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h79
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/app.qml13
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro15
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp57
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/instrument.h62
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp68
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/musician.h69
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp55
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h56
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/qmldir1
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/samegame1.qmlproject16
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/samegame.js8
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/samegame2.qmlproject16
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.js8
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame3.qmlproject16
-rwxr-xr-xexamples/declarative/tutorials/samegame/samegame4/content/samegame.js8
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/samegame4.qmlproject16
-rw-r--r--examples/declarative/workerscript/workerscript.qml6
40 files changed, 1542 insertions, 18 deletions
diff --git a/examples/declarative/dynamic/qml/itemCreation.js b/examples/declarative/dynamic/qml/itemCreation.js
index 4fa0d9f..98d48a8 100644
--- a/examples/declarative/dynamic/qml/itemCreation.js
+++ b/examples/declarative/dynamic/qml/itemCreation.js
@@ -32,7 +32,7 @@ function loadComponent() {
createItem();
itemComponent = Qt.createComponent(itemButton.file);
- //print(itemButton.file)
+ //console.log(itemButton.file)
if(itemComponent.isLoading){
component.statusChanged.connect(finishCreation);
}else{//Depending on the content, it can be ready or error immediately
@@ -51,8 +51,8 @@ function createItem() {
draggedItem.z = 4;//On top
} else if (itemComponent.isError) {
draggedItem = null;
- print("error creating component");
- print(component.errorsString());
+ console.log("error creating component");
+ console.log(component.errorsString());
}
}
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/app.qml b/examples/declarative/tutorials/extending/chapter1-basics/app.qml
new file mode 100644
index 0000000..15dcd2d
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter1-basics/app.qml
@@ -0,0 +1,17 @@
+import Music 1.0
+import Qt 4.7
+
+Rectangle {
+ width: 300; height: 200
+
+ Musician {
+ id: aMusician
+ name: "Reddy the Rocker"
+ instrument: "Guitar"
+ }
+
+ Text {
+ anchors.fill: parent
+ text: aMusician.name + " plays the " + aMusician.instrument
+ }
+}
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro
new file mode 100644
index 0000000..bd05ebe
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro
@@ -0,0 +1,5 @@
+QT += declarative
+
+HEADERS += musician.h
+SOURCES += musician.cpp \
+ main.cpp
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/main.cpp b/examples/declarative/tutorials/extending/chapter1-basics/main.cpp
new file mode 100644
index 0000000..0e71bb0
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter1-basics/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** 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 documentation 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$
+**
+****************************************************************************/
+//![0]
+#include "musician.h"
+#include <qdeclarative.h>
+#include <QDeclarativeView>
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ qmlRegisterType<Musician>("Music", 1, 0, "Musician");
+
+ QDeclarativeView view;
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/musician.cpp b/examples/declarative/tutorials/extending/chapter1-basics/musician.cpp
new file mode 100644
index 0000000..b545f84
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter1-basics/musician.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** 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 documentation 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 "musician.h"
+
+Musician::Musician(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Musician::name() const
+{
+ return m_name;
+}
+
+void Musician::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QString Musician::instrument() const
+{
+ return m_instrument;
+}
+
+void Musician::setInstrument(const QString &instrument)
+{
+ m_instrument = instrument;
+}
+
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/musician.h b/examples/declarative/tutorials/extending/chapter1-basics/musician.h
new file mode 100644
index 0000000..70ade82
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter1-basics/musician.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** 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 documentation 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$
+**
+****************************************************************************/
+#ifndef MUSICIAN_H
+#define MUSICIAN_H
+
+//![0]
+#include <QObject>
+
+class Musician : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString instrument READ instrument WRITE setInstrument)
+
+public:
+ Musician(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QString instrument() const;
+ void setInstrument(const QString &instrument);
+
+private:
+ QString m_name;
+ QString m_instrument;
+};
+//![0]
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/app.qml b/examples/declarative/tutorials/extending/chapter2-methods/app.qml
new file mode 100644
index 0000000..35e083e
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter2-methods/app.qml
@@ -0,0 +1,19 @@
+import Music 1.0
+import Qt 4.7
+
+Rectangle {
+ width: 200; height: 200
+
+ Musician {
+ id: aMusician
+ name: "Reddy the Rocker"
+ instrument: "Guitar"
+
+ onPerformanceEnded: console.log("The performance has now ended")
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: aMusician.perform()
+ }
+}
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro
new file mode 100644
index 0000000..bd05ebe
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro
@@ -0,0 +1,5 @@
+QT += declarative
+
+HEADERS += musician.h
+SOURCES += musician.cpp \
+ main.cpp
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/main.cpp b/examples/declarative/tutorials/extending/chapter2-methods/main.cpp
new file mode 100644
index 0000000..0e71bb0
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter2-methods/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** 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 documentation 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$
+**
+****************************************************************************/
+//![0]
+#include "musician.h"
+#include <qdeclarative.h>
+#include <QDeclarativeView>
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ qmlRegisterType<Musician>("Music", 1, 0, "Musician");
+
+ QDeclarativeView view;
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/musician.cpp b/examples/declarative/tutorials/extending/chapter2-methods/musician.cpp
new file mode 100644
index 0000000..3df19e3
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter2-methods/musician.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** 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 documentation 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 "musician.h"
+#include <QDebug>
+
+Musician::Musician(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Musician::name() const
+{
+ return m_name;
+}
+
+void Musician::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QString Musician::instrument() const
+{
+ return m_instrument;
+}
+
+void Musician::setInstrument(const QString &instrument)
+{
+ m_instrument = instrument;
+}
+
+//![0]
+void Musician::perform()
+{
+ qWarning() << m_name << "is playing the" << m_instrument;
+ emit performanceEnded();
+}
+//![0]
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/musician.h b/examples/declarative/tutorials/extending/chapter2-methods/musician.h
new file mode 100644
index 0000000..dc48759
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter2-methods/musician.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** 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 documentation 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$
+**
+****************************************************************************/
+#ifndef MUSICIAN_H
+#define MUSICIAN_H
+
+#include <QObject>
+
+//![0]
+class Musician : public QObject
+{
+//![0]
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString instrument READ instrument WRITE setInstrument)
+
+//![1]
+public:
+//![1]
+
+ Musician(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QString instrument() const;
+ void setInstrument(const QString &instrument);
+
+//![2]
+ Q_INVOKABLE void perform();
+
+signals:
+ void performanceEnded();
+//![2]
+
+private:
+ QString m_name;
+ QString m_instrument;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml
new file mode 100644
index 0000000..0460b0b
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml
@@ -0,0 +1,31 @@
+import Music 1.0
+import Qt 4.7
+
+Rectangle {
+ width: 200; height: 200
+
+ Musician {
+ id: reddy
+ name: "Reddy the Rocker"
+ instrument: "Guitar"
+ }
+
+ Musician {
+ id: craig
+ name: "Craig the Copycat"
+ instrument: reddy.instrument
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ reddy.perform()
+ craig.perform()
+
+ reddy.instrument = "Drums"
+
+ reddy.perform()
+ craig.perform()
+ }
+ }
+}
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
new file mode 100644
index 0000000..bd05ebe
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
@@ -0,0 +1,5 @@
+QT += declarative
+
+HEADERS += musician.h
+SOURCES += musician.cpp \
+ main.cpp
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp
new file mode 100644
index 0000000..0e71bb0
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** 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 documentation 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$
+**
+****************************************************************************/
+//![0]
+#include "musician.h"
+#include <qdeclarative.h>
+#include <QDeclarativeView>
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ qmlRegisterType<Musician>("Music", 1, 0, "Musician");
+
+ QDeclarativeView view;
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+}
+//![0]
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp
new file mode 100644
index 0000000..eb615f6
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** 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 documentation 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 "musician.h"
+#include <QDebug>
+
+Musician::Musician(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Musician::name() const
+{
+ return m_name;
+}
+
+void Musician::setName(const QString &name)
+{
+ m_name = name;
+}
+
+QString Musician::instrument() const
+{
+ return m_instrument;
+}
+
+//![0]
+void Musician::setInstrument(const QString &instrument)
+{
+ if (instrument != m_instrument) {
+ m_instrument = instrument;
+ emit instrumentChanged();
+ }
+}
+//![0]
+
+void Musician::perform()
+{
+ qWarning() << m_name << "is playing the" << m_instrument;
+}
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/musician.h b/examples/declarative/tutorials/extending/chapter3-bindings/musician.h
new file mode 100644
index 0000000..39887be
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/musician.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** 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 documentation 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$
+**
+****************************************************************************/
+#ifndef MUSICIAN_H
+#define MUSICIAN_H
+
+#include <QObject>
+
+//![0]
+class Musician : public QObject
+{
+//![0]
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString instrument READ instrument WRITE setInstrument)
+
+//![1]
+ Q_PROPERTY(QString instrument READ instrument WRITE setInstrument NOTIFY instrumentChanged)
+public:
+//![1]
+
+ Musician(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ QString instrument() const;
+ void setInstrument(const QString &instrument);
+
+ Q_INVOKABLE void perform();
+
+//![2]
+signals:
+ void instrumentChanged();
+//![2]
+
+private:
+ QString m_name;
+ QString m_instrument;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
new file mode 100644
index 0000000..ae9272e
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
@@ -0,0 +1,13 @@
+import Music 1.0
+import Qt 4.7
+
+Item {
+
+ Musician {
+ id: reddy
+ name: "Reddy the Rocker"
+ instrument: Instrument { type: "Guitar" }
+ }
+
+ Component.onCompleted: console.log("Reddy plays the " + reddy.instrument.type)
+}
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
new file mode 100644
index 0000000..aea07a0
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
@@ -0,0 +1,7 @@
+QT += declarative
+
+HEADERS += musician.h \
+ instrument.h
+SOURCES += musician.cpp \
+ instrument.cpp \
+ main.cpp
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp
new file mode 100644
index 0000000..13cd2fe
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** 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 documentation 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 "instrument.h"
+
+Instrument::Instrument(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Instrument::type() const
+{
+ return m_type;
+}
+
+void Instrument::setType(const QString &type)
+{
+ m_type = type;
+}
+
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h
new file mode 100644
index 0000000..e2f09be
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** 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 documentation 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$
+**
+****************************************************************************/
+#ifndef INSTRUMENT_H
+#define INSTRUMENT_H
+
+#include <QObject>
+
+//![0]
+class Instrument : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString type READ type WRITE setType)
+
+public:
+ Instrument(QObject *parent = 0);
+
+ QString type() const;
+ void setType(const QString &type);
+
+private:
+ QString m_type;
+};
+//![0]
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp
new file mode 100644
index 0000000..cbbbc0f
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** 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 documentation 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 "musician.h"
+#include "instrument.h"
+
+#include <qdeclarative.h>
+#include <QDeclarativeView>
+#include <QApplication>
+
+//![0]
+int main(int argc, char *argv[])
+{
+//![0]
+ QApplication app(argc, argv);
+
+ qmlRegisterType<Musician>("Music", 1, 0, "Musician");
+
+//![1]
+ qmlRegisterType<Instrument>("Music", 1, 0, "Instrument");
+//![1]
+
+ QDeclarativeView view;
+ view.setSource(QUrl::fromLocalFile("app.qml"));
+ view.show();
+ return app.exec();
+
+//![2]
+}
+//![2]
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp
new file mode 100644
index 0000000..6b66d5d
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** 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 documentation 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 "musician.h"
+#include "instrument.h"
+
+Musician::Musician(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Musician::name() const
+{
+ return m_name;
+}
+
+void Musician::setName(const QString &name)
+{
+ m_name = name;
+}
+
+Instrument *Musician::instrument() const
+{
+ return m_instrument;
+}
+
+void Musician::setInstrument(Instrument *instrument)
+{
+ m_instrument = instrument;
+}
+
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h
new file mode 100644
index 0000000..d0aa118
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** 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 documentation 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$
+**
+****************************************************************************/
+#ifndef MUSICIAN_H
+#define MUSICIAN_H
+
+#include <QObject>
+
+class Instrument;
+
+//![0]
+class Musician : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(Instrument* instrument READ instrument WRITE setInstrument)
+//![0]
+ Q_PROPERTY(QString name READ name WRITE setName)
+
+//![1]
+public:
+//![1]
+
+ Musician(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+//![2]
+ Instrument *instrument() const;
+ void setInstrument(Instrument *instrument);
+//![2]
+
+private:
+ QString m_name;
+ Instrument *m_instrument;
+
+//![3]
+};
+//![3]
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/app.qml b/examples/declarative/tutorials/extending/chapter5-plugins/app.qml
new file mode 100644
index 0000000..51c1232
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/app.qml
@@ -0,0 +1,13 @@
+import Qt 4.7
+
+Item {
+
+ Musician {
+ id: reddy
+ name: "Reddy the Rocker"
+ instrument: Instrument { type: "Guitar" }
+ }
+
+ Component.onCompleted: console.log("Reddy plays the " + reddy.instrument.type)
+}
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro b/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro
new file mode 100644
index 0000000..7ec68e9
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro
@@ -0,0 +1,15 @@
+TEMPLATE = lib
+CONFIG += qt plugin
+QT += declarative
+
+HEADERS += musician.h \
+ instrument.h \
+ musicplugin.h
+
+SOURCES += musician.cpp \
+ instrument.cpp \
+ musicplugin.cpp
+
+DESTDIR = lib
+OBJECTS_DIR = tmp
+MOC_DIR = tmp
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp
new file mode 100644
index 0000000..13cd2fe
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** 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 documentation 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 "instrument.h"
+
+Instrument::Instrument(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Instrument::type() const
+{
+ return m_type;
+}
+
+void Instrument::setType(const QString &type)
+{
+ m_type = type;
+}
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/instrument.h b/examples/declarative/tutorials/extending/chapter5-plugins/instrument.h
new file mode 100644
index 0000000..15f9fae
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/instrument.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** 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 documentation 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$
+**
+****************************************************************************/
+#ifndef INSTRUMENT_H
+#define INSTRUMENT_H
+
+#include <QObject>
+
+class Instrument : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString type READ type WRITE setType)
+
+public:
+ Instrument(QObject *parent = 0);
+
+ QString type() const;
+ void setType(const QString &type);
+
+private:
+ QString m_type;
+};
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp
new file mode 100644
index 0000000..6b66d5d
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** 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 documentation 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 "musician.h"
+#include "instrument.h"
+
+Musician::Musician(QObject *parent)
+ : QObject(parent)
+{
+}
+
+QString Musician::name() const
+{
+ return m_name;
+}
+
+void Musician::setName(const QString &name)
+{
+ m_name = name;
+}
+
+Instrument *Musician::instrument() const
+{
+ return m_instrument;
+}
+
+void Musician::setInstrument(Instrument *instrument)
+{
+ m_instrument = instrument;
+}
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/musician.h b/examples/declarative/tutorials/extending/chapter5-plugins/musician.h
new file mode 100644
index 0000000..3c3eb2e
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/musician.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** 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 documentation 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$
+**
+****************************************************************************/
+#ifndef MUSICIAN_H
+#define MUSICIAN_H
+
+#include <QObject>
+
+class Instrument;
+
+class Musician : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(Instrument* instrument READ instrument WRITE setInstrument)
+
+public:
+ Musician(QObject *parent = 0);
+
+ QString name() const;
+ void setName(const QString &name);
+
+ Instrument *instrument() const;
+ void setInstrument(Instrument *instrument);
+
+private:
+ QString m_name;
+ Instrument *m_instrument;
+};
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp
new file mode 100644
index 0000000..e2f6244
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** 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 documentation 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 "musicplugin.h"
+//![0]
+#include "musician.h"
+#include "instrument.h"
+#include <QtDeclarative/qdeclarative.h>
+
+void MusicPlugin::registerTypes(const char *uri)
+{
+ qmlRegisterType<Musician>(uri, 1, 0, "Musician");
+ qmlRegisterType<Instrument>(uri, 1, 0, "Instrument");
+}
+
+Q_EXPORT_PLUGIN2(musicplugin, MusicPlugin);
+//![0]
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h b/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h
new file mode 100644
index 0000000..df8c9ab
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** 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 documentation 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$
+**
+****************************************************************************/
+#ifndef MUSICPLUGIN_H
+#define MUSICPLUGIN_H
+
+//![0]
+#include <QtDeclarative/QDeclarativeExtensionPlugin>
+
+class MusicPlugin : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri);
+};
+//![0]
+
+#endif
+
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/qmldir b/examples/declarative/tutorials/extending/chapter5-plugins/qmldir
new file mode 100644
index 0000000..c3afd6b
--- /dev/null
+++ b/examples/declarative/tutorials/extending/chapter5-plugins/qmldir
@@ -0,0 +1 @@
+plugin chapter5-plugins lib
diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame1.qmlproject b/examples/declarative/tutorials/samegame/samegame1/samegame1.qmlproject
new file mode 100644
index 0000000..d4909f8
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame1/samegame1.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/samegame2/samegame.js b/examples/declarative/tutorials/samegame/samegame2/samegame.js
index 81da31b..e5c790d 100644
--- a/examples/declarative/tutorials/samegame/samegame2/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame2/samegame.js
@@ -43,8 +43,8 @@ function createBlock(column, row) {
if (component.isReady) {
var dynamicObject = component.createObject();
if (dynamicObject == null) {
- print("error creating block");
- print(component.errorsString());
+ console.log("error creating block");
+ console.log(component.errorsString());
return false;
}
dynamicObject.parent = background;
@@ -54,8 +54,8 @@ function createBlock(column, row) {
dynamicObject.height = blockSize;
board[index(column, row)] = dynamicObject;
} else {
- print("error loading block component");
- print(component.errorsString());
+ console.log("error loading block component");
+ console.log(component.errorsString());
return false;
}
return true;
diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame2.qmlproject b/examples/declarative/tutorials/samegame/samegame2/samegame2.qmlproject
new file mode 100644
index 0000000..d4909f8
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame2/samegame2.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/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js
index eaf47d9..da0f76e 100644
--- a/examples/declarative/tutorials/samegame/samegame3/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.js
@@ -40,8 +40,8 @@ function createBlock(column, row) {
if (component.isReady) {
var dynamicObject = component.createObject();
if (dynamicObject == null) {
- print("error creating block");
- print(component.errorsString());
+ console.log("error creating block");
+ console.log(component.errorsString());
return false;
}
dynamicObject.type = Math.floor(Math.random() * 3);
@@ -52,8 +52,8 @@ function createBlock(column, row) {
dynamicObject.height = gameCanvas.blockSize;
board[index(column, row)] = dynamicObject;
} else {
- print("error loading block component");
- print(component.errorsString());
+ console.log("error loading block component");
+ console.log(component.errorsString());
return false;
}
return true;
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame3.qmlproject b/examples/declarative/tutorials/samegame/samegame3/samegame3.qmlproject
new file mode 100644
index 0000000..d4909f8
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame3.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/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
index c527f66..1454f0b 100755
--- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
@@ -51,8 +51,8 @@ function createBlock(column, row) {
if (component.isReady) {
var dynamicObject = component.createObject();
if (dynamicObject == null) {
- print("error creating block");
- print(component.errorsString());
+ console.log("error creating block");
+ console.log(component.errorsString());
return false;
}
dynamicObject.type = Math.floor(Math.random() * 3);
@@ -65,8 +65,8 @@ function createBlock(column, row) {
dynamicObject.spawned = true;
board[index(column, row)] = dynamicObject;
} else {
- print("error loading block component");
- print(component.errorsString());
+ console.log("error loading block component");
+ console.log(component.errorsString());
return false;
}
return true;
diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame4.qmlproject b/examples/declarative/tutorials/samegame/samegame4/samegame4.qmlproject
new file mode 100644
index 0000000..d4909f8
--- /dev/null
+++ b/examples/declarative/tutorials/samegame/samegame4/samegame4.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.qml b/examples/declarative/workerscript/workerscript.qml
index 6c6253b..2294a81 100644
--- a/examples/declarative/workerscript/workerscript.qml
+++ b/examples/declarative/workerscript/workerscript.qml
@@ -8,9 +8,9 @@ Rectangle {
source: "workerscript.js"
onMessage: {
- print("Moved " + messageObject.xmove + " along the X axis.");
- print("Moved " + messageObject.ymove + " along the Y axis.");
- print("Moved " + messageObject.move + " pixels.");
+ console.log("Moved " + messageObject.xmove + " along the X axis.");
+ console.log("Moved " + messageObject.ymove + " along the Y axis.");
+ console.log("Moved " + messageObject.move + " pixels.");
}
}