From 76dd4f8af9c48a685cb50bfa02389b392bc12a5a Mon Sep 17 00:00:00 2001 From: Damian Jansen Date: Tue, 30 Aug 2011 16:18:20 +1000 Subject: [PATCH] Update extension tutorials and examples to QtQuick2 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 Reviewed-by: Glenn Watson --- .../imageprovider/imageprovider-example.qml | 6 +-- .../cppextensions/imageprovider/imageprovider.cpp | 3 -- .../cppextensions/imageprovider/imageprovider.pro | 2 +- .../networkaccessmanagerfactory/main.cpp | 4 +- .../networkaccessmanagerfactory.pro | 2 +- .../networkaccessmanagerfactory/view.qml | 2 +- examples/declarative/cppextensions/plugins/README | 2 +- .../plugins/com/nokia/TimeExample/Clock.qml | 2 +- .../declarative/cppextensions/plugins/plugins.qml | 1 + .../referenceexamples/methods/example.qml | 2 +- examples/declarative/dragtarget/text/dragtext.qml | 40 +++++++++++++++++++ .../tutorials/extending/chapter1-basics/app.qml | 2 +- .../extending/chapter1-basics/chapter1-basics.pro | 2 +- .../tutorials/extending/chapter1-basics/main.cpp | 6 +-- .../extending/chapter1-basics/piechart.cpp | 10 ++--- .../tutorials/extending/chapter1-basics/piechart.h | 8 ++-- .../tutorials/extending/chapter2-methods/app.qml | 2 +- .../chapter2-methods/chapter2-methods.pro | 2 +- .../tutorials/extending/chapter2-methods/main.cpp | 6 +-- .../extending/chapter2-methods/piechart.cpp | 11 ++---- .../extending/chapter2-methods/piechart.h | 8 ++-- .../tutorials/extending/chapter3-bindings/app.qml | 2 +- .../chapter3-bindings/chapter3-bindings.pro | 2 +- .../tutorials/extending/chapter3-bindings/main.cpp | 6 +-- .../extending/chapter3-bindings/piechart.cpp | 11 ++---- .../extending/chapter3-bindings/piechart.h | 8 ++-- .../extending/chapter4-customPropertyTypes/app.qml | 2 +- .../chapter4-customPropertyTypes.pro | 2 +- .../chapter4-customPropertyTypes/main.cpp | 6 +-- .../chapter4-customPropertyTypes/piechart.cpp | 6 +-- .../chapter4-customPropertyTypes/piechart.h | 6 +-- .../chapter4-customPropertyTypes/pieslice.cpp | 10 ++--- .../chapter4-customPropertyTypes/pieslice.h | 8 ++-- .../extending/chapter5-listproperties/app.qml | 2 +- .../chapter5-listproperties.pro | 2 +- .../extending/chapter5-listproperties/main.cpp | 6 +-- .../extending/chapter5-listproperties/piechart.cpp | 4 +- .../extending/chapter5-listproperties/piechart.h | 6 +-- .../extending/chapter5-listproperties/pieslice.cpp | 10 ++--- .../extending/chapter5-listproperties/pieslice.h | 8 ++-- .../extending/chapter6-plugins/ChartsPlugin/qmldir | 1 + .../tutorials/extending/chapter6-plugins/app.qml | 3 +- .../chapter6-plugins/chapter6-plugins.pro | 11 ++---- .../extending/chapter6-plugins/piechart.cpp | 4 +- .../extending/chapter6-plugins/piechart.h | 6 +-- .../extending/chapter6-plugins/pieslice.cpp | 10 ++--- .../extending/chapter6-plugins/pieslice.h | 8 ++-- .../tutorials/extending/chapter6-plugins/qmldir | 1 - tests/auto/declarative/examples/examples.pro | 19 ++------- tests/auto/declarative/examples/tst_examples.cpp | 46 ++++------------------ 50 files changed, 158 insertions(+), 181 deletions(-) create mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir delete mode 100644 examples/declarative/tutorials/extending/chapter6-plugins/qmldir diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml b/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml index f8f7b0e..f4e3741 100644 --- a/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml +++ b/examples/declarative/cppextensions/imageprovider/imageprovider-example.qml @@ -37,13 +37,13 @@ ** $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] diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.cpp b/examples/declarative/cppextensions/imageprovider/imageprovider.cpp index 730ce4b..5078a97 100644 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.cpp +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.cpp @@ -42,10 +42,7 @@ #include #include -#include -#include #include -#include #include #include diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.pro b/examples/declarative/cppextensions/imageprovider/imageprovider.pro index 5a91503..eaa48cd 100644 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.pro +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.pro @@ -1,6 +1,6 @@ TEMPLATE = lib CONFIG += qt plugin -QT += declarative qtquick1 +QT += declarative DESTDIR = ImageProviderCore TARGET = qmlimageproviderplugin diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp b/examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp index 665feac..2da6e3c 100644 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp +++ b/examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp @@ -44,7 +44,7 @@ #include #include -#include +#include /* @@ -97,7 +97,7 @@ int main(int argc, char ** argv) } } - QDeclarativeView view; + QSGView view; view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory); view.setSource(source); diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro index ba0498e..74d8db3 100644 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro +++ b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro @@ -2,7 +2,7 @@ TEMPLATE = app TARGET = networkaccessmanagerfactory DEPENDPATH += . INCLUDEPATH += . -QT += declarative network qtquick1 +QT += declarative network # Input SOURCES += main.cpp diff --git a/examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml b/examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml index e002ef6..e335396 100644 --- a/examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml +++ b/examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Image { width: 100 diff --git a/examples/declarative/cppextensions/plugins/README b/examples/declarative/cppextensions/plugins/README index 95e0eea..f4f9074 100644 --- a/examples/declarative/cppextensions/plugins/README +++ b/examples/declarative/cppextensions/plugins/README @@ -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 diff --git a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml index 465f164..59a7894 100644 --- a/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml +++ b/examples/declarative/cppextensions/plugins/com/nokia/TimeExample/Clock.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: clock diff --git a/examples/declarative/cppextensions/plugins/plugins.qml b/examples/declarative/cppextensions/plugins/plugins.qml index a61af15..4a6f25f 100644 --- a/examples/declarative/cppextensions/plugins/plugins.qml +++ b/examples/declarative/cppextensions/plugins/plugins.qml @@ -48,5 +48,6 @@ Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml) hours: time.hour minutes: time.minute + } //![0] diff --git a/examples/declarative/cppextensions/referenceexamples/methods/example.qml b/examples/declarative/cppextensions/referenceexamples/methods/example.qml index 868473a..c32ce4a 100644 --- a/examples/declarative/cppextensions/referenceexamples/methods/example.qml +++ b/examples/declarative/cppextensions/referenceexamples/methods/example.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import People 1.0 // ![0] diff --git a/examples/declarative/dragtarget/text/dragtext.qml b/examples/declarative/dragtarget/text/dragtext.qml index c4a4f24..49858d1 100644 --- a/examples/declarative/dragtarget/text/dragtext.qml +++ b/examples/declarative/dragtarget/text/dragtext.qml @@ -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 { diff --git a/examples/declarative/tutorials/extending/chapter1-basics/app.qml b/examples/declarative/tutorials/extending/chapter1-basics/app.qml index f42ec1e..92dd147 100644 --- a/examples/declarative/tutorials/extending/chapter1-basics/app.qml +++ b/examples/declarative/tutorials/extending/chapter1-basics/app.qml @@ -39,7 +39,7 @@ ****************************************************************************/ //![0] import Charts 1.0 -import QtQuick 1.0 +import QtQuick 2.0 Item { width: 300; height: 200 diff --git a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro index 77cc4cd..0f04167 100644 --- a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro +++ b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro @@ -1,4 +1,4 @@ -QT += declarative qtquick1 +QT += declarative HEADERS += piechart.h SOURCES += piechart.cpp \ diff --git a/examples/declarative/tutorials/extending/chapter1-basics/main.cpp b/examples/declarative/tutorials/extending/chapter1-basics/main.cpp index 2ab2e2b..4c11768 100644 --- a/examples/declarative/tutorials/extending/chapter1-basics/main.cpp +++ b/examples/declarative/tutorials/extending/chapter1-basics/main.cpp @@ -39,8 +39,7 @@ ****************************************************************************/ //![0] #include "piechart.h" -#include -#include +#include #include int main(int argc, char *argv[]) @@ -49,7 +48,8 @@ int main(int argc, char *argv[]) qmlRegisterType("Charts", 1, 0, "PieChart"); - QDeclarativeView view; + QSGView view; + view.setResizeMode(QSGView::SizeRootObjectToView); view.setSource(QUrl::fromLocalFile("app.qml")); view.show(); return app.exec(); diff --git a/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp b/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp index bfc1645..5820c56 100644 --- a/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp +++ b/examples/declarative/tutorials/extending/chapter1-basics/piechart.cpp @@ -41,11 +41,9 @@ #include //![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] diff --git a/examples/declarative/tutorials/extending/chapter1-basics/piechart.h b/examples/declarative/tutorials/extending/chapter1-basics/piechart.h index c873f6a..a5afec5 100644 --- a/examples/declarative/tutorials/extending/chapter1-basics/piechart.h +++ b/examples/declarative/tutorials/extending/chapter1-basics/piechart.h @@ -41,17 +41,17 @@ #define PIECHART_H //![0] -#include +#include #include -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; diff --git a/examples/declarative/tutorials/extending/chapter2-methods/app.qml b/examples/declarative/tutorials/extending/chapter2-methods/app.qml index e2f34c7..05f5952 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/app.qml +++ b/examples/declarative/tutorials/extending/chapter2-methods/app.qml @@ -39,7 +39,7 @@ ****************************************************************************/ //![0] import Charts 1.0 -import QtQuick 1.0 +import QtQuick 2.0 Item { width: 300; height: 200 diff --git a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro index 77cc4cd..0f04167 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro +++ b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro @@ -1,4 +1,4 @@ -QT += declarative qtquick1 +QT += declarative HEADERS += piechart.h SOURCES += piechart.cpp \ diff --git a/examples/declarative/tutorials/extending/chapter2-methods/main.cpp b/examples/declarative/tutorials/extending/chapter2-methods/main.cpp index 2ab2e2b..4c11768 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/main.cpp +++ b/examples/declarative/tutorials/extending/chapter2-methods/main.cpp @@ -39,8 +39,7 @@ ****************************************************************************/ //![0] #include "piechart.h" -#include -#include +#include #include int main(int argc, char *argv[]) @@ -49,7 +48,8 @@ int main(int argc, char *argv[]) qmlRegisterType("Charts", 1, 0, "PieChart"); - QDeclarativeView view; + QSGView view; + view.setResizeMode(QSGView::SizeRootObjectToView); view.setSource(QUrl::fromLocalFile("app.qml")); view.show(); return app.exec(); diff --git a/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp b/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp index 78970e5..86407f1 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp +++ b/examples/declarative/tutorials/extending/chapter2-methods/piechart.cpp @@ -39,13 +39,10 @@ ****************************************************************************/ #include "piechart.h" #include -#include -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); } diff --git a/examples/declarative/tutorials/extending/chapter2-methods/piechart.h b/examples/declarative/tutorials/extending/chapter2-methods/piechart.h index bfcbd80..38f5c05 100644 --- a/examples/declarative/tutorials/extending/chapter2-methods/piechart.h +++ b/examples/declarative/tutorials/extending/chapter2-methods/piechart.h @@ -40,11 +40,11 @@ #ifndef PIECHART_H #define PIECHART_H -#include +#include #include //![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(); diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml index b4ad5ef..996a828 100644 --- a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml +++ b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml @@ -39,7 +39,7 @@ ****************************************************************************/ //![0] import Charts 1.0 -import QtQuick 1.0 +import QtQuick 2.0 Item { width: 300; height: 200 diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro index 77cc4cd..0f04167 100644 --- a/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro +++ b/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro @@ -1,4 +1,4 @@ -QT += declarative qtquick1 +QT += declarative HEADERS += piechart.h SOURCES += piechart.cpp \ diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp index 2ab2e2b..4c11768 100644 --- a/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp +++ b/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp @@ -39,8 +39,7 @@ ****************************************************************************/ //![0] #include "piechart.h" -#include -#include +#include #include int main(int argc, char *argv[]) @@ -49,7 +48,8 @@ int main(int argc, char *argv[]) qmlRegisterType("Charts", 1, 0, "PieChart"); - QDeclarativeView view; + QSGView view; + view.setResizeMode(QSGView::SizeRootObjectToView); view.setSource(QUrl::fromLocalFile("app.qml")); view.show(); return app.exec(); diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp index 375025e..86ad6a7 100644 --- a/examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp +++ b/examples/declarative/tutorials/extending/chapter3-bindings/piechart.cpp @@ -39,13 +39,10 @@ ****************************************************************************/ #include "piechart.h" #include -#include -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); } diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/piechart.h b/examples/declarative/tutorials/extending/chapter3-bindings/piechart.h index feff9c4..5208f81 100644 --- a/examples/declarative/tutorials/extending/chapter3-bindings/piechart.h +++ b/examples/declarative/tutorials/extending/chapter3-bindings/piechart.h @@ -40,11 +40,11 @@ #ifndef PIECHART_H #define PIECHART_H -#include #include +#include //![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(); diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml index 187095a..68f667a 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml @@ -39,7 +39,7 @@ ****************************************************************************/ //![0] import Charts 1.0 -import QtQuick 1.0 +import QtQuick 2.0 Item { width: 300; height: 200 diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro index 9942ccd..c3f5402 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro @@ -1,4 +1,4 @@ -QT += declarative qtquick1 +QT += declarative HEADERS += piechart.h \ pieslice.h diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp index dcb3481..1113cc5 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp @@ -40,8 +40,7 @@ #include "piechart.h" #include "pieslice.h" -#include -#include +#include #include //![0] @@ -56,7 +55,8 @@ int main(int argc, char *argv[]) qmlRegisterType("Charts", 1, 0, "PieSlice"); //![1] - QDeclarativeView view; + QSGView view; + view.setResizeMode(QSGView::SizeRootObjectToView); view.setSource(QUrl::fromLocalFile("app.qml")); view.show(); return app.exec(); diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp index b1f4278..5911f4d 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp @@ -40,11 +40,9 @@ #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 diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h index d7f4473..9e81398 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h @@ -40,12 +40,12 @@ #ifndef PIECHART_H #define PIECHART_H -#include +#include 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); diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp index f36c8ce..764ef23 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp @@ -41,11 +41,9 @@ #include -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); } diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h index 6e5707f..7163864 100644 --- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h +++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h @@ -40,22 +40,22 @@ #ifndef PIESLICE_H #define PIESLICE_H -#include +#include #include //![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; diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/app.qml b/examples/declarative/tutorials/extending/chapter5-listproperties/app.qml index 0fc8558..99bc1c5 100644 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/app.qml +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/app.qml @@ -39,7 +39,7 @@ ****************************************************************************/ //![0] import Charts 1.0 -import QtQuick 1.0 +import QtQuick 2.0 Item { width: 300; height: 200 diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro index 9942ccd..c3f5402 100644 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro @@ -1,4 +1,4 @@ -QT += declarative qtquick1 +QT += declarative HEADERS += piechart.h \ pieslice.h diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp b/examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp index 5a50567..1c43a09 100644 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/main.cpp @@ -40,8 +40,7 @@ #include "piechart.h" #include "pieslice.h" -#include -#include +#include #include int main(int argc, char *argv[]) @@ -51,7 +50,8 @@ int main(int argc, char *argv[]) qmlRegisterType("Charts", 1, 0, "PieChart"); qmlRegisterType("Charts", 1, 0, "PieSlice"); - QDeclarativeView view; + QSGView view; + view.setResizeMode(QSGView::SizeRootObjectToView); view.setSource(QUrl::fromLocalFile("app.qml")); view.show(); return app.exec(); diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp index ea70ff2..248f4a2 100644 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.cpp @@ -40,8 +40,8 @@ #include "piechart.h" #include "pieslice.h" -PieChart::PieChart(QDeclarativeItem *parent) - : QDeclarativeItem(parent) +PieChart::PieChart(QSGItem *parent) + : QSGItem(parent) { } diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h b/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h index ad15a24..e95b02f 100644 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/piechart.h @@ -40,12 +40,12 @@ #ifndef PIECHART_H #define PIECHART_H -#include +#include class PieSlice; //![0] -class PieChart : public QDeclarativeItem +class PieChart : public QSGItem { Q_OBJECT Q_PROPERTY(QDeclarativeListProperty 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); diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp b/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp index 16f4bae..70338f0 100644 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.cpp @@ -41,11 +41,9 @@ #include -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); } diff --git a/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h b/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h index 877f54b..1204f9a 100644 --- a/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h +++ b/examples/declarative/tutorials/extending/chapter5-listproperties/pieslice.h @@ -40,11 +40,11 @@ #ifndef PIESLICE_H #define PIESLICE_H -#include +#include #include //![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 index 0000000..72650d8 --- /dev/null +++ b/examples/declarative/tutorials/extending/chapter6-plugins/ChartsPlugin/qmldir @@ -0,0 +1 @@ +plugin chartsplugin \ No newline at end of file diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/app.qml b/examples/declarative/tutorials/extending/chapter6-plugins/app.qml index a8e13b2..67df25a 100644 --- a/examples/declarative/tutorials/extending/chapter6-plugins/app.qml +++ b/examples/declarative/tutorials/extending/chapter6-plugins/app.qml @@ -37,7 +37,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 +import "ChartsPlugin" 1.0 Item { width: 300; height: 200 diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro index e5963ee..47fe0a2 100644 --- a/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro +++ b/examples/declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro @@ -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 diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp index 27086f1..5aa4a78 100644 --- a/examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp +++ b/examples/declarative/tutorials/extending/chapter6-plugins/piechart.cpp @@ -40,8 +40,8 @@ #include "piechart.h" #include "pieslice.h" -PieChart::PieChart(QDeclarativeItem *parent) - : QDeclarativeItem(parent) +PieChart::PieChart(QSGItem *parent) + : QSGItem(parent) { } diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/piechart.h b/examples/declarative/tutorials/extending/chapter6-plugins/piechart.h index 1338cad..1e4f122 100644 --- a/examples/declarative/tutorials/extending/chapter6-plugins/piechart.h +++ b/examples/declarative/tutorials/extending/chapter6-plugins/piechart.h @@ -40,18 +40,18 @@ #ifndef PIECHART_H #define PIECHART_H -#include +#include class PieSlice; -class PieChart : public QDeclarativeItem +class PieChart : public QSGItem { Q_OBJECT Q_PROPERTY(QDeclarativeListProperty 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); diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp b/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp index 16f4bae..70338f0 100644 --- a/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp +++ b/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.cpp @@ -41,11 +41,9 @@ #include -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); } diff --git a/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h b/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h index 83b728a..3096ee6 100644 --- a/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h +++ b/examples/declarative/tutorials/extending/chapter6-plugins/pieslice.h @@ -40,10 +40,10 @@ #ifndef PIESLICE_H #define PIESLICE_H -#include +#include #include -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 index a83bf85..0000000 --- a/examples/declarative/tutorials/extending/chapter6-plugins/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin chapter6-plugins lib diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index a19700c..0875e1f 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -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 diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 072ab75..4a3a085 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -38,21 +38,15 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include #include #include #include #include -#include "qmlruntime.h" -#include #include #include -#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("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; -- 2.7.4