Update extension tutorials and examples to QtQuick2
authorDamian Jansen <damian.jansen@nokia.com>
Tue, 30 Aug 2011 06:18:20 +0000 (16:18 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 5 Sep 2011 01:09:09 +0000 (03:09 +0200)
Also add missing licence header and update example tests

Change-Id: Ic2dc8c893ddf22f646eaeba86b6f3b4a2772726c
Reviewed-on: http://codereview.qt.nokia.com/3844
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
50 files changed:
examples/declarative/cppextensions/imageprovider/imageprovider-example.qml
examples/declarative/cppextensions/imageprovider/imageprovider.cpp
examples/declarative/cppextensions/imageprovider/imageprovider.pro
examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp
examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro
examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml
examples/declarative/cppextensions/plugins/README
examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml
examples/declarative/cppextensions/plugins/plugins.qml
examples/declarative/cppextensions/referenceexamples/methods/example.qml
examples/declarative/dragtarget/text/dragtext.qml
examples/declarative/tutorials/extending/chapter1-basics/app.qml
examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro
examples/declarative/tutorials/extending/chapter1-basics/main.cpp
examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp
examples/declarative/tutorials/extending/chapter1-basics/piechart.h
examples/declarative/tutorials/extending/chapter2-methods/app.qml
examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro
examples/declarative/tutorials/extending/chapter2-methods/main.cpp
examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp
examples/declarative/tutorials/extending/chapter2-methods/piechart.h
examples/declarative/tutorials/extending/chapter3-bindings/app.qml
examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
examples/declarative/tutorials/extending/chapter3-bindings/main.cpp
examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp
examples/declarative/tutorials/extending/chapter3-bindings/piechart.h
examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp
examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp
examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h
examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp
examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h
examples/declarative/tutorials/extending/chapter5-listproperties/app.qml
examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro
examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp
examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp
examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h
examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp
examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h
examples/declarative/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir [new file with mode: 0644]
examples/declarative/tutorials/extending/chapter6-plugins/app.qml
examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro
examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp
examples/declarative/tutorials/extending/chapter6-plugins/piechart.h
examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp
examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h
examples/declarative/tutorials/extending/chapter6-plugins/qmldir [deleted file]
tests/auto/declarative/examples/examples.pro
tests/auto/declarative/examples/tst_examples.cpp

index f8f7b0e..f4e3741 100644 (file)
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
 import "ImageProviderCore" // import the plugin that registers the color image provider
 
 //![0]
 Column {
-    Image { source: "source://colors/yellow" }
-    Image { source: "source://colors/red" }
+    Image { source: "image://colors/yellow" }
+    Image { source: "image://colors/red" }
 }
 //![0]
 
index 730ce4b..5078a97 100644 (file)
 #include <qdeclarativeextensionplugin.h>
 
 #include <qdeclarativeengine.h>
-#include <qdeclarative.h>
-#include <qdeclarativeitem.h>
 #include <qdeclarativeimageprovider.h>
-#include <qdeclarativeview.h>
 #include <QImage>
 #include <QPainter>
 
index 5a91503..eaa48cd 100644 (file)
@@ -1,6 +1,6 @@
 TEMPLATE = lib
 CONFIG += qt plugin
-QT += declarative qtquick1
+QT += declarative
 
 DESTDIR = ImageProviderCore
 TARGET  = qmlimageproviderplugin
index 665feac..2da6e3c 100644 (file)
@@ -44,7 +44,7 @@
 
 #include <QDeclarativeEngine>
 #include <QDeclarativeNetworkAccessManagerFactory>
-#include <QDeclarativeView>
+#include <QSGView>
 
 
 /*
@@ -97,7 +97,7 @@ int main(int argc, char ** argv)
         }
     }
 
-    QDeclarativeView view;
+    QSGView view;
     view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory);
 
     view.setSource(source);
index ba0498e..74d8db3 100644 (file)
@@ -2,7 +2,7 @@ TEMPLATE = app
 TARGET = networkaccessmanagerfactory
 DEPENDPATH += .
 INCLUDEPATH += .
-QT += declarative network qtquick1
+QT += declarative network
 
 # Input
 SOURCES += main.cpp 
index e002ef6..e335396 100644 (file)
@@ -38,7 +38,7 @@
 **
 ****************************************************************************/
 
-import QtQuick 1.0
+import QtQuick 2.0
 
 Image {
     width: 100
index 95e0eea..f4f9074 100644 (file)
@@ -5,5 +5,5 @@ by a C++ plugin (providing the "Time" type), and by QML files (providing the
 To run:
 
   make install
-  qmlviewer -I . plugins.qml
+  QML_IMPORT_PATH=$PWD qmlscene plugins.qml
 
index 465f164..59a7894 100644 (file)
@@ -38,7 +38,7 @@
 **
 ****************************************************************************/
 
-import QtQuick 1.0
+import QtQuick 2.0
 
 Rectangle {
     id: clock
index a61af15..4a6f25f 100644 (file)
@@ -48,5 +48,6 @@ Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml)
 
     hours: time.hour
     minutes: time.minute
+
 }
 //![0]
index 868473a..c32ce4a 100644 (file)
@@ -38,7 +38,7 @@
 **
 ****************************************************************************/
 
-import QtQuick 1.0
+import QtQuick 2.0
 import People 1.0
 
 // ![0]
index c4a4f24..49858d1 100644 (file)
@@ -1,3 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+**     the names of its contributors may be used to endorse or promote
+**     products derived from this software without specific prior written
+**     permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
 import QtQuick 2.0
 
 Item {
index f42ec1e..92dd147 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 //![0]
 import Charts 1.0
-import QtQuick 1.0
+import QtQuick 2.0
 
 Item {
     width: 300; height: 200
index 2ab2e2b..4c11768 100644 (file)
@@ -39,8 +39,7 @@
 ****************************************************************************/
 //![0]
 #include "piechart.h"
-#include <qdeclarative.h>
-#include <QDeclarativeView>
+#include <QSGView>
 #include <QApplication>
 
 int main(int argc, char *argv[])
@@ -49,7 +48,8 @@ int main(int argc, char *argv[])
 
     qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
 
-    QDeclarativeView view;
+    QSGView view;
+    view.setResizeMode(QSGView::SizeRootObjectToView);
     view.setSource(QUrl::fromLocalFile("app.qml"));
     view.show();
     return app.exec();
index bfc1645..5820c56 100644 (file)
 #include <QPainter>
 
 //![0]
-PieChart::PieChart(QDeclarativeItem *parent)
-    : QDeclarativeItem(parent)
+PieChart::PieChart(QSGItem *parent)
+    : QSGPaintedItem(parent)
 {
-    // need to disable this flag to draw inside a QDeclarativeItem
-    setFlag(QGraphicsItem::ItemHasNoContents, false);
 }
 //![0]
 
@@ -70,11 +68,11 @@ void PieChart::setColor(const QColor &color)
 }
 
 //![1]
-void PieChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+void PieChart::paint(QPainter *painter)
 {
     QPen pen(m_color, 2);
     painter->setPen(pen);
-    painter->setRenderHints(QPainter::Antialiasing, true);
+    painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
     painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
 }
 //![1]
index c873f6a..a5afec5 100644 (file)
 #define PIECHART_H
 
 //![0]
-#include <QDeclarativeItem>
+#include <QtDeclarative/QSGPaintedItem>
 #include <QColor>
 
-class PieChart : public QDeclarativeItem
+class PieChart : public QSGPaintedItem
 {
     Q_OBJECT
     Q_PROPERTY(QString name READ name WRITE setName)
     Q_PROPERTY(QColor color READ color WRITE setColor)
 
 public:
-    PieChart(QDeclarativeItem *parent = 0);
+    PieChart(QSGItem *parent = 0);
 
     QString name() const;
     void setName(const QString &name);
@@ -59,7 +59,7 @@ public:
     QColor color() const;
     void setColor(const QColor &color);
 
-    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+    void paint(QPainter *painter);
 
 private:
     QString m_name;
index e2f34c7..05f5952 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 //![0]
 import Charts 1.0
-import QtQuick 1.0
+import QtQuick 2.0
 
 Item {
     width: 300; height: 200
index 2ab2e2b..4c11768 100644 (file)
@@ -39,8 +39,7 @@
 ****************************************************************************/
 //![0]
 #include "piechart.h"
-#include <qdeclarative.h>
-#include <QDeclarativeView>
+#include <QSGView>
 #include <QApplication>
 
 int main(int argc, char *argv[])
@@ -49,7 +48,8 @@ int main(int argc, char *argv[])
 
     qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
 
-    QDeclarativeView view;
+    QSGView view;
+    view.setResizeMode(QSGView::SizeRootObjectToView);
     view.setSource(QUrl::fromLocalFile("app.qml"));
     view.show();
     return app.exec();
index 78970e5..86407f1 100644 (file)
 ****************************************************************************/
 #include "piechart.h"
 #include <QPainter>
-#include <QDebug>
 
-PieChart::PieChart(QDeclarativeItem *parent)
-    : QDeclarativeItem(parent)
+PieChart::PieChart(QSGItem *parent)
+    : QSGPaintedItem(parent)
 {
-    // need to disable this flag to draw inside a QDeclarativeItem
-    setFlag(QGraphicsItem::ItemHasNoContents, false);
 }
 
 QString PieChart::name() const
@@ -68,11 +65,11 @@ void PieChart::setColor(const QColor &color)
     m_color = color;
 }
 
-void PieChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+void PieChart::paint(QPainter *painter)
 {
     QPen pen(m_color, 2);
     painter->setPen(pen);
-    painter->setRenderHints(QPainter::Antialiasing, true);
+    painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
     painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
 }
 
index bfcbd80..38f5c05 100644 (file)
 #ifndef PIECHART_H
 #define PIECHART_H
 
-#include <QDeclarativeItem>
+#include <QtDeclarative/QSGPaintedItem>
 #include <QColor>
 
 //![0]
-class PieChart : public QDeclarativeItem
+class PieChart : public QSGPaintedItem
 {
 //![0]
     Q_OBJECT
@@ -55,7 +55,7 @@ class PieChart : public QDeclarativeItem
 public:
 //![1]
 
-    PieChart(QDeclarativeItem *parent = 0);
+    PieChart(QSGItem *parent = 0);
 
     QString name() const;
     void setName(const QString &name);
@@ -63,7 +63,7 @@ public:
     QColor color() const;
     void setColor(const QColor &color);
 
-    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+    void paint(QPainter *painter);
 
 //![2]
     Q_INVOKABLE void clearChart();
index b4ad5ef..996a828 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 //![0]
 import Charts 1.0
-import QtQuick 1.0
+import QtQuick 2.0
 
 Item {
     width: 300; height: 200
index 2ab2e2b..4c11768 100644 (file)
@@ -39,8 +39,7 @@
 ****************************************************************************/
 //![0]
 #include "piechart.h"
-#include <qdeclarative.h>
-#include <QDeclarativeView>
+#include <QSGView>
 #include <QApplication>
 
 int main(int argc, char *argv[])
@@ -49,7 +48,8 @@ int main(int argc, char *argv[])
 
     qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
 
-    QDeclarativeView view;
+    QSGView view;
+    view.setResizeMode(QSGView::SizeRootObjectToView);
     view.setSource(QUrl::fromLocalFile("app.qml"));
     view.show();
     return app.exec();
index 375025e..86ad6a7 100644 (file)
 ****************************************************************************/
 #include "piechart.h"
 #include <QPainter>
-#include <QDebug>
 
-PieChart::PieChart(QDeclarativeItem *parent)
-    : QDeclarativeItem(parent)
+PieChart::PieChart(QSGItem *parent)
+    : QSGPaintedItem(parent)
 {
-    // need to disable this flag to draw inside a QDeclarativeItem
-    setFlag(QGraphicsItem::ItemHasNoContents, false);
 }
 
 QString PieChart::name() const
@@ -74,11 +71,11 @@ void PieChart::setColor(const QColor &color)
 }
 //![0]
 
-void PieChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+void PieChart::paint(QPainter *painter)
 {
     QPen pen(m_color, 2);
     painter->setPen(pen);
-    painter->setRenderHints(QPainter::Antialiasing, true);
+    painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
     painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
 }
 
index feff9c4..5208f81 100644 (file)
 #ifndef PIECHART_H
 #define PIECHART_H
 
-#include <QDeclarativeItem>
 #include <QColor>
+#include <QtDeclarative/QSGPaintedItem>
 
 //![0]
-class PieChart : public QDeclarativeItem
+class PieChart : public QSGPaintedItem
 {
 //![0]
     Q_OBJECT
@@ -55,7 +55,7 @@ class PieChart : public QDeclarativeItem
 public:
 //![1]
 
-    PieChart(QDeclarativeItem *parent = 0);
+    PieChart(QSGItem *parent = 0);
 
     QString name() const;
     void setName(const QString &name);
@@ -63,7 +63,7 @@ public:
     QColor color() const;
     void setColor(const QColor &color);
 
-    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+    void paint(QPainter *painter);
 
     Q_INVOKABLE void clearChart();
 
index 187095a..68f667a 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 //![0]
 import Charts 1.0
-import QtQuick 1.0
+import QtQuick 2.0
 
 Item {
     width: 300; height: 200
index dcb3481..1113cc5 100644 (file)
@@ -40,8 +40,7 @@
 #include "piechart.h"
 #include "pieslice.h"
 
-#include <qdeclarative.h>
-#include <QDeclarativeView>
+#include <QSGView>
 #include <QApplication>
 
 //![0]
@@ -56,7 +55,8 @@ int main(int argc, char *argv[])
     qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
 //![1]
 
-    QDeclarativeView view;
+    QSGView view;
+    view.setResizeMode(QSGView::SizeRootObjectToView);
     view.setSource(QUrl::fromLocalFile("app.qml"));
     view.show();
     return app.exec();
index b1f4278..5911f4d 100644 (file)
 #include "piechart.h"
 #include "pieslice.h"
 
-PieChart::PieChart(QDeclarativeItem *parent)
-    : QDeclarativeItem(parent)
+PieChart::PieChart(QSGItem *parent)
+    : QSGItem(parent)
 {
-    // this doesn't need to disable QGraphicsItem::ItemHasNoContents
-    // anymore since the drawing is now done in PieSlice
 }
 
 QString PieChart::name() const
index d7f4473..9e81398 100644 (file)
 #ifndef PIECHART_H
 #define PIECHART_H
 
-#include <QDeclarativeItem>
+#include <QtDeclarative/QSGItem>
 
 class PieSlice;
 
 //![0]
-class PieChart : public QDeclarativeItem
+class PieChart : public QSGItem
 {
     Q_OBJECT
     Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice)
@@ -56,7 +56,7 @@ class PieChart : public QDeclarativeItem
 public:
 //![1]
 
-    PieChart(QDeclarativeItem *parent = 0);
+    PieChart(QSGItem *parent = 0);
 
     QString name() const;
     void setName(const QString &name);
index f36c8ce..764ef23 100644 (file)
 
 #include <QPainter>
 
-PieSlice::PieSlice(QDeclarativeItem *parent)
-    : QDeclarativeItem(parent)
+PieSlice::PieSlice(QSGItem *parent)
+    : QSGPaintedItem(parent)
 {
-    // need to disable this flag to draw inside a QDeclarativeItem
-    setFlag(QGraphicsItem::ItemHasNoContents, false);
 }
 
 QColor PieSlice::color() const
@@ -58,11 +56,11 @@ void PieSlice::setColor(const QColor &color)
     m_color = color;
 }
 
-void PieSlice::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+void PieSlice::paint(QPainter *painter)
 {
     QPen pen(m_color, 2);
     painter->setPen(pen);
-    painter->setRenderHints(QPainter::Antialiasing, true);
+    painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
     painter->drawPie(boundingRect(), 90 * 16, 290 * 16);
 }
 
index 6e5707f..7163864 100644 (file)
 #ifndef PIESLICE_H
 #define PIESLICE_H
 
-#include <QDeclarativeItem>
+#include <QtDeclarative/QSGPaintedItem>
 #include <QColor>
 
 //![0]
-class PieSlice : public QDeclarativeItem
+class PieSlice : public QSGPaintedItem
 {
     Q_OBJECT
     Q_PROPERTY(QColor color READ color WRITE setColor)
 
 public:
-    PieSlice(QDeclarativeItem *parent = 0);
+    PieSlice(QSGItem *parent = 0);
 
     QColor color() const;
     void setColor(const QColor &color);
 
-    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+    void paint(QPainter *painter);
 
 private:
     QColor m_color;
index 0fc8558..99bc1c5 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 //![0]
 import Charts 1.0
-import QtQuick 1.0
+import QtQuick 2.0
 
 Item {
     width: 300; height: 200
index 5a50567..1c43a09 100644 (file)
@@ -40,8 +40,7 @@
 #include "piechart.h"
 #include "pieslice.h"
 
-#include <qdeclarative.h>
-#include <QDeclarativeView>
+#include <QSGView>
 #include <QApplication>
 
 int main(int argc, char *argv[])
@@ -51,7 +50,8 @@ int main(int argc, char *argv[])
     qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
     qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
 
-    QDeclarativeView view;
+    QSGView view;
+    view.setResizeMode(QSGView::SizeRootObjectToView);
     view.setSource(QUrl::fromLocalFile("app.qml"));
     view.show();
     return app.exec();
index ea70ff2..248f4a2 100644 (file)
@@ -40,8 +40,8 @@
 #include "piechart.h"
 #include "pieslice.h"
 
-PieChart::PieChart(QDeclarativeItem *parent)
-    : QDeclarativeItem(parent)
+PieChart::PieChart(QSGItem *parent)
+    : QSGItem(parent)
 {
 }
 
index ad15a24..e95b02f 100644 (file)
 #ifndef PIECHART_H
 #define PIECHART_H
 
-#include <QDeclarativeItem>
+#include <QSGItem>
 
 class PieSlice;
 
 //![0]
-class PieChart : public QDeclarativeItem
+class PieChart : public QSGItem
 {
     Q_OBJECT
     Q_PROPERTY(QDeclarativeListProperty<PieSlice> slices READ slices)
@@ -55,7 +55,7 @@ class PieChart : public QDeclarativeItem
 //![1]
 public:
 //![1]
-    PieChart(QDeclarativeItem *parent = 0);
+    PieChart(QSGItem *parent = 0);
 
     QString name() const;
     void setName(const QString &name);
index 16f4bae..70338f0 100644 (file)
 
 #include <QPainter>
 
-PieSlice::PieSlice(QDeclarativeItem *parent)
-    : QDeclarativeItem(parent)
+PieSlice::PieSlice(QSGItem *parent)
+    : QSGPaintedItem(parent)
 {
-    // need to disable this flag to draw inside a QDeclarativeItem
-    setFlag(QGraphicsItem::ItemHasNoContents, false);
 }
 
 QColor PieSlice::color() const
@@ -78,11 +76,11 @@ void PieSlice::setAngleSpan(int angle)
     m_angleSpan = angle;
 }
 
-void PieSlice::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+void PieSlice::paint(QPainter *painter)
 {
     QPen pen(m_color, 2);
     painter->setPen(pen);
-    painter->setRenderHints(QPainter::Antialiasing, true);
+    painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
     painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16);
 }
 
index 877f54b..1204f9a 100644 (file)
 #ifndef PIESLICE_H
 #define PIESLICE_H
 
-#include <QDeclarativeItem>
+#include <QtDeclarative/QSGPaintedItem>
 #include <QColor>
 
 //![0]
-class PieSlice : public QDeclarativeItem
+class PieSlice : public QSGPaintedItem
 {
     Q_OBJECT
     Q_PROPERTY(QColor color READ color WRITE setColor)
@@ -53,7 +53,7 @@ class PieSlice : public QDeclarativeItem
 //![0]
 
 public:
-    PieSlice(QDeclarativeItem *parent = 0);
+    PieSlice(QSGItem *parent = 0);
 
     QColor color() const;
     void setColor(const QColor &color);
@@ -64,7 +64,7 @@ public:
     int angleSpan() const;
     void setAngleSpan(int span);
 
-    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+    void paint(QPainter *painter);
 
 private:
     QColor m_color;
diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir b/examples/declarative/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir
new file mode 100644 (file)
index 0000000..72650d8
--- /dev/null
@@ -0,0 +1 @@
+plugin chartsplugin
\ No newline at end of file
index a8e13b2..67df25a 100644 (file)
@@ -37,7 +37,8 @@
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
+import "ChartsPlugin" 1.0
 
 Item {
     width: 300; height: 200
index e5963ee..47fe0a2 100644 (file)
@@ -1,8 +1,10 @@
 TEMPLATE = lib
 CONFIG += qt plugin
-QT += declarative qtquick1
+QT += declarative
+
+DESTDIR = ChartsPlugin
+TARGET = chartsplugin
 
-DESTDIR = lib
 OBJECTS_DIR = tmp
 MOC_DIR = tmp
 
@@ -14,8 +16,3 @@ SOURCES += piechart.cpp \
            pieslice.cpp \
            chartsplugin.cpp
 
-symbian {
-    CONFIG += qt_example
-    TARGET.EPOCALLOWDLLDATA = 1
-}
-maemo5: CONFIG += qt_example
index 27086f1..5aa4a78 100644 (file)
@@ -40,8 +40,8 @@
 #include "piechart.h"
 #include "pieslice.h"
 
-PieChart::PieChart(QDeclarativeItem *parent)
-    : QDeclarativeItem(parent)
+PieChart::PieChart(QSGItem *parent)
+    : QSGItem(parent)
 {
 }
 
index 1338cad..1e4f122 100644 (file)
 #ifndef PIECHART_H
 #define PIECHART_H
 
-#include <QDeclarativeItem>
+#include <QSGItem>
 
 class PieSlice;
 
-class PieChart : public QDeclarativeItem
+class PieChart : public QSGItem
 {
     Q_OBJECT
     Q_PROPERTY(QDeclarativeListProperty<PieSlice> slices READ slices)
     Q_PROPERTY(QString name READ name WRITE setName)
 
 public:
-    PieChart(QDeclarativeItem *parent = 0);
+    PieChart(QSGItem *parent = 0);
 
     QString name() const;
     void setName(const QString &name);
index 16f4bae..70338f0 100644 (file)
 
 #include <QPainter>
 
-PieSlice::PieSlice(QDeclarativeItem *parent)
-    : QDeclarativeItem(parent)
+PieSlice::PieSlice(QSGItem *parent)
+    : QSGPaintedItem(parent)
 {
-    // need to disable this flag to draw inside a QDeclarativeItem
-    setFlag(QGraphicsItem::ItemHasNoContents, false);
 }
 
 QColor PieSlice::color() const
@@ -78,11 +76,11 @@ void PieSlice::setAngleSpan(int angle)
     m_angleSpan = angle;
 }
 
-void PieSlice::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+void PieSlice::paint(QPainter *painter)
 {
     QPen pen(m_color, 2);
     painter->setPen(pen);
-    painter->setRenderHints(QPainter::Antialiasing, true);
+    painter->setRenderHints(QPainter::HighQualityAntialiasing, true);
     painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16);
 }
 
index 83b728a..3096ee6 100644 (file)
 #ifndef PIESLICE_H
 #define PIESLICE_H
 
-#include <QDeclarativeItem>
+#include <QtDeclarative/QSGPaintedItem>
 #include <QColor>
 
-class PieSlice : public QDeclarativeItem
+class PieSlice : public QSGPaintedItem
 {
     Q_OBJECT
     Q_PROPERTY(QColor color READ color WRITE setColor)
@@ -51,7 +51,7 @@ class PieSlice : public QDeclarativeItem
     Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan)
 
 public:
-    PieSlice(QDeclarativeItem *parent = 0);
+    PieSlice(QSGItem *parent = 0);
 
     QColor color() const;
     void setColor(const QColor &color);
@@ -62,7 +62,7 @@ public:
     int angleSpan() const;
     void setAngleSpan(int span);
 
-    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+    void paint(QPainter *painter);
 
 private:
     QColor m_color;
diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/qmldir b/examples/declarative/tutorials/extending/chapter6-plugins/qmldir
deleted file mode 100644 (file)
index a83bf85..0000000
+++ /dev/null
@@ -1 +0,0 @@
-plugin chapter6-plugins lib
index a19700c..0875e1f 100644 (file)
@@ -1,23 +1,12 @@
 load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative qtquick1
+contains(QT_CONFIG,declarative): QT += declarative
 macx:CONFIG -= app_bundle
 
-SOURCES += tst_examples.cpp 
-
-include(../../../../tools/qmlviewer/qml.pri)
-
-include(../symbianlibs.pri)
-
-symbian: {
-    importFiles.files = data
-    importFiles.path = .
-    DEPLOYMENT += importFiles
-} else {
-    DEFINES += SRCDIR=\\\"$$PWD\\\"
-}
+SOURCES += tst_examples.cpp
+DEFINES += SRCDIR=\\\"$$PWD\\\"
 
 CONFIG += parallel_test
 
-QT += core-private gui-private v8-private declarative-private qtquick1-private
+QT += core-private gui-private v8-private declarative-private
 
 qpa:CONFIG+=insignificant_test  # QTBUG-20990, aborts
index 072ab75..4a3a085 100644 (file)
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
+
 #include <qtest.h>
 #include <QLibraryInfo>
 #include <QDir>
 #include <QProcess>
 #include <QDebug>
-#include "qmlruntime.h"
-#include <QDeclarativeView>
 #include <QSGView>
 #include <QDeclarativeError>
 
-#ifdef Q_OS_SYMBIAN
-// In Symbian OS test data is located in applications private dir
-#define SRCDIR "."
-#endif
-
 class tst_examples : public QObject
 {
     Q_OBJECT
@@ -60,8 +54,6 @@ public:
     tst_examples();
 
 private slots:
-    void examples_data();
-    void examples();
     void sgexamples_data();
     void sgexamples();
 
@@ -185,7 +177,12 @@ that they start and exit cleanly.
 Examples are any .qml files under the examples/ directory that start
 with a lower case letter.
 */
-void tst_examples::examples_data()
+static void silentErrorsMsgHandler(QtMsgType, const char *)
+{
+}
+
+
+void tst_examples::sgexamples_data()
 {
     QTest::addColumn<QString>("file");
 
@@ -200,37 +197,8 @@ void tst_examples::examples_data()
         QTest::newRow(qPrintable(file)) << file;
 }
 
-static void silentErrorsMsgHandler(QtMsgType, const char *)
-{
-}
-
-void tst_examples::examples()
-{
-    QFETCH(QString, file);
-
-    QDeclarativeViewer viewer;
-
-    QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler);
-    QVERIFY(viewer.open(file));
-    qInstallMsgHandler(old);
-
-    if (viewer.view()->status() == QDeclarativeView::Error)
-        qWarning() << viewer.view()->errors();
-
-    QCOMPARE(viewer.view()->status(), QDeclarativeView::Ready);
-    viewer.show();
-
-    QTest::qWaitForWindowShown(&viewer);
-}
-
-void tst_examples::sgexamples_data()
-{
-    examples_data();
-}
-
 void tst_examples::sgexamples()
 {
-    qputenv("QMLSCENE_IMPORT_NAME", "quick1");
     QFETCH(QString, file);
 
     QSGView view;