summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-04-27 05:11:09 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-04-27 05:11:09 (GMT)
commitdb51f7d5452f645db252341d8a633a299b2ef2e1 (patch)
tree1be01d82f6ac68e159d3a9da9d86eac96835f82d
parent09293f1d07b019dc7bfe95afb93364cc87774e82 (diff)
parentf0826662baaf7916f7b5f4fa9c8e9abab457731d (diff)
downloadQt-db51f7d5452f645db252341d8a633a299b2ef2e1.zip
Qt-db51f7d5452f645db252341d8a633a299b2ef2e1.tar.gz
Qt-db51f7d5452f645db252341d8a633a299b2ef2e1.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: (29 commits) 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 Add doc pages for qml examples. ...
-rwxr-xr-xdemos/declarative/samegame/SamegameCore/samegame.js9
-rw-r--r--demos/declarative/snake/content/snake.js8
-rw-r--r--doc/src/declarative/advtutorial.qdoc19
-rw-r--r--doc/src/declarative/anchor-layout.qdoc8
-rw-r--r--doc/src/declarative/animation.qdoc2
-rw-r--r--doc/src/declarative/declarativeui.qdoc11
-rw-r--r--doc/src/declarative/elements.qdoc1
-rw-r--r--doc/src/declarative/examples.qdoc40
-rw-r--r--doc/src/declarative/extending-tutorial.qdoc420
-rw-r--r--doc/src/declarative/extending.qdoc39
-rw-r--r--doc/src/declarative/globalobject.qdoc4
-rw-r--r--doc/src/declarative/integrating.qdoc4
-rw-r--r--doc/src/declarative/javascriptblocks.qdoc17
-rw-r--r--doc/src/declarative/measuring-performance.qdoc122
-rw-r--r--doc/src/declarative/network.qdoc11
-rw-r--r--doc/src/declarative/qdeclarativedocument.qdoc2
-rw-r--r--doc/src/declarative/qdeclarativei18n.qdoc2
-rw-r--r--doc/src/declarative/qdeclarativeintro.qdoc4
-rw-r--r--doc/src/declarative/qdeclarativestates.qdoc2
-rw-r--r--doc/src/declarative/qmlruntime.qdoc16
-rw-r--r--doc/src/declarative/qtprogrammers.qdoc4
-rw-r--r--doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp2
-rw-r--r--doc/src/declarative/snippets/qtbinding/custompalette/main.cpp2
-rw-r--r--doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp2
-rw-r--r--doc/src/examples/qml-examples.qdoc260
-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.cpp (renamed from doc/src/examples/qml-focus.qdoc)20
-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
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp8
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp8
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater.cpp13
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp12
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp30
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h3
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp81
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager.cpp6
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp196
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h3
-rw-r--r--src/declarative/qml/qdeclarativeextensionplugin.cpp15
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp2
-rw-r--r--src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp9
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp8
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp5
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp7
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp4
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp24
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h2
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp22
-rw-r--r--src/imports/gestures/plugin.cpp3
-rw-r--r--src/imports/gestures/qdeclarativegesturearea_p.h2
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h2
-rw-r--r--tests/auto/declarative/examples/tst_examples.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp23
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp32
-rw-r--r--tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp54
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/formatting.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp15
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp17
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp99
-rw-r--r--tools/qml/loggerwidget.cpp2
-rw-r--r--tools/qml/main.cpp6
-rw-r--r--tools/qml/qmlruntime.cpp32
-rw-r--r--tools/qml/qmlruntime.h1
106 files changed, 2938 insertions, 379 deletions
diff --git a/demos/declarative/samegame/SamegameCore/samegame.js b/demos/declarative/samegame/SamegameCore/samegame.js
index aafbfdf..bf99ca3 100755
--- a/demos/declarative/samegame/SamegameCore/samegame.js
+++ b/demos/declarative/samegame/SamegameCore/samegame.js
@@ -5,7 +5,6 @@ var maxRow = 15;
var maxIndex = maxColumn*maxRow;
var board = new Array(maxIndex);
var blockSrc = "SamegameCore/BoomBlock.qml";
-var scoresURL = "http://qtfx-nokia.trolltech.com.au/samegame/scores.php";
var scoresURL = "";
var gameDuration;
var component = Qt.createComponent(blockSrc);
@@ -179,8 +178,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);
@@ -193,8 +192,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/demos/declarative/snake/content/snake.js b/demos/declarative/snake/content/snake.js
index 2457fbd..02f9757 100644
--- a/demos/declarative/snake/content/snake.js
+++ b/demos/declarative/snake/content/snake.js
@@ -54,9 +54,9 @@ function startNewGame()
} else {
if(linkComponent.isReady == false){
if(linkComponent.isError == true)
- print(linkComponent.errorsString());
+ console.log(linkComponent.errorsString());
else
- print("Still loading linkComponent");
+ console.log("Still loading linkComponent");
continue;//TODO: Better error handling?
}
var link = linkComponent.createObject();
@@ -295,9 +295,9 @@ function createCookie(value) {
if(cookieComponent.isReady == false){
if(cookieComponent.isError == true)
- print(cookieComponent.errorsString());
+ console.log(cookieComponent.errorsString());
else
- print("Still loading cookieComponent");
+ console.log("Still loading cookieComponent");
return;//TODO: Better error handling?
}
cookie = cookieComponent.createObject();
diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc
index c465da4..2d05850 100644
--- a/doc/src/declarative/advtutorial.qdoc
+++ b/doc/src/declarative/advtutorial.qdoc
@@ -66,13 +66,13 @@ control QML elements.
Tutorial chapters:
\list 1
-\o \l {QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks}{Creating the Game Canvas and Blocks}
-\o \l {QML Advanced Tutorial 2 - Populating the Game Canvas}{Populating the Game Canvas}
-\o \l {QML Advanced Tutorial 3 - Implementing the Game Logic}{Implementing the Game Logic}
-\o \l {QML Advanced Tutorial 4 - Finishing Touches}{Finishing Touches}
+\o \l {declarative/tutorials/samegame/samegame1}{Creating the Game Canvas and Blocks}
+\o \l {declarative/tutorials/samegame/samegame2}{Populating the Game Canvas}
+\o \l {declarative/tutorials/samegame/samegame3}{Implementing the Game Logic}
+\o \l {declarative/tutorials/samegame/samegame4}{Finishing Touches}
\endlist
-All the code in this tutorial can be found in the $QTDIR/examples/declarative/tutorials/samegame
+All the code in this tutorial can be found in Qt's \c examples/declarative/tutorials/samegame
directory.
*/
@@ -83,7 +83,7 @@ directory.
\previouspage QML Advanced Tutorial
\nextpage QML Advanced Tutorial 2 - Populating the Game Canvas
-The files referenced on this page can be found in \c $QTDIR\examples\tutorials\samegame\samegame1.
+\example declarative/tutorials/samegame/samegame1
\section2 Creating the application screen
@@ -148,8 +148,7 @@ elements to get started. Next, we will populate the game canvas with some blocks
\previouspage QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks
\nextpage QML Advanced Tutorial 3 - Implementing the Game Logic
-The files referenced on this page can be found in \c $QTDIR\examples\tutorials\samegame\samegame2.
-
+\example declarative/tutorials/samegame/samegame2
\section2 Generating the blocks in JavaScript
@@ -216,7 +215,7 @@ Now, we have a screen of blocks, and we can begin to add the game mechanics.
\previouspage QML Advanced Tutorial 2 - Populating the Game Canvas
\nextpage QML Advanced Tutorial 4 - Finishing Touches
-The files referenced on this page can be found in \c $QTDIR\examples\tutorials\samegame\samegame3.
+\example declarative/tutorials/samegame/samegame3
\section2 Making a playable game
@@ -301,7 +300,7 @@ until the next chapter - where your application becomes alive!
\contentspage QML Advanced Tutorial
\previouspage QML Advanced Tutorial 3 - Implementing the Game Logic
-The files referenced on this page can be found in \c $QTDIR\examples\tutorials\samegame\samegame4.
+\example declarative/tutorials/samegame/samegame4
\section2 Adding some flair
diff --git a/doc/src/declarative/anchor-layout.qdoc b/doc/src/declarative/anchor-layout.qdoc
index ff47694..5340de6 100644
--- a/doc/src/declarative/anchor-layout.qdoc
+++ b/doc/src/declarative/anchor-layout.qdoc
@@ -44,10 +44,16 @@
\target anchor-layout
\title Anchor-based Layout in QML
-In addition to the more traditional \l Grid, \l Row, and \l Column, QML also provides a way to layout items using the concept of \e anchors. Each item can be thought of as having a set of 6 invisible "anchor lines": \e left, \e horizontalCenter, \e right, \e top, \e verticalCenter, and \e bottom.
+In addition to the more traditional \l Grid, \l Row, and \l Column,
+QML also provides a way to layout items using the concept of \e anchors.
+Each item can be thought of as having a set of 7 invisible "anchor lines":
+\e left, \e horizontalCenter, \e right, \e top, \e verticalCenter, \e baseline, and \e bottom.
\image edges_qml.png
+The baseline (not pictured above) corresponds to the imaginary line on which
+text would sit. For items with no text it is the same as \e top.
+
The QML anchoring system allows you to define relationships between the anchor lines of different items. For example, you can write:
\code
diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc
index 9969e8f..88aca1b 100644
--- a/doc/src/declarative/animation.qdoc
+++ b/doc/src/declarative/animation.qdoc
@@ -94,7 +94,7 @@ Rectangle {
Rectangle {
color: "red"
width: 50; height: 50
- NumberAnimation on x { to: 50; }
+ NumberAnimation on x { to: 50 }
}
}
\endqml
diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc
index 55945e6..8f36582 100644
--- a/doc/src/declarative/declarativeui.qdoc
+++ b/doc/src/declarative/declarativeui.qdoc
@@ -76,7 +76,6 @@ completely new applications. QML is fully \l {Extending QML in C++}{extensible
\o \l {QML Tutorial}{Tutorial: 'Hello World'}
\o \l {QML Advanced Tutorial}{Tutorial: 'Same Game'}
\o \l {QML Examples and Demos}
-\o \l {Using QML in C++ Applications}
\o \l {QML for Qt programmers}
\endlist
@@ -98,12 +97,18 @@ completely new applications. QML is fully \l {Extending QML in C++}{extensible
\o \l {qmlruntime.html}{The Qt Declarative Runtime}
\endlist
+\section1 Using QML with C++:
+\list
+\o \l {Tutorial: Writing QML extensions with C++}
+\o \l {Extending QML in C++}
+\o \l {Using QML in C++ Applications}
+\o \l {Integrating QML with existing Qt UI code}
+\endlist
+
\section1 Reference:
\list
\o \l {QML Elements}
\o \l {QML Global Object}
-\o \l {Extending QML in C++}
-\o \l {Integrating QML with existing Qt UI code}
\o \l {QML Internationalization}
\o \l {QML Security}
\o \l {QtDeclarative Module}
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index 355c0f4..bbe01e4 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -122,6 +122,7 @@ The following table lists the QML elements provided by the Qt Declarative module
\o \l Rectangle
\o \l Image
\o \l BorderImage
+\o \l AnimatedImage
\o \l Text
\o \l TextInput
\o \l TextEdit
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc
index dc6b76c..e01459f 100644
--- a/doc/src/declarative/examples.qdoc
+++ b/doc/src/declarative/examples.qdoc
@@ -71,7 +71,47 @@ For example, from your build directory, run:
\section1 Examples
\list
+\o \l{declarative/animations}{Animations}
+\o \l{declarative/aspectratio}{Aspect Ratio}
+\o \l{declarative/behaviors}{Behaviors}
+\o \l{declarative/border-image}{Border Image}
+\o \l{declarative/clocks}{Clocks}
+\o \l{declarative/connections}{Connections}
+\o \l{declarative/dial}{Dial}
+\o \l{declarative/dynamic}{Dynamic}
+\o \l{declarative/extending}{Extending}
+\o \l{declarative/fillmode}{Fillmode}
+\o \l{declarative/flipable}{Flipable}
\o \l{declarative/focus}{Focus}
+\o \l{declarative/fonts}{Fonts}
+\o \l{declarative/gridview}{GridView}
+\o \l{declarative/imageprovider}{Image Provider}
+\o \l{declarative/images}{Images}
+\o \l{declarative/layouts}{Layouts}
+\o \l{declarative/listmodel-threaded}{ListModel Threaded}
+\o \l{declarative/listview}{ListView}
+\o \l{declarative/mousearea}{Mouse Area}
+\o \l{declarative/objectlistmodel}{Object ListModel}
+\o \l{declarative/package}{Package}
+\o \l{declarative/parallax}{Parallax}
+\o \l{declarative/plugins}{Plugins}
+\o \l{declarative/progressbar}{Progress Bars}
+\o \l{declarative/proxywidgets}{Proxy Widgets}
+\o \l{declarative/scrollbar}{Scrollbar}
+\o \l{declarative/searchbox}{Search Box}
+\o \l{declarative/slideswitch}{Slide Switch}
+\o \l{declarative/sql}{SQL}
+\o \l{declarative/states}{States}
+\o \l{declarative/stringlistmodel}{String ListModel}
+\o \l{declarative/tabwidget}{Tab Widget}
+\o \l{declarative/tic-tac-toe}{Tic-Tac-Toe}
+\o \l{declarative/tvtennis}{TV Tennis}
+\o \l{declarative/velocity}{Velocity}
+\o \l{declarative/webview}{WebView}
+\o \l{declarative/workerscript}{WorkerScript}
+\o \l{declarative/xmldata}{XML Data}
+\o \l{declarative/xmlhttprequest}{XMLHttpRequest}
+
\endlist
\section1 Demos
diff --git a/doc/src/declarative/extending-tutorial.qdoc b/doc/src/declarative/extending-tutorial.qdoc
new file mode 100644
index 0000000..f00b858
--- /dev/null
+++ b/doc/src/declarative/extending-tutorial.qdoc
@@ -0,0 +1,420 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+
+\page qml-extending-tutorial-index.html
+\title Tutorial: Writing QML extensions with C++
+
+The QtDeclarative module provides a set of APIs for extending QML through
+C++ extensions. You can write extensions to add your own QML types, extend existing
+Qt types, or call C/C++ functions that are not accessible from ordinary QML code.
+
+This tutorial shows how to write a QML extension using C++ that includes
+core QML features, including properties, signals and bindings. It also shows how
+extensions can be deployed through plugins.
+
+You can find the source code for this tutorial in \c Qt's
+examples/declarative/tutorials/extending directory.
+
+Tutorial chapters:
+
+\list 1
+\o \l{declarative/tutorials/extending/chapter1-basics}{Creating a New Type}
+\o \l{declarative/tutorials/extending/chapter2-methods}{Connecting to C++ Methods and Signals}
+\o \l{declarative/tutorials/extending/chapter3-bindings}{Adding Property Bindings}
+\o \l{declarative/tutorials/extending/chapter4-customPropertyTypes}{Using Custom Property Types}
+\o \l{declarative/tutorials/extending/chapter5-plugins}{Writing an Extension Plugin}
+\o \l{qml-extending-tutorial6.html}{In Summary}
+\endlist
+
+*/
+
+/*!
+\title Chapter 1: Creating a New Type
+
+\example declarative/tutorials/extending/chapter1-basics
+
+Let's create a new QML type called "Musician" that has two properties: a name
+and an instrument. We will make it available in a \l {Modules}{module} called "Music", with
+a module version of 1.0.
+We want this \c Musician type to be usable from QML like this:
+
+\code
+ import Music 1.0
+
+ Musician {
+ name: "Reddy the Rocker"
+ instrument: "Guitar"
+ }
+\endcode
+
+To do this, we need a C++ class that encapsulates this \c Musician type and its two
+properties. Since QML relies heavily on Qt's \l{Meta-Object System}{meta object system},
+this new class must:
+
+\list
+\o inherit from QObject
+\o declare its properties using the Q_PROPERTY() macro
+\endlist
+
+Here is our \c Musician class, defined in \c musician.h:
+
+\snippet declarative/tutorials/extending/chapter1-basics/musician.h 0
+
+It defines the two properties, \c name and \c instrument, with the Q_PROPERTY() macro.
+The class implementation in \c musician.cpp simply sets and returns the \c m_name and
+\c m_instrument values as appropriate.
+
+Our QML file, \c app.qml, creates a \c Musician item and display the musician's details
+using a standard QML \l Text item:
+
+\quotefile declarative/tutorials/extending/chapter1-basics/app.qml
+
+We'll also create a C++ application that uses a QDeclarativeView to run and
+display \c app.qml. The application must register the \c Musician type
+using the qmlRegisterType() function, to allow it to be used from QML. If
+you don't register the type, \c app.qml won't be able to create a \c Musician.
+
+Here is the application \c main.cpp:
+
+\snippet declarative/tutorials/extending/chapter1-basics/main.cpp 0
+
+This call to qmlRegisterType() registers the \c Musician type as a type called "Musician", in a module named "Music",
+with a module version of 1.0.
+
+Lastly, we write a \c .pro project file that includes the files and the \c declarative library:
+
+\quotefile declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro
+
+Now we can build and run the application. Try it yourself with the code in Qt's \c examples/tutorials/extending/chapter1-basics directory.
+
+\example declarative/tutorials/extending/chapter1-basics
+
+At the moment, the \c app.qml is run from within a C++ application.
+This may seem odd if you're used to running QML files with the standard \c qml tool.
+Later on, we'll show how to create a plugin so that you can run \c app.qml using the
+\c qml tool instead.
+
+*/
+
+
+/*!
+\title Chapter 2: Connecting to C++ Methods and Signals
+
+\example declarative/tutorials/extending/chapter2-methods
+
+Suppose we want \c Musician to have a "perform" method that prints a message
+to the console and then emits a "performanceEnded" signal.
+Other elements would be able to call \c perform() and receive
+\c performanceEnded() signals like this:
+
+\quotefile declarative/tutorials/extending/chapter2-methods/app.qml
+
+To do this, we add a \c perform() method and a \c performanceEnded() signal
+to our C++ class:
+
+\snippet declarative/tutorials/extending/chapter2-methods/musician.h 0
+\dots
+\snippet declarative/tutorials/extending/chapter2-methods/musician.h 1
+\dots
+\snippet declarative/tutorials/extending/chapter2-methods/musician.h 2
+\dots
+\snippet declarative/tutorials/extending/chapter2-methods/musician.h 3
+
+The use of Q_INVOKABLE makes the \c perform() method available to the
+Qt Meta-Object system, and in turn, to QML. Note that it could have
+been declared as as a Qt slot instead of using Q_INVOKABLE, as
+slots are also callable from QML. Both of these approaches are valid.
+
+The \c perform() method simply prints a message to the console and
+then emits \c performanceEnded():
+
+\snippet declarative/tutorials/extending/chapter2-methods/musician.cpp 0
+
+Now when we run the application and click the window, the application outputs:
+
+\code
+ "Reddy the Rocker" is playing the "Guitar"
+ The performance has now ended
+\endcode
+
+Try out the example yourself with the updated code in Qt's \c examples/tutorials/extending/chapter2-methods directory.
+
+*/
+
+/*!
+\title Chapter 3: Adding Property Bindings
+
+\example declarative/tutorials/extending/chapter3-bindings
+
+Property bindings is a powerful feature of QML that allows values of different
+elements to be synchronized automatically. It uses signals to notify and update
+other elements' values when property values change.
+
+Let's enable property bindings for the \c instrument property. That means
+if we have code like this:
+
+\quotefile declarative/tutorials/extending/chapter3-bindings/app.qml
+
+The "instrument: reddy.instrument" statement binds the \c instrument value of
+\c craig to the \c instrument of \c reddy.
+Whenever \c reddy's \c instrument value changes, \c craig's \c instrument value
+updates to the same value. When the window is clicked, the application outputs:
+
+\code
+ "Reddy the Rocker" is playing the "Guitar"
+ "Craig the Copycat" is playing the "Guitar"
+ "Reddy the Rocker" is playing the "Drums"
+ "Craig the Copycat" is playing the "Drums"
+\endcode
+
+It's easy to enable property binding for the \c instrument property.
+We add a \l{Qt's Property System}{NOTIFY} feature to its Q_PROPERTY() declaration to indicate that a "instrumentChanged" signal
+is emitted whenever the value changes.
+
+\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 0
+\dots
+\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 1
+\dots
+\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 2
+\dots
+\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 3
+
+Then, we emit this signal in \c setInstrument():
+
+\snippet declarative/tutorials/extending/chapter3-bindings/musician.cpp 0
+
+It's important for \c setInstrument() to check that the instrument value has actually changed
+before emitting \c instrumentChanged(). This ensures the signal is not emitted unnecessarily and
+also prevents loops when other elements respond to the value change.
+
+*/
+
+/*!
+\title Chapter 4: Using Custom Property Types
+
+\example declarative/tutorials/extending/chapter4-customPropertyTypes
+
+The \c Musician type currently has two properties that are both strings.
+It could have all sorts of other properties. For example, we could add an
+integer-type property to store the age of each musician:
+
+\code
+ class Musician : public QObject
+ {
+ ...
+ Q_PROPERTY(int age READ age WRITE setAge)
+ public:
+ ...
+ int age() const;
+ void setAge(int age);
+ ...
+ };
+\endcode
+
+We can also use various other property types. QML has built-in support for the following
+types:
+
+\list
+\o bool
+\o unsigned int, int
+\o float, double, qreal
+\o QString
+\o QUrl
+\o QColor
+\o QDate, QTime, QDateTime
+\o QPoint, QPointF
+\o QSize, QSizeF
+\o QRect, QRectF
+\o QVariant
+\endlist
+
+If we want to create a property whose type is not supported by QML by default,
+we need to register the type with QML.
+
+For example, let's change the type of the \c instrument property from a string to a
+new type called "Instrument". Instead of assigning a string value to \c instrument,
+we assign an \c Instrument value:
+
+\quotefile declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
+
+Like \c Musician, this new \c Instrument type has to inherit from QObject and declare
+its properties with Q_PROPERTY():
+
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h 0
+
+To use it from \c Musician, we modify the \c instrument property declaration
+and associated method signatures:
+
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 0
+\dots
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 1
+\dots
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 2
+\dots
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 3
+
+Like the \c Musician type, the \c Instrument type has to be registered
+using qmlRegisterType() to be used from QML. As with \c Musician, we'll add the
+type to the "Music" module, version 1.0:
+
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp 0
+\dots
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp 1
+\dots
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp 2
+
+Try it out with the code in Qt's \c examples/tutorials/extending/chapter4-customPropertyTypes directory.
+
+*/
+
+/*!
+\title Chapter 5: Writing an Extension Plugin
+
+\example declarative/tutorials/extending/chapter5-plugins
+
+Currently the \c Musician and \c Instrument types are used by \c app.qml,
+which is displayed using a QDeclarativeView in a C++ application. An alternative
+way to use our QML extension is to create a plugin library to make it available
+to the QML engine. This means we could load \c app.qml using the standard \c qml tool
+(or some other QML runtime application) instead of writing a \c main.cpp file and
+loading our own C++ application.
+
+To create a plugin library, we need:
+
+\list
+\o A plugin class that registers our QML types
+\o A project file that describes the plugin
+\o A "qmldir" file that tells the QML engine to load the plugin
+\endlist
+
+First, we create a plugin class named \c MusicPlugin. It subclasses QDeclarativeExtensionPlugin
+and registers our QML types in the inherited \l{QDeclarativeExtensionPlugin::}{registerTypes()} method. It also calls
+Q_EXPORT_PLUGIN2 for Qt's \l{How to Create Qt Plugins}{plugin system}.
+
+Here is the \c MusicPlugin definition in \c musicplugin.h:
+
+\snippet declarative/tutorials/extending/chapter5-plugins/musicplugin.h 0
+
+And its implementation in \c musicplugin.cpp:
+
+\snippet declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp 0
+
+Then, we write a \c .pro project file that defines the project as a plugin library
+and specifies with DESTDIR that library files should be built into a "lib" subdirectory:
+
+\quotefile declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro
+
+Finally, we add a \c qmldir file that is automatically parsed by the QML engine.
+Here, we specify that a plugin named "chapter5-plugin" (the name
+of the example project) can be found in the "lib" subdirectory:
+
+\quotefile declarative/tutorials/extending/chapter5-plugins/qmldir
+
+Now we have a plugin, and instead of having a main.cpp and an executable, we can build
+the project and then run the QML file directly using the \c qml tool:
+
+\code
+ qml app.qml
+\endcode
+
+Notice the "import Music 1.0" statement has disappeared from \c app.qml. This is
+because the \c qmldir file is in the same directory as \c app.qml: this is equivalent to
+having Musician.qml and Instrument.qml files inside the project directory, which could both
+be used by \c app.qml without import statements.
+*/
+
+/*!
+\page qml-extending-tutorial6.html
+\title Chapter 6: In Summary
+
+In this tutorial, we've shown the basic steps for creating a QML extension:
+
+\list
+\o Define new QML types by subclassing QObject and registering them with qmlRegisterType()
+\o Add callable methods using Q_INVOKABLE or Qt slots, and connect to Qt signals with an \c onSignal syntax
+\o Add property bindings by defining \l{Qt's Property System}{NOTIFY} signals
+\o Define custom property types if the built-in types are not sufficient
+\o Create a plugin library by defining a Qt plugin and writing a \c qmldir file
+\endlist
+
+
+The \l {Extending QML in C++} reference documentation shows other useful features that can be added to
+QML extensions. For example, we could use \l{Object and List Property Types}{list properties} to allow multiple instruments for a \c Musician:
+
+\code
+ Musician {
+ instruments: [
+ Instrument { type: "Guitar" }
+ Instrument { type: "Drums" }
+ Instrument { type: "Keyboard" }
+ ]
+ }
+\endcode
+
+Or use \l{Default Property}{default properties} and avoid an
+\c instruments property altogether:
+
+\code
+ Musician {
+ Instrument { type: "Guitar" }
+ Instrument { type: "Drums" }
+ Instrument { type: "Keyboard" }
+ }
+\endcode
+
+Or even change the \c instrument of a \c Musician from time to time using \l{Property Value Sources}{property value sources}:
+
+\code
+ Musician {
+ InstrumentRandomizer on instrument {}
+ }
+\endcode
+
+
+See the \l{Extending QML in C++}{reference documentation} for more information.
+
+Additionally, \l {Integrating QML with existing Qt UI code} shows how to create
+and integrate with QML extensions that have drawing and graphical capabilities (through QGraphicsWidget).
+
+*/
+
diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc
index c27d091..1c159e4 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -43,7 +43,7 @@
\page qml-extending.html
\title Extending QML in C++
-The QML syntax declaratively describes how to construct an in memory object
+The QML syntax declaratively describes how to construct an in-memory object
tree. In Qt, QML is mainly used to describe a visual scene graph, but it is
not conceptually limited to this: the QML format is an abstract description of
any object tree. All the QML element types included in Qt are implemented using
@@ -65,7 +65,7 @@ QML relies heavily on Qt's meta object system and can only instantiate classes
that derive from QObject.
The QML engine has no intrinsic knowledge of any class types. Instead the
-programmer must define the C++ types, and their corresponding QML name.
+programmer must register the C++ types with their corresponding QML names.
Custom C++ types are registered using a template function:
@@ -152,7 +152,7 @@ template<typename T>
int qmlRegisterInterface(const char *typeName)
\endcode
-Registers the C++ interface \a T with the QML system as \a typeName.
+This registers the C++ interface \a T with the QML system as \a typeName.
Following registration, QML can coerce objects that implement this interface
for assignment to appropriately typed properties.
@@ -196,7 +196,7 @@ registered, the following function can be used:
int qmlRegisterType()
\endcode
-Registers the C++ type \a T with the QML system. The parameterless call to the template
+This registers the C++ type \a T with the QML system. The parameterless call to the template
function qmlRegisterType() does not define a mapping between the
C++ class and a QML element name, so the type is not instantiable from QML, but
it is available for type coercion.
@@ -222,7 +222,7 @@ The QML snippet shown above assigns a collection of objects to the
The \e {default property} is a syntactic convenience that allows a type designer to
specify a single property as the type's default. The default property is
assigned to whenever no explicit property is specified. As a convenience, it is
-behaviorally identical to assigning the default property explicitly by name.
+behaviorally identical to assigning to the default property explicitly by name.
From C++, type designers mark the default property using a Q_CLASSINFO()
annotation:
@@ -232,7 +232,7 @@ annotation:
Q_CLASSINFO("DefaultProperty", "property")
\endcode
-Mark \a property as the class's default property. \a property must be either
+This marks \a property as the class's default property. \a property must be either
an object property, or a list property.
A default property is optional. A derived class inherits its base class's
@@ -248,7 +248,7 @@ specify a default property.
\snippet examples/declarative/extending/grouped/example.qml 1
-The QML snippet shown above assigns a number properties to the \c Boy object,
+The QML snippet shown above assigns a number of properties to the \c Boy object,
including four properties using the grouped property syntax.
Grouped properties collect similar properties together into a single named
@@ -273,13 +273,13 @@ implement the \c shoe property grouping.
\snippet examples/declarative/extending/attached/example.qml 1
-The QML snippet shown above assigns the \c rsvp property using the attached
+The QML snippet shown above assigns a date to the \c rsvp property using the attached
property syntax.
Attached properties allow unrelated types to annotate other types with some
additional properties, generally for their own use. Attached properties are
identified through the use of the attacher type name, in the case shown
-\c BirthdayParty, as a suffix to the property name.
+\c BirthdayParty, as a prefix to the property name.
In the example shown, \c BirthdayParty is called the attaching type, and the
\c Boy instance the attachee object instance.
@@ -306,7 +306,7 @@ public:
QML_DECLARE_TYPEINFO(MyType, QML_HAS_ATTACHED_PROPERTIES)
\endcode
-Return an attachment object, of type \a AttachedPropertiesType, for the
+This returns an attachment object, of type \a AttachedPropertiesType, for the
attachee \a object instance. It is customary, though not strictly required, for
the attachment object to be parented to \a object to prevent memory leaks.
@@ -349,7 +349,7 @@ an instance can be accessed using the following method:
template<typename T>
QObject *qmlAttachedPropertiesObject<T>(QObject *attachee, bool create = true);
\endcode
-Returns the attachment object attached to \a attachee by the attaching type
+This returns the attachment object attached to \a attachee by the attaching type
\a T. If type \a T is not a valid attaching type, this method always returns 0.
If \a create is true, a valid attachment object will always be returned,
@@ -366,7 +366,7 @@ It is an element's responsibility to ensure that it does not access or return
pointers to invalid objects. QML makes the following guarentees:
\list
-\o An object assigned to an QObject (or QObject-derived) pointer property will be
+\o An object assigned to a QObject (or QObject-derived) pointer property will be
valid at the time of assignment.
Following assignment, it is the responsibility of the class to subsequently guard
@@ -562,19 +562,22 @@ extension type - when registering the target class whose properties are
transparently merged with the original target class when used from within QML.
An extension class is a regular QObject, with a constructor that takes a QObject
-pointer. When needed (extension classes are delay created until the first extended
+pointer. When needed (extension class creation is delayed until the first extended
property is accessed) the extension class is created and the target object is
passed in as the parent. When an extended property on the original is accessed,
the appropriate property on the extension object is used instead.
When an extended type is installed, one of the
\code
- #define QML_REGISTER_EXTENDED_TYPE(URI, VMAJ, VFROM, VTO, QDeclarativeName,T, ExtendedT)
- #define QML_REGISTER_EXTENDED_NOCREATE_TYPE(T, ExtendedT)
+template<typename T, typename ExtendedT>
+int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+
+template<typename T, typename ExtendedT>
+int qmlRegisterType()
\endcode
-macros should be used instead of the regular \c QML_REGISTER_TYPE or
-\c QML_REGISTER_NOCREATE_TYPE. The arguments are identical to the corresponding
-non-extension object macro, except for the ExtendedT parameter which is the type
+functions should be used instead of the regular \c qmlRegisterType() variations.
+The arguments are identical to the corresponding non-extension registration functions,
+except for the ExtendedT parameter which is the type
of the extension object.
\section1 Optimization
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index 6709ab4..57eaae7 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -223,7 +223,7 @@ of their use.
function finishCreation(){
if(component.isReady()){
sprite = component.createObject();
- if(sprite == 0){
+ if(sprite == null){
// Error Handling
}else{
sprite.parent = page;
@@ -248,7 +248,7 @@ of their use.
\code
component = createComponent("Sprite.qml");
sprite = component.createObject();
- if(sprite == 0){
+ if(sprite == null){
// Error Handling
console.log(component.errorsString());
}else{
diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc
index 65413ec..0051f09 100644
--- a/doc/src/declarative/integrating.qdoc
+++ b/doc/src/declarative/integrating.qdoc
@@ -152,8 +152,8 @@ Here is a screenshot of the result:
\image declarative-integrating-graphicswidgets.png
-Note this approach of creating your graphics widgets from QML does not work
-with QGraphicsItem objects that are not QGraphicsWidget-based, since they are not QObjects.
+Note this approach of creating your graphics objects from QML does not work
+with QGraphicsItems that are not QGraphicsObject-based, since they are not QObjects.
See \l{Extending QML in C++} for further information on using C++ types.
diff --git a/doc/src/declarative/javascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc
index 7c0570e..2db7e8e 100644
--- a/doc/src/declarative/javascriptblocks.qdoc
+++ b/doc/src/declarative/javascriptblocks.qdoc
@@ -75,7 +75,7 @@ Item {
MouseArea {
anchors.fill: parent
- onClicked: print(factorial(10))
+ onClicked: console.log(factorial(10))
}
}
\endcode
@@ -99,7 +99,7 @@ import "factorial.js" as MathFunctions
Item {
MouseArea {
anchors.fill: parent
- onClicked: print(MathFunctions.factorial(10))
+ onClicked: console.log(MathFunctions.factorial(10))
}
}
\endcode
@@ -184,6 +184,9 @@ Any element in a QML file - including nested elements and nested QML component
instances - can use this attached property. If there is more than one \c onCompleted()
handler to execute at startup, they are run sequentially in an undefined order.
+Likewise, the \l {Component::onDestruction} attached property is triggered on
+component destruction.
+
\section1 QML JavaScript Restrictions
QML executes standard JavaScript code, with the following restrictions:
@@ -204,16 +207,18 @@ is illegal in QML.
\code
// Illegal modification of undeclared variable
a = 1;
-for (var ii = 1; ii < 10; ++ii) a = a * ii;
- console.log("Result: " + a);
+for (var ii = 1; ii < 10; ++ii)
+ a = a * ii;
+console.log("Result: " + a);
\endcode
It can be trivially modified to this legal code.
\code
var a = 1;
-for (var ii = 1; ii < 10; ++ii) a = a * ii;
- console.log("Result: " + a);
+for (var ii = 1; ii < 10; ++ii)
+ a = a * ii;
+console.log("Result: " + a);
\endcode
Any attempt to modify the global object - either implicitly or explicitly - will
diff --git a/doc/src/declarative/measuring-performance.qdoc b/doc/src/declarative/measuring-performance.qdoc
deleted file mode 100644
index cb608bf..0000000
--- a/doc/src/declarative/measuring-performance.qdoc
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
-
-/*!
-\page optimizing-performance.html
-\target optimizing-performance
-\title Optimizing Performance in QML
-
-The Qt Declarative module includes several tools to help measure performance.
-
-\section1 Performance Logging
-
-The declarative module uses the functionality provided by QPerformanceLog to log performance information. To see this information you can add the following to src.pro:
-
-\code
-DEFINES += Q_ENABLE_PERFORMANCE_LOG
-\endcode
-
-The performance information will be printed to screen on a QML application startup, or when running the viewer can be forced at anytime by pressing 'F3' on the keyboard.
-
-Additional logging can be enabled by adding the relevant categories to qfxperf.h and qfxperf.cpp.
-
-For example, to measure the cost of calculating the size of a text item, you would first define a TextSize category by adding the following:
-
-\code
-//in qfxperf.h
-Q_DECLARE_PERFORMANCE_METRIC(TextSize);
-
-//in qfxperf.cpp
-Q_DEFINE_PERFORMANCE_METRIC(TextSize, "Text Size Calculation");
-\endcode
-
-You could then use this category in the code:
-
-\code
-void QDeclarativeText::updateSize()
-{
- QDeclarativePerfTimer<QDeclarativePerf::TextSize> perf;
- ...
-}
-\endcode
-
-Because there is no cost for a QDeclarativePerfTimer when Q_ENABLE_PERFORMANCE_LOG is not defined, this line can persist in the code and be used to help detect performance bottlenecks and regressions. See the QPerformanceLog documentation for more information on this performance framework.
-
-\section1 FPS Measurements
-
-When running the viewer, pressing 'F2' on the keyboard while a QML program is running will cause information on cost-per-frame and frames-per-second (FPS) to be printed to the console.
-
-The information printed includes:
-\list
-\o \e repaint(): the total time spent painting.
-\o \e paint(): the time spent by Qt painting.
-\o \e timeBetweenFrames: the total time spent per frame. This number minus repaint() gives a good idea of how much time is spent on things besides painting. A high number here with a low number for repaint() indicates expensive calculations happening each frame.
-\endlist
-
-\section1 Improving Performance
-
-The following tips can help decrease startup time for QML-based appications.
-
-\section2 Images
-
-\list
-\o Use jpg instead of png for photo-like images. On the N810, this can save 150ms for a large (320x480) image.
-
-\o If you are configuring Qt, configure out any image plugins you don't plan to support (mng and svg are the most expensive). On the N810, this can save 75-100ms startup time. For example:
-
-\code
-configure -no-libmng -no-svg -no-libtiff
-\endcode
-
-\o In some cases running pngcrush, optipng, gifsicle or other similar tools can give some improvement.
-
-We are also investigating support for the loading of uncompressed images. This will provide opportunites to decrease startup time at the cost of increased storage space.
-\endlist
-
-\section2 Fonts
-
-\list
-\o Use qpf instead of ttf. When using multiple font sizes and weights on the N810, this can save 125ms startup time compared to a ttf 'clean' run, and 40-50ms on subsequent runs (ttfs are shared by open applications).
-\endlist
-
-*/
-
-*/
diff --git a/doc/src/declarative/network.qdoc b/doc/src/declarative/network.qdoc
index d268a13..68768c6 100644
--- a/doc/src/declarative/network.qdoc
+++ b/doc/src/declarative/network.qdoc
@@ -130,11 +130,12 @@ See the \tt demos/declarative/flickr for a real demonstration of this.
\section1 Configuring the Network Access Manager
All network access from QML is managed by a QNetworkAccessManager set on the QDeclarativeEngine which executes the QML.
-By default, this is an unmodified Qt QNetworkAccessManager. You may set a different manager using
-QDeclarativeEngine::setNetworkAccessManager() as appropriate for the policies of your application.
-For example, the \l {Qt Declarative UI Runtime}{qml} tool sets a new QNetworkAccessManager which
-trusts HTTP Expiry headers to avoid network cache checks, allows HTTP Pipelining, adds a persistent HTTP CookieJar,
-a simple disk cache, and supports proxy settings.
+By default, this is an unmodified Qt QNetworkAccessManager. You may set a different manager by
+providing a QDeclarativeNetworkAccessManagerFactory and setting it via
+QDeclarativeEngine::setNetworkAccessManagerFactory().
+For example, the \l {Qt Declarative UI Runtime}{qml} tool sets a QDeclarativeNetworkAccessManagerFactory which
+creates QNetworkAccessManager that trusts HTTP Expiry headers to avoid network cache checks,
+allows HTTP Pipelining, adds a persistent HTTP CookieJar, a simple disk cache, and supports proxy settings.
\section1 QRC Resources
diff --git a/doc/src/declarative/qdeclarativedocument.qdoc b/doc/src/declarative/qdeclarativedocument.qdoc
index cf3aae2..bc099ce 100644
--- a/doc/src/declarative/qdeclarativedocument.qdoc
+++ b/doc/src/declarative/qdeclarativedocument.qdoc
@@ -93,7 +93,7 @@ behaviour. As it is a template, a single QML component can be "run" multiple ti
produce several objects, each of which are said to be \e instances of the component.
Once created, instances are not dependent on the component that created them, so they can
-operate on independent data. Here is an example of a simple "button" component that is
+operate on independent data. Here is an example of a simple "Button" component that is
instantiated four times, each with a different value for its \c text property.
\table
diff --git a/doc/src/declarative/qdeclarativei18n.qdoc b/doc/src/declarative/qdeclarativei18n.qdoc
index 0a48dd9..c7dbd4d 100644
--- a/doc/src/declarative/qdeclarativei18n.qdoc
+++ b/doc/src/declarative/qdeclarativei18n.qdoc
@@ -86,7 +86,7 @@ lupdate hello.qml -ts hello.ts
\endcode
Then we open \c hello.ts in \l{Qt Linguist Manual} {Linguist}, provide
-a translation and create the release file \c hello.qml.
+a translation and create the release file \c hello.qm.
Finally, we can test the translation:
\code
diff --git a/doc/src/declarative/qdeclarativeintro.qdoc b/doc/src/declarative/qdeclarativeintro.qdoc
index 4d05a8c..a98c9e1 100644
--- a/doc/src/declarative/qdeclarativeintro.qdoc
+++ b/doc/src/declarative/qdeclarativeintro.qdoc
@@ -142,8 +142,8 @@ Commenting in QML is similar to JavaScript.
\quotefile doc/src/snippets/declarative/comments.qml
-Comments are ignored by the engine. The are useful for explaining what you
-are doing: for referring back to at a later date, or for others reading
+Comments are ignored by the engine. They are useful for explaining what you
+are doing; for referring back to at a later date, or for others reading
your QML files.
Comments can also be used to prevent the execution of code, which is
diff --git a/doc/src/declarative/qdeclarativestates.qdoc b/doc/src/declarative/qdeclarativestates.qdoc
index 0fea6f8..fd0c677 100644
--- a/doc/src/declarative/qdeclarativestates.qdoc
+++ b/doc/src/declarative/qdeclarativestates.qdoc
@@ -70,7 +70,7 @@ In QML:
\o A state can affect the properties of other objects, not just the object owning the state (and not just that object's children).
\endlist
-Here is an example of using states. In the default state \c myRect is positioned at 0,0. In the 'moved' state it is positioned at 50,50. Clicking within the mouse region changes the state from the default state to the 'moved' state, thus moving the rectangle.
+Here is an example of using states. In the default state \c myRect is positioned at 0,0. In the 'moved' state it is positioned at 50,50. Clicking within the mouse area changes the state from the default state to the 'moved' state, thus moving the rectangle.
\qml
Item {
diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc
index 9f7183a..a724c7d 100644
--- a/doc/src/declarative/qmlruntime.qdoc
+++ b/doc/src/declarative/qmlruntime.qdoc
@@ -52,7 +52,7 @@
QML is a runtime, as you can run plain qml files which pull in their required modules.
To run apps with the QML runtime, you can either start the runtime
- from your on application (using a QDeclarativeView) or with the simple \c qml application.
+ from your own application (using a QDeclarativeView) or with the simple \c qml application.
The \c qml application can be
installed in a production environment, assuming that it is not already
present in the system. It is generally packaged alongside Qt.
@@ -137,8 +137,8 @@
\section2 Runtime Object
All applications using the qmlruntime will have access to the 'runtime'
- property on the root context. This property contains several information
- about the runtime environment of the application.
+ property on the root context. This property contains several pieces of
+ information about the runtime environment of the application.
\section3 Screen Orientation
@@ -150,11 +150,11 @@
which can be either Orientation.Landscape or Orientation.Portrait and which can be bound to in your
application. An example is below:
-\code
+ \code
Item {
state: (runtime.orientation == Orientation.Landscape) ? 'landscape' : ''
}
-\endcode
+ \endcode
This allows your application to respond to the orientation of the screen changing. The runtime
will automatically update this on some platforms (currently the N900 only) to match the physical
@@ -163,12 +163,12 @@
\section3 Window Active
The runtime.isActiveWindow property tells whether the main window of the qml runtime is currently active
- or not. This is specially useful for embedded devices when you want to pause parts of your application,
+ or not. This is especially useful for embedded devices when you want to pause parts of your application,
including animations, when your application loses focus or goes to the background.
The example below, stops the animation when the application's window is deactivated and resumes on activation:
-\code
+ \code
Item {
width: 300; height: 200
Rectangle {
@@ -182,6 +182,6 @@
}
}
}
-\endcode
+ \endcode
*/
diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc
index 05ffeb0..0b40840 100644
--- a/doc/src/declarative/qtprogrammers.qdoc
+++ b/doc/src/declarative/qtprogrammers.qdoc
@@ -62,7 +62,7 @@ QML provides direct access to the following concepts from Qt:
\o QObject signals and slots - available as functions to call in JavaScript
\o QObject properties - available as variables in JavaScript
\o QWidget - QDeclarativeView is a QML-displaying widget
- \o Qt models - used directly in data binding (QAbstractItemModel and next generation QListModelInterface)
+ \o Qt models - used directly in data binding (QAbstractItemModel)
\endlist
Qt knowledge is \e required for \l {Extending QML in C++}, and also for \l{Integrating QML with existing Qt UI code}.
@@ -104,7 +104,7 @@ and exactly how it respond to mouse, key, or touch input, should all be left for
in QML.
It is illustrative to note that QDeclarativeTextEdit is built upon QTextControl,
-QDeclarativeWebView is built upon QWebPage, and ListView uses QListModelInterface,
+QDeclarativeWebView is built upon QWebPage, and ListView uses QAbstractItemModel,
just as QTextEdit, QWebView, and QListView are built upon
those same UI-agnostic components.
diff --git a/doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp b/doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp
index 15e3d4c..4073a6c 100644
--- a/doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp
+++ b/doc/src/declarative/snippets/qtbinding/contextproperties/main.cpp
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])
context->setContextProperty("backgroundColor",
QColor(Qt::yellow));
- view.setSource(QUrl("main.qml"));
+ view.setSource(QUrl::fromLocalFile("main.qml"));
view.show();
return app.exec();
diff --git a/doc/src/declarative/snippets/qtbinding/custompalette/main.cpp b/doc/src/declarative/snippets/qtbinding/custompalette/main.cpp
index c723688..dc651f6 100644
--- a/doc/src/declarative/snippets/qtbinding/custompalette/main.cpp
+++ b/doc/src/declarative/snippets/qtbinding/custompalette/main.cpp
@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
QDeclarativeView view;
view.rootContext()->setContextProperty("palette", new CustomPalette);
- view.setSource(QUrl("main.qml"));
+ view.setSource(QUrl::fromLocalFile("main.qml"));
view.show();
return app.exec();
diff --git a/doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp b/doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp
index 13e3b9f..537a288 100644
--- a/doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp
+++ b/doc/src/declarative/snippets/qtbinding/stopwatch/main.cpp
@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
view.rootContext()->setContextProperty("stopwatch",
new Stopwatch);
- view.setSource(QUrl("main.qml"));
+ view.setSource(QUrl::fromLocalFile("main.qml"));
view.show();
return app.exec();
diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc
new file mode 100644
index 0000000..93e4a46
--- /dev/null
+++ b/doc/src/examples/qml-examples.qdoc
@@ -0,0 +1,260 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+/*!
+ \title Animations
+ \example declarative/animations
+
+ This example shows how to use animations in QML.
+*/
+
+/*!
+ \title AspectRatio
+ \example declarative/aspectratio
+
+ This example shows how to implement different aspect ratios in QML.
+*/
+
+/*!
+ \example declarative/behaviors
+ \title Behaviors
+*/
+
+/*!
+ \title Border Image
+ \example declarative/border-image
+
+ This example shows how to use a BorderImage in QML.
+*/
+
+/*!
+ \title Clocks
+ \example declarative/clocks
+
+ This example shows how to create a Clock component and reuse it in a grid.
+*/
+
+/*!
+ \title Connections
+ \example declarative/connections
+
+ This example shows how to use a Connection element in QML.
+*/
+
+/*!
+ \title Dial
+ \example declarative/dial
+
+ This example shows how to implement a dial in QML.
+*/
+
+/*!
+ \title Dynamic
+ \example declarative/dynamic
+
+ This example shows how to create dynamic objects QML.
+*/
+
+/*!
+ \example declarative/extending
+ \title Extending
+*/
+
+/*!
+ \example declarative/fillmode
+ \title Fillmode
+*/
+
+/*!
+ \title Flipable
+ \example declarative/flipable
+
+ This example shows how to use a Flipable element in QML.
+*/
+
+/*!
+ \title Focus
+ \example declarative/focus
+
+ This example shows how to handle keys and focus in QML.
+
+ \image qml-focus-example.png
+*/
+
+/*!
+ \example declarative/fonts
+ \title Fonts
+*/
+
+/*!
+ \example declarative/gridview
+ \title GridView
+*/
+
+/*!
+ \example declarative/imageprovider
+ \title Image Provider
+*/
+
+/*!
+ \example declarative/images
+ \title Images
+*/
+
+/*!
+ \example declarative/layouts
+ \title Layouts
+*/
+
+/*!
+ \example declarative/listmodel-threaded
+ \title ListModel Threaded
+*/
+
+/*!
+ \example declarative/listview
+ \title ListView
+*/
+
+/*!
+ \example declarative/mousearea
+ \title Mouse Area
+*/
+
+/*!
+ \example declarative/objectlistmodel
+ \title Object ListModel
+*/
+
+/*!
+ \example declarative/package
+ \title Package
+*/
+
+/*!
+ \example declarative/parallax
+ \title Parallax
+*/
+
+/*!
+ \example declarative/plugins
+ \title Plugins
+*/
+
+/*!
+ \example declarative/progressbar
+ \title Progress Bars
+*/
+
+/*!
+ \example declarative/proxywidgets
+ \title Proxy Widgets
+*/
+
+/*!
+ \example declarative/scrollbar
+ \title Scrollbar
+*/
+
+/*!
+ \example declarative/searchbox
+ \title Search Box
+*/
+
+/*!
+ \example declarative/slideswitch
+ \title Slide Switch
+*/
+
+/*!
+ \example declarative/sql
+ \title SQL
+*/
+
+/*!
+ \example declarative/states
+ \title States
+*/
+
+/*!
+ \example declarative/stringlistmodel
+ \title String ListModel
+*/
+
+/*!
+ \example declarative/tabwidget
+ \title Tab Widget
+*/
+
+/*!
+ \example declarative/tic-tac-toe
+ \title Tic-Tac-Toe
+*/
+
+/*!
+ \example declarative/tvtennis
+ \title TV Tennis
+*/
+
+/*!
+ \example declarative/velocity
+ \title Velocity
+*/
+
+/*!
+ \example declarative/webview
+ \title WebView
+*/
+
+/*!
+ \example declarative/workerscript
+ \title WorkerScript
+*/
+
+/*!
+ \example declarative/xmldata
+ \title XML Data
+*/
+
+/*!
+ \example declarative/xmlhttprequest
+ \title XMLHttpRequest
+*/
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/doc/src/examples/qml-focus.qdoc b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp
index 92d93b2..13cd2fe 100644
--- a/doc/src/examples/qml-focus.qdoc
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp
@@ -38,12 +38,20 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#include "instrument.h"
-/*!
- \title Focus
- \example declarative/focus
+Instrument::Instrument(QObject *parent)
+ : QObject(parent)
+{
+}
- This example shows how to handle keys and focus in QML.
+QString Instrument::type() const
+{
+ return m_type;
+}
+
+void Instrument::setType(const QString &type)
+{
+ m_type = type;
+}
- \image qml-focus-example.png
-*/
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.");
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index f8b773e..f79a853 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -375,9 +375,11 @@ FxGridItem *QDeclarativeGridViewPrivate::createItem(int modelIndex)
if (QDeclarativeItem *item = model->item(modelIndex, false)) {
listItem = new FxGridItem(item, q);
listItem->index = modelIndex;
- listItem->item->setZValue(1);
- // complete
- model->completeItem();
+ if (model->completePending()) {
+ // complete
+ listItem->item->setZValue(1);
+ model->completeItem();
+ }
listItem->item->setParentItem(q->viewport());
unrequestedItems.remove(listItem->item);
}
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 60e8f6c..c88dab2 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -570,9 +570,11 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex)
listItem->attached->m_prevSection = sectionAt(modelIndex-1);
}
}
- listItem->item->setZValue(1);
- // complete
- model->completeItem();
+ if (model->completePending()) {
+ // complete
+ listItem->item->setZValue(1);
+ model->completeItem();
+ }
listItem->item->setParentItem(q->viewport());
QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
index 95f6276..d49bb02 100644
--- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
@@ -346,21 +346,26 @@ void QDeclarativeRepeater::itemsInserted(int index, int count)
void QDeclarativeRepeater::itemsRemoved(int index, int count)
{
Q_D(QDeclarativeRepeater);
- if (!isComponentComplete())
+ if (!isComponentComplete() || count <= 0)
return;
while (count--) {
QDeclarativeItem *item = d->deletables.takeAt(index);
- if (item) {
+ if (item)
d->model->release(item);
- }
+ else
+ break;
}
}
void QDeclarativeRepeater::itemsMoved(int from, int to, int count)
{
Q_D(QDeclarativeRepeater);
- if (!isComponentComplete())
+ if (!isComponentComplete() || count <= 0)
return;
+ if (from + count > d->deletables.count()) {
+ regenerate();
+ return;
+ }
QList<QDeclarativeItem*> removed;
int removedCount = count;
while (removedCount--)
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 2161e23..b618183 100644
--- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
@@ -726,8 +726,18 @@ void QDeclarativeTextInput::setEchoMode(QDeclarativeTextInput::EchoMode echo)
Q_D(QDeclarativeTextInput);
if (echoMode() == echo)
return;
-
+ Qt::InputMethodHints imHints = inputMethodHints();
+ if (echo == Password || echo == NoEcho)
+ imHints |= Qt::ImhHiddenText;
+ else
+ imHints &= ~Qt::ImhHiddenText;
+ if (echo != Normal)
+ imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ else
+ imHints &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ setInputMethodHints(imHints);
d->control->setEchoMode((uint)echo);
+ update();
emit echoModeChanged(echoMode());
}
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index e2d8bc7..43cafe3 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -176,6 +176,11 @@ QDeclarativeVisualModel::ReleaseFlags QDeclarativeVisualItemModel::release(QDecl
return 0;
}
+bool QDeclarativeVisualItemModel::completePending() const
+{
+ return false;
+}
+
void QDeclarativeVisualItemModel::completeItem()
{
// Nothing to do
@@ -352,9 +357,10 @@ public:
VDMDelegateDataType *m_delegateDataType;
friend class QDeclarativeVisualDataModelData;
- bool m_metaDataCreated;
- bool m_metaDataCacheable;
- bool m_delegateValidated;
+ bool m_metaDataCreated : 1;
+ bool m_metaDataCacheable : 1;
+ bool m_delegateValidated : 1;
+ bool m_completePending : 1;
QDeclarativeVisualDataModelData *data(QObject *item);
@@ -567,7 +573,7 @@ QDeclarativeVisualDataModelParts::QDeclarativeVisualDataModelParts(QDeclarativeV
QDeclarativeVisualDataModelPrivate::QDeclarativeVisualDataModelPrivate(QDeclarativeContext *ctxt)
: m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0)
, m_context(ctxt), m_parts(0), m_delegateDataType(0), m_metaDataCreated(false)
-, m_metaDataCacheable(false), m_delegateValidated(false), m_listAccessor(0)
+, m_metaDataCacheable(false), m_delegateValidated(false), m_completePending(false), m_listAccessor(0)
{
}
@@ -1026,11 +1032,14 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
QDeclarativeVisualDataModelData *data = new QDeclarativeVisualDataModelData(index, this);
ctxt->setContextProperty(QLatin1String("model"), data);
ctxt->setContextObject(data);
+ d->m_completePending = false;
nobj = d->m_delegate->beginCreate(ctxt);
- if (complete)
+ if (complete) {
d->m_delegate->completeCreate();
- else
+ } else {
+ d->m_completePending = true;
needComplete = true;
+ }
if (nobj) {
QDeclarative_setParent_noEvent(ctxt, nobj);
QDeclarative_setParent_noEvent(data, nobj);
@@ -1066,6 +1075,14 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray
return item;
}
+bool QDeclarativeVisualDataModel::completePending() const
+{
+ Q_D(const QDeclarativeVisualDataModel);
+ if (d->m_visualItemModel)
+ return d->m_visualItemModel->completePending();
+ return d->m_completePending;
+}
+
void QDeclarativeVisualDataModel::completeItem()
{
Q_D(QDeclarativeVisualDataModel);
@@ -1075,6 +1092,7 @@ void QDeclarativeVisualDataModel::completeItem()
}
d->m_delegate->completeCreate();
+ d->m_completePending = false;
}
QString QDeclarativeVisualDataModel::stringValue(int index, const QString &name)
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
index 0a9173f..edfd387 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h
@@ -82,6 +82,7 @@ public:
virtual bool isValid() const = 0;
virtual QDeclarativeItem *item(int index, bool complete=true) = 0;
virtual ReleaseFlags release(QDeclarativeItem *item) = 0;
+ virtual bool completePending() const = 0;
virtual void completeItem() = 0;
virtual QVariant evaluate(int index, const QString &expression, QObject *objectContext) = 0;
virtual QString stringValue(int, const QString &) { return QString(); }
@@ -123,6 +124,7 @@ public:
virtual bool isValid() const;
virtual QDeclarativeItem *item(int index, bool complete=true);
virtual ReleaseFlags release(QDeclarativeItem *item);
+ virtual bool completePending() const;
virtual void completeItem();
virtual QString stringValue(int index, const QString &role);
virtual QVariant evaluate(int index, const QString &expression, QObject *objectContext);
@@ -177,6 +179,7 @@ public:
QDeclarativeItem *item(int index, bool complete=true);
QDeclarativeItem *item(int index, const QByteArray &, bool complete=true);
ReleaseFlags release(QDeclarativeItem *item);
+ bool completePending() const;
void completeItem();
virtual QString stringValue(int index, const QString &role);
QVariant evaluate(int index, const QString &expression, QObject *objectContext);
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 3899e73..161ce56 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -152,7 +152,7 @@ int statusId = qRegisterMetaType<QDeclarativeComponent::Status>("QDeclarativeCom
\value Null This QDeclarativeComponent has no data. Call loadUrl() or setData() to add QML content.
\value Ready This QDeclarativeComponent is ready and create() may be called.
\value Loading This QDeclarativeComponent is loading network data.
- \value Error An error has occured. Calling errorDescription() to retrieve a description.
+ \value Error An error has occured. Call errors() to retrieve a list of \{QDeclarativeError}{errors}.
*/
void QDeclarativeComponentPrivate::typeDataReady()
@@ -237,6 +237,18 @@ QDeclarativeComponent::~QDeclarativeComponent()
}
/*!
+ \qmlproperty enumeration Component::status
+ This property holds the status of component loading. It can be one of:
+ \list
+ \o Null - no data is available for the component
+ \o Ready - the component has been loaded, and can be used to create instances.
+ \o Loading - the component is currently being loaded
+ \o Error - an error occurred while loading the component.
+ Calling errorsString() will provide a human-readable description of any errors.
+ \endlist
+ */
+
+/*!
\property QDeclarativeComponent::status
The component's current \l{QDeclarativeComponent::Status} {status}.
*/
@@ -255,6 +267,14 @@ QDeclarativeComponent::Status QDeclarativeComponent::status() const
}
/*!
+ \qmlproperty bool Component::isNull
+
+ Is true if the component is in the Null state, false otherwise.
+
+ Equivalent to status == Component.Null.
+*/
+
+/*!
\property QDeclarativeComponent::isNull
Is true if the component is in the Null state, false otherwise.
@@ -267,6 +287,14 @@ bool QDeclarativeComponent::isNull() const
}
/*!
+ \qmlproperty bool Component::isReady
+
+ Is true if the component is in the Ready state, false otherwise.
+
+ Equivalent to status == Component.Ready.
+*/
+
+/*!
\property QDeclarativeComponent::isReady
Is true if the component is in the Ready state, false otherwise.
@@ -279,6 +307,16 @@ bool QDeclarativeComponent::isReady() const
}
/*!
+ \qmlproperty bool Component::isError
+
+ Is true if the component is in the Error state, false otherwise.
+
+ Equivalent to status == Component.Error.
+
+ Calling errorsString() will provide a human-readable description of any errors.
+*/
+
+/*!
\property QDeclarativeComponent::isError
Is true if the component is in the Error state, false otherwise.
@@ -291,6 +329,14 @@ bool QDeclarativeComponent::isError() const
}
/*!
+ \qmlproperty bool Component::isLoading
+
+ Is true if the component is in the Loading state, false otherwise.
+
+ Equivalent to status == Component::Loading.
+*/
+
+/*!
\property QDeclarativeComponent::isLoading
Is true if the component is in the Loading state, false otherwise.
@@ -303,6 +349,12 @@ bool QDeclarativeComponent::isLoading() const
}
/*!
+ \qmlproperty real Component::progress
+ The progress of loading the component, from 0.0 (nothing loaded)
+ to 1.0 (finished).
+*/
+
+/*!
\property QDeclarativeComponent::progress
The progress of loading the component, from 0.0 (nothing loaded)
to 1.0 (finished).
@@ -488,6 +540,17 @@ QList<QDeclarativeError> QDeclarativeComponent::errors() const
}
/*!
+ \qmlmethod string Component::errorsString()
+
+ Returns a human-readable description of any errors.
+
+ The string includes the file, location, and description of each error.
+ If multiple errors are present they are separated by a newline character.
+
+ If no errors are present, an empty string is returned.
+*/
+
+/*!
\internal
errorsString is only meant as a way to get the errors in script
*/
@@ -506,6 +569,11 @@ QString QDeclarativeComponent::errorsString() const
}
/*!
+ \qmlproperty url Component::url
+ The component URL. This is the URL that was used to construct the component.
+*/
+
+/*!
\property QDeclarativeComponent::url
The component URL. This is the URL passed to either the constructor,
or the loadUrl() or setData() methods.
@@ -525,6 +593,13 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
}
/*!
+ \qmlmethod object Component::createObject()
+ Returns an object instance from this component, or null if object creation fails.
+
+ The object will be created in the same context as the component was created in.
+*/
+
+/*!
\internal
A version of create which returns a scriptObject, for use in script
*/
@@ -533,10 +608,10 @@ QScriptValue QDeclarativeComponent::createObject()
Q_D(QDeclarativeComponent);
QDeclarativeContext* ctxt = creationContext();
if(!ctxt)
- return QScriptValue();
+ return QScriptValue(QScriptValue::NullValue);
QObject* ret = create(ctxt);
if (!ret)
- return QScriptValue();
+ return QScriptValue(QScriptValue::NullValue);
QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(d->engine);
QDeclarativeData::get(ret, true)->setImplicitDestructible();
return priv->objectClass->newQObject(ret, QMetaType::QObjectStar);
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
index adeb7a5..0eb7e1b 100644
--- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp
+++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
@@ -617,7 +617,8 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData
int majorVersion;
int minorVersion;
QDeclarativeEnginePrivate::ImportedNamespace *typeNamespace = 0;
- if (!QDeclarativeEnginePrivate::get(engine)->resolveType(unit->imports, typeName, &ref.type, &url, &majorVersion, &minorVersion, &typeNamespace)
+ QString errorString;
+ if (!QDeclarativeEnginePrivate::get(engine)->resolveType(unit->imports, typeName, &ref.type, &url, &majorVersion, &minorVersion, &typeNamespace, &errorString)
|| typeNamespace)
{
// Known to not be a type:
@@ -630,7 +631,8 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData
if (typeNamespace)
error.setDescription(tr("Namespace %1 cannot be used as a type").arg(userTypeName));
else
- error.setDescription(tr("%1 is not a type").arg(userTypeName));
+ error.setDescription(tr("%1 %2").arg(userTypeName).arg(errorString));
+
if (!parserRef->refObjects.isEmpty()) {
QDeclarativeParser::Object *obj = parserRef->refObjects.first();
error.setLine(obj->location.start.line);
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 8eae120..0ee6dfe 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -112,6 +112,7 @@ Q_DECLARE_METATYPE(QDeclarativeProperty)
QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(qmlImportTrace, QML_IMPORT_TRACE)
+DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES)
/*!
\qmlclass QtObject QObject
@@ -293,6 +294,10 @@ QNetworkAccessManager *QDeclarativeScriptEngine::networkAccessManager()
QDeclarativeEnginePrivate::~QDeclarativeEnginePrivate()
{
+ Q_ASSERT(inProgressCreations == 0);
+ Q_ASSERT(bindValues.isEmpty());
+ Q_ASSERT(parserStatus.isEmpty());
+
while (cleanup) {
QDeclarativeCleanup *c = cleanup;
cleanup = c->next;
@@ -317,10 +322,6 @@ QDeclarativeEnginePrivate::~QDeclarativeEnginePrivate()
delete globalClass;
globalClass = 0;
- for(int ii = 0; ii < bindValues.count(); ++ii)
- clear(bindValues[ii]);
- for(int ii = 0; ii < parserStatus.count(); ++ii)
- clear(parserStatus[ii]);
for(QHash<int, QDeclarativeCompiledData*>::ConstIterator iter = m_compositeTypes.constBegin(); iter != m_compositeTypes.constEnd(); ++iter)
(*iter)->release();
for(QHash<const QMetaObject *, QDeclarativePropertyCache *>::Iterator iter = propertyCache.begin(); iter != propertyCache.end(); ++iter)
@@ -770,7 +771,9 @@ void QDeclarativeEngine::setObjectOwnership(QObject *object, ObjectOwnership own
if (!object)
return;
- QDeclarativeData *ddata = QDeclarativeData::get(object, true);
+ // No need to do anything if CppOwnership and there is no QDeclarativeData as
+ // the current ownership must be CppOwnership
+ QDeclarativeData *ddata = QDeclarativeData::get(object, ownership == JavaScriptOwnership);
if (!ddata)
return;
@@ -808,9 +811,6 @@ void qmlExecuteDeferred(QObject *object)
data->deferredComponent = 0;
QDeclarativeComponentPrivate::complete(ep, &state);
-
- if (!state.errors.isEmpty())
- ep->warning(state.errors);
}
}
@@ -1161,7 +1161,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr
} else if (ctxt->argument(1).isNumber()) {
enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32());
} else {
- return ctxt->throwError("Qt.formatDateTime(): Invalid datetime formate");
+ return ctxt->throwError("Qt.formatDateTime(): Invalid datetime format");
}
}
return engine->newVariant(qVariantFromValue(date.toString(enumFormat)));
@@ -1543,55 +1543,65 @@ struct QDeclarativeEnginePrivate::ImportedNamespace {
QList<bool> isLibrary;
QList<QDeclarativeDirComponents> qmlDirComponents;
- bool find(const QByteArray& type, int *vmajor, int *vminor, QDeclarativeType** type_return, QUrl* url_return,
- QUrl *base = 0)
+
+ bool find_helper(int i, const QByteArray& type, int *vmajor, int *vminor,
+ QDeclarativeType** type_return, QUrl* url_return,
+ QUrl *base = 0, bool *typeRecursionDetected = 0)
{
- for (int i=0; i<urls.count(); ++i) {
- int vmaj = majversions.at(i);
- int vmin = minversions.at(i);
-
- QByteArray qt = uris.at(i).toUtf8();
- qt += '/';
- qt += type;
-
- QDeclarativeType *t = QDeclarativeMetaType::qmlType(qt,vmaj,vmin);
- if (t) {
- if (vmajor) *vmajor = vmaj;
- if (vminor) *vminor = vmin;
- if (type_return)
- *type_return = t;
- return true;
- }
+ int vmaj = majversions.at(i);
+ int vmin = minversions.at(i);
+
+ QByteArray qt = uris.at(i).toUtf8();
+ qt += '/';
+ qt += type;
+
+ QDeclarativeType *t = QDeclarativeMetaType::qmlType(qt,vmaj,vmin);
+ if (t) {
+ if (vmajor) *vmajor = vmaj;
+ if (vminor) *vminor = vmin;
+ if (type_return)
+ *type_return = t;
+ return true;
+ }
- QUrl url = QUrl(urls.at(i) + QLatin1Char('/') + QString::fromUtf8(type) + QLatin1String(".qml"));
- QDeclarativeDirComponents qmldircomponents = qmlDirComponents.at(i);
-
- bool typeWasDeclaredInQmldir = false;
- if (!qmldircomponents.isEmpty()) {
- const QString typeName = QString::fromUtf8(type);
- foreach (const QDeclarativeDirParser::Component &c, qmldircomponents) {
- if (c.typeName == typeName) {
- typeWasDeclaredInQmldir = true;
-
- // importing version -1 means import ALL versions
- if ((vmaj == -1) || (c.majorVersion < vmaj || (c.majorVersion == vmaj && vmin >= c.minorVersion))) {
- QUrl candidate = url.resolved(QUrl(c.fileName));
- if (c.internal && base) {
- if (base->resolved(QUrl(c.fileName)) != candidate)
- continue; // failed attempt to access an internal type
- }
- if (url_return)
- *url_return = candidate;
- return true;
+ QUrl url = QUrl(urls.at(i) + QLatin1Char('/') + QString::fromUtf8(type) + QLatin1String(".qml"));
+ QDeclarativeDirComponents qmldircomponents = qmlDirComponents.at(i);
+
+ bool typeWasDeclaredInQmldir = false;
+ if (!qmldircomponents.isEmpty()) {
+ const QString typeName = QString::fromUtf8(type);
+ foreach (const QDeclarativeDirParser::Component &c, qmldircomponents) {
+ if (c.typeName == typeName) {
+ typeWasDeclaredInQmldir = true;
+
+ // importing version -1 means import ALL versions
+ if ((vmaj == -1) || (c.majorVersion < vmaj || (c.majorVersion == vmaj && vmin >= c.minorVersion))) {
+ QUrl candidate = url.resolved(QUrl(c.fileName));
+ if (c.internal && base) {
+ if (base->resolved(QUrl(c.fileName)) != candidate)
+ continue; // failed attempt to access an internal type
}
+ if (base && *base == candidate) {
+ if (typeRecursionDetected)
+ *typeRecursionDetected = true;
+ continue; // no recursion
+ }
+ if (url_return)
+ *url_return = candidate;
+ return true;
}
}
}
+ }
- if (!typeWasDeclaredInQmldir && !isLibrary.at(i)) {
- // XXX search non-files too! (eg. zip files, see QT-524)
- QFileInfo f(toLocalFileOrQrc(url));
- if (f.exists()) {
+ if (!typeWasDeclaredInQmldir && !isLibrary.at(i)) {
+ // XXX search non-files too! (eg. zip files, see QT-524)
+ QFileInfo f(toLocalFileOrQrc(url));
+ if (f.exists()) {
+ if (base && *base == url) { // no recursion
+ if (typeRecursionDetected)
+ *typeRecursionDetected = true;
+ } else {
if (url_return)
*url_return = url;
return true;
@@ -1600,6 +1610,63 @@ struct QDeclarativeEnginePrivate::ImportedNamespace {
}
return false;
}
+
+ bool find(const QByteArray& type, int *vmajor, int *vminor, QDeclarativeType** type_return,
+ QUrl* url_return, QUrl *base = 0, QString *errorString = 0)
+ {
+ bool typeRecursionDetected = false;
+ for (int i=0; i<urls.count(); ++i) {
+ if (find_helper(i, type, vmajor, vminor, type_return, url_return, base, &typeRecursionDetected)) {
+ if (qmlCheckTypes()) {
+ // check for type clashes
+ for (int j = i+1; j<urls.count(); ++j) {
+ if (find_helper(j, type, vmajor, vminor, 0, 0, base)) {
+ if (errorString) {
+ QString u1 = urls.at(i);
+ QString u2 = urls.at(j);
+ if (base) {
+ QString b = base->toString();
+ int slash = b.lastIndexOf(QLatin1Char('/'));
+ if (slash >= 0) {
+ b = b.left(slash+1);
+ QString l = b.left(slash);
+ if (u1.startsWith(b))
+ u1 = u1.mid(b.count());
+ else if (u1 == l)
+ u1 = QDeclarativeEngine::tr("local directory");
+ if (u2.startsWith(b))
+ u2 = u2.mid(b.count());
+ else if (u2 == l)
+ u2 = QDeclarativeEngine::tr("local directory");
+ }
+ }
+
+ if (u1 != u2)
+ *errorString
+ = QDeclarativeEngine::tr("is ambiguous. Found in %1 and in %2")
+ .arg(u1).arg(u2);
+ else
+ *errorString
+ = QDeclarativeEngine::tr("is ambiguous. Found in %1 in version %2.%3 and %4.%5")
+ .arg(u1)
+ .arg(majversions.at(i)).arg(minversions.at(i))
+ .arg(majversions.at(j)).arg(minversions.at(j));
+ }
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ }
+ if (errorString) {
+ if (typeRecursionDetected)
+ *errorString = QDeclarativeEngine::tr("is instantiated recursively");
+ else
+ *errorString = QDeclarativeEngine::tr("is not a type");
+ }
+ return false;
+ }
};
static bool greaterThan(const QString &s1, const QString &s2)
@@ -1809,30 +1876,37 @@ public:
return true;
}
- bool find(const QByteArray& type, int *vmajor, int *vminor, QDeclarativeType** type_return, QUrl* url_return)
+ bool find(const QByteArray& type, int *vmajor, int *vminor, QDeclarativeType** type_return,
+ QUrl* url_return, QString *errorString)
{
QDeclarativeEnginePrivate::ImportedNamespace *s = 0;
int slash = type.indexOf('/');
if (slash >= 0) {
- s = set.value(QString::fromUtf8(type.left(slash)));
- if (!s)
- return false; // qualifier must be a namespace
+ QString namespaceName = QString::fromUtf8(type.left(slash));
+ s = set.value(namespaceName);
+ if (!s) {
+ if (errorString)
+ *errorString = QDeclarativeEngine::tr("- %1 is not a namespace").arg(namespaceName);
+ return false;
+ }
int nslash = type.indexOf('/',slash+1);
- if (nslash > 0)
- return false; // only single qualification allowed
+ if (nslash > 0) {
+ if (errorString)
+ *errorString = QDeclarativeEngine::tr("- nested namespaces not allowed");
+ return false;
+ }
} else {
s = &unqualifiedset;
}
QByteArray unqualifiedtype = slash < 0 ? type : type.mid(slash+1); // common-case opt (QString::mid works fine, but slower)
if (s) {
- if (s->find(unqualifiedtype,vmajor,vminor,type_return,url_return, &base))
+ if (s->find(unqualifiedtype,vmajor,vminor,type_return,url_return, &base, errorString))
return true;
if (s->urls.count() == 1 && !s->isLibrary[0] && url_return && s != &unqualifiedset) {
// qualified, and only 1 url
*url_return = QUrl(s->urls[0]+QLatin1Char('/')).resolved(QUrl(QString::fromUtf8(unqualifiedtype) + QLatin1String(".qml")));
return true;
}
-
}
return false;
@@ -2329,7 +2403,7 @@ bool QDeclarativeEnginePrivate::addToImport(Imports* imports, const QDeclarative
\sa addToImport()
*/
-bool QDeclarativeEnginePrivate::resolveType(const Imports& imports, const QByteArray& type, QDeclarativeType** type_return, QUrl* url_return, int *vmaj, int *vmin, ImportedNamespace** ns_return) const
+bool QDeclarativeEnginePrivate::resolveType(const Imports& imports, const QByteArray& type, QDeclarativeType** type_return, QUrl* url_return, int *vmaj, int *vmin, ImportedNamespace** ns_return, QString *errorString) const
{
ImportedNamespace* ns = imports.d->findNamespace(QString::fromUtf8(type));
if (ns) {
@@ -2338,7 +2412,7 @@ bool QDeclarativeEnginePrivate::resolveType(const Imports& imports, const QByteA
return true;
}
if (type_return || url_return) {
- if (imports.d->find(type,vmaj,vmin,type_return,url_return)) {
+ if (imports.d->find(type,vmaj,vmin,type_return,url_return, errorString)) {
if (qmlImportTrace()) {
if (type_return && *type_return && url_return && !url_return->isEmpty())
qDebug() << "QDeclarativeEngine::resolveType" << type << '=' << (*type_return)->typeName() << *url_return;
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index f6b9bcb..743275e 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -290,7 +290,8 @@ public:
bool resolveType(const Imports&, const QByteArray& type,
QDeclarativeType** type_return, QUrl* url_return,
int *version_major, int *version_minor,
- ImportedNamespace** ns_return) const;
+ ImportedNamespace** ns_return,
+ QString *errorString = 0) const;
void resolveTypeInNamespace(ImportedNamespace*, const QByteArray& type,
QDeclarativeType** type_return, QUrl* url_return,
int *version_major, int *version_minor ) const;
diff --git a/src/declarative/qml/qdeclarativeextensionplugin.cpp b/src/declarative/qml/qdeclarativeextensionplugin.cpp
index 863bfc4..2c15385 100644
--- a/src/declarative/qml/qdeclarativeextensionplugin.cpp
+++ b/src/declarative/qml/qdeclarativeextensionplugin.cpp
@@ -64,8 +64,11 @@ QT_BEGIN_NAMESPACE
as any manipulation of the engine's root context may cause conflicts
or other issues in the library user's code.
- See \l {Extending QML in C++} for details how to write a QML extension plugin.
- See \l {How to Create Qt Plugins} for general Qt plugin documentation.
+ See \l {Tutorial: Writing QML extensions with C++} for details on creating
+ QML extensions, including how to build a plugin with with QDeclarativeExtensionPlugin.
+ For a simple overview, see the \l{declarative/plugins}{plugins} example.
+
+ Also see \l {How to Create Qt Plugins} for general Qt plugin documentation.
\sa QDeclarativeEngine::importPlugin()
*/
@@ -73,8 +76,12 @@ QT_BEGIN_NAMESPACE
/*!
\fn void QDeclarativeExtensionPlugin::registerTypes(const char *uri)
- Registers the QML types in the given \a uri. Here you call qmlRegisterType() for
- all types which are provided by the extension plugin.
+ Registers the QML types in the given \a uri. Subclasses should implement
+ this to call qmlRegisterType() for all types which are provided by the extension
+ plugin.
+
+ The \a uri is an identifier for the plugin generated by the QML engine
+ based on the name and path of the extension's plugin library.
*/
/*!
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
index d9ea8dc..5fcb7ee 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -247,7 +247,7 @@ static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo,
QMetaProperty property = mo->property(ii);
int otherIndex = ignoreEnd->indexOfProperty(property.name());
- if (otherIndex >= ignoreStart->classInfoOffset() + ignoreStart->classInfoCount()) {
+ if (otherIndex >= ignoreStart->propertyOffset() + ignoreStart->propertyCount()) {
builder.addProperty(QByteArray("__qml_ignore__") + property.name(), QByteArray("void"));
// Skip
} else {
diff --git a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
index b116129..399831d 100644
--- a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
+++ b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
@@ -59,10 +59,6 @@ QT_BEGIN_NAMESPACE
To use a factory, assign it to the relevant QDeclarativeEngine using
QDeclarativeEngine::setNetworkAccessManagerFactory().
- If the created QNetworkAccessManager becomes invalid, due to a
- change in proxy settings, for example, call the invalidate() method.
- This will cause all QNetworkAccessManagers to be recreated.
-
Note: the create() method may be called by multiple threads, so ensure the
implementation of this method is reentrant.
@@ -82,7 +78,10 @@ QDeclarativeNetworkAccessManagerFactory::~QDeclarativeNetworkAccessManagerFactor
Implement this method to create a QNetworkAccessManager with \a parent.
This allows proxies, caching and cookie support to be setup appropriately.
- This method should return a new QNetworkAccessManager each time it is called.
+ This method must return a new QNetworkAccessManager each time it is called.
+ The parent of the QNetworkAccessManager must be the \a parent provided.
+ The QNetworkAccessManager(s) created by this
+ function will be destroyed automatically when their parent is destroyed.
Note: this method may be called by multiple threads, so ensure the
implementation of this method is reentrant.
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index e7c8a12..8b96733 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -449,6 +449,14 @@ bool ProcessAST::visit(AST::UiImport *node)
_parser->_errors << error;
return false;
}
+ if (import.qualifier == QLatin1String("Qt")) {
+ QDeclarativeError error;
+ error.setDescription(QCoreApplication::translate("QDeclarativeParser","Reserved name \"Qt\" cannot be used as an qualifier"));
+ error.setLine(node->importIdToken.startLine);
+ error.setColumn(node->importIdToken.startColumn);
+ _parser->_errors << error;
+ return false;
+ }
// Check for script qualifier clashes
bool isScript = import.type == QDeclarativeScriptParser::Import::Script;
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp
index 2641dcf..8afa2f0 100644
--- a/src/declarative/util/qdeclarativepropertychanges.cpp
+++ b/src/declarative/util/qdeclarativepropertychanges.cpp
@@ -125,8 +125,9 @@ QT_BEGIN_NAMESPACE
}
\endqml
- Changes to an Item's parent or anchors should be done using the associated change elements
- (ParentChange and AnchorChanges, respectively) rather than PropertyChanges.
+ Anchor margins should be changed with PropertyChanges, but other anchor changes or changes to
+ an Item's parent should be done using the associated change elements
+ (ParentChange and AnchorChanges, respectively).
\sa {qmlstate}{States}
*/
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 9049b83..689f53c 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -612,6 +612,11 @@ QString QDeclarativeStateChangeScript::typeName() const
anchors.top: window.top;
anchors.bottom: window.bottom
}
+ PropertyChanges {
+ target: content;
+ anchors.topMargin: 3
+ anchors.bottomMargin: 3;
+ }
}
\endqml
@@ -623,6 +628,8 @@ QString QDeclarativeStateChangeScript::typeName() const
}
\endqml
+ Margin animations can be animated using NumberAnimation.
+
For more information on anchors see \l {anchor-layout}{Anchor Layouts}.
*/
diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
index eb59fb1..3cf07a7 100644
--- a/src/declarative/util/qdeclarativeutilmodule.cpp
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -122,6 +122,6 @@ void QDeclarativeUtilModule::defineModule()
qmlRegisterUncreatableType<QDeclarativeAbstractAnimation>("Qt",4,7,"Animation",QDeclarativeAbstractAnimation::tr("Animation is an abstract class"));
qmlRegisterCustomType<QDeclarativeListModel>("Qt", 4,7, "ListModel", new QDeclarativeListModelParser);
- qmlRegisterCustomType<QDeclarativePropertyChanges>("Qt", 4, 6, "PropertyChanges", new QDeclarativePropertyChangesParser);
- qmlRegisterCustomType<QDeclarativeConnections>("Qt", 4, 6, "Connections", new QDeclarativeConnectionsParser);
+ qmlRegisterCustomType<QDeclarativePropertyChanges>("Qt", 4, 7, "PropertyChanges", new QDeclarativePropertyChangesParser);
+ qmlRegisterCustomType<QDeclarativeConnections>("Qt", 4, 7, "Connections", new QDeclarativeConnectionsParser);
}
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 6cc3f7d..326f130 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -7325,6 +7325,18 @@ void QGraphicsItem::setInputMethodHints(Qt::InputMethodHints hints)
{
Q_D(QGraphicsItem);
d->imHints = hints;
+ if (!hasFocus())
+ return;
+ d->scene->d_func()->updateInputMethodSensitivityInViews();
+#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
+ QWidget *fw = QApplication::focusWidget();
+ if (!fw)
+ return;
+ for (int i = 0 ; i < scene()->views().count() ; ++i)
+ if (scene()->views().at(i) == fw)
+ if (QInputContext *inputContext = fw->inputContext())
+ inputContext->update();
+#endif
}
/*!
@@ -7337,13 +7349,11 @@ void QGraphicsItem::setInputMethodHints(Qt::InputMethodHints hints)
void QGraphicsItem::updateMicroFocus()
{
#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
- if (QWidget *fw = qApp->focusWidget()) {
- if (qt_widget_private(fw)->ic || qApp->d_func()->inputContext) {
- if (QInputContext *ic = fw->inputContext()) {
- if (ic)
- ic->update();
- }
- }
+ if (QWidget *fw = QApplication::focusWidget()) {
+ for (int i = 0 ; i < scene()->views().count() ; ++i)
+ if (scene()->views().at(i) == fw)
+ if (QInputContext *inputContext = fw->inputContext())
+ inputContext->update();
#ifndef QT_NO_ACCESSIBILITY
// ##### is this correct
QAccessible::updateAccessibility(fw, 0, QAccessible::StateChanged);
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 8c7fbb4..6b22607 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -861,7 +861,7 @@ inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect)
static_cast<QGraphicsItemEffectSourcePrivate *>(parentp->graphicsEffect->d_func()
->source->d_func())->invalidateCache();
}
- if (parentp->graphicsEffect->isEnabled()) {
+ if (parentp->scene && parentp->graphicsEffect->isEnabled()) {
parentp->dirty = 1;
parentp->fullUpdatePending = 1;
}
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 114de85..c951dce 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -1037,10 +1037,28 @@ QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedReg
void QGraphicsViewPrivate::updateInputMethodSensitivity()
{
Q_Q(QGraphicsView);
- bool enabled = scene && scene->focusItem()
- && (scene->focusItem()->flags() & QGraphicsItem::ItemAcceptsInputMethod);
+ QGraphicsItem *focusItem = 0;
+ bool enabled = scene && (focusItem = scene->focusItem())
+ && (focusItem->d_ptr->flags & QGraphicsItem::ItemAcceptsInputMethod);
q->setAttribute(Qt::WA_InputMethodEnabled, enabled);
q->viewport()->setAttribute(Qt::WA_InputMethodEnabled, enabled);
+
+ if (!enabled) {
+ q->setInputMethodHints(0);
+ return;
+ }
+
+ QGraphicsProxyWidget *proxy = focusItem->d_ptr->isWidget && focusItem->d_ptr->isProxyWidget()
+ ? static_cast<QGraphicsProxyWidget *>(focusItem) : 0;
+ if (!proxy) {
+ q->setInputMethodHints(focusItem->inputMethodHints());
+ } else if (QWidget *widget = proxy->widget()) {
+ if (QWidget *fw = widget->focusWidget())
+ widget = fw;
+ q->setInputMethodHints(widget->inputMethodHints());
+ } else {
+ q->setInputMethodHints(0);
+ }
}
/*!
diff --git a/src/imports/gestures/plugin.cpp b/src/imports/gestures/plugin.cpp
index 9f5d923..b8a9751 100644
--- a/src/imports/gestures/plugin.cpp
+++ b/src/imports/gestures/plugin.cpp
@@ -53,8 +53,7 @@ public:
virtual void registerTypes(const char *uri)
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.gestures"));
- qmlRegisterCustomType<QDeclarativeGestureArea>(uri,1,0, "GestureArea", "QDeclarativeGestureArea",
- new QDeclarativeGestureAreaParser);
+ qmlRegisterCustomType<QDeclarativeGestureArea>(uri,1,0, "GestureArea", new QDeclarativeGestureAreaParser);
}
};
diff --git a/src/imports/gestures/qdeclarativegesturearea_p.h b/src/imports/gestures/qdeclarativegesturearea_p.h
index 8e2c066..0195511 100644
--- a/src/imports/gestures/qdeclarativegesturearea_p.h
+++ b/src/imports/gestures/qdeclarativegesturearea_p.h
@@ -59,7 +59,7 @@ QT_MODULE(Declarative)
class QDeclarativeBoundSignal;
class QDeclarativeContext;
class QDeclarativeGestureAreaPrivate;
-class Q_DECLARATIVE_EXPORT QDeclarativeGestureArea : public QDeclarativeItem
+class QDeclarativeGestureArea : public QDeclarativeItem
{
Q_OBJECT
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
index 04731b1..75c2bb1 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
class QGL2PaintEngineExPrivate;
-class QGLTextureGlyphCache : public QObject, public QTextureGlyphCache
+class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QObject, public QTextureGlyphCache
{
Q_OBJECT
public:
diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp
index c650346..16b0cbe 100644
--- a/tests/auto/declarative/examples/tst_examples.cpp
+++ b/tests/auto/declarative/examples/tst_examples.cpp
@@ -81,6 +81,7 @@ tst_examples::tst_examples()
// Add directories you want excluded here
excludedDirs << "examples/declarative/extending";
+ excludedDirs << "examples/declarative/tutorials/extending";
excludedDirs << "examples/declarative/plugins";
excludedDirs << "examples/declarative/proxywidgets";
excludedDirs << "examples/declarative/gestures";
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml
new file mode 100644
index 0000000..9c46c3f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml
@@ -0,0 +1,10 @@
+import Qt.test 1.0
+import Qt 4.7
+
+MyDeferredObject {
+ value: undefined // error is resolved before complete
+ objectProperty: undefined // immediate error
+ objectProperty2: QtObject {
+ Component.onCompleted: value = 10
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
index 154ff4d..8a4605a 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
@@ -39,6 +39,8 @@
**
****************************************************************************/
#include "testtypes.h"
+#include <QWidget>
+#include <QPlainTextEdit>
class BaseExtensionObject : public QObject
{
@@ -80,6 +82,24 @@ public:
DefaultPropertyExtensionObject(QObject *parent) : QObject(parent) {}
};
+class QWidgetDeclarativeUI : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
+
+signals:
+ void widthChanged();
+
+public:
+ QWidgetDeclarativeUI(QObject *other) : QObject(other) { }
+
+public:
+ int width() const { return 0; }
+ void setWidth(int) { }
+};
+
+
void registerTypes()
{
qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject");
@@ -91,6 +111,9 @@ void registerTypes()
qmlRegisterType<NumberAssignment>("Qt.test", 1,0, "NumberAssignment");
qmlRegisterExtendedType<DefaultPropertyExtendedObject, DefaultPropertyExtensionObject>("Qt.test", 1,0, "DefaultPropertyExtendedObject");
qmlRegisterType<OverrideDefaultPropertyObject>("Qt.test", 1,0, "OverrideDefaultPropertyObject");
+
+ qmlRegisterExtendedType<QWidget,QWidgetDeclarativeUI>("Qt.test",1,0,"QWidget");
+ qmlRegisterType<QPlainTextEdit>("Qt.test",1,0,"QPlainTextEdit");
}
#include "testtypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 97fced4..491a736 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -89,6 +89,7 @@ private slots:
void contextPropertiesTriggerReeval();
void objectPropertiesTriggerReeval();
void deferredProperties();
+ void deferredPropertiesErrors();
void extensionObjects();
void overrideExtensionProperties();
void attachedProperties();
@@ -133,6 +134,7 @@ private slots:
void numberAssignment();
void bug1();
+ void bug2();
void dynamicCreationCrash();
void regExpBug();
void nullObjectBinding();
@@ -543,6 +545,25 @@ void tst_qdeclarativeecmascript::deferredProperties()
QCOMPARE(qmlObject->value(), 19);
}
+// Check errors on deferred properties are correctly emitted
+void tst_qdeclarativeecmascript::deferredPropertiesErrors()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("deferredPropertiesErrors.qml"));
+ MyDeferredObject *object =
+ qobject_cast<MyDeferredObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->value(), 0);
+ QVERIFY(object->objectProperty() == 0);
+ QVERIFY(object->objectProperty2() == 0);
+
+ QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ qmlExecuteDeferred(object);
+
+ delete object;
+}
+
void tst_qdeclarativeecmascript::extensionObjects()
{
QDeclarativeComponent component(&engine, TEST_FILE("extensionObjects.qml"));
@@ -1231,6 +1252,17 @@ void tst_qdeclarativeecmascript::bug1()
delete object;
}
+void tst_qdeclarativeecmascript::bug2()
+{
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt.test 1.0;\nQPlainTextEdit { width: 100 }", QUrl());
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
// Don't crash in createObject when the component has errors.
void tst_qdeclarativeecmascript::dynamicCreationCrash()
{
diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
index ee320aa..b0db771 100644
--- a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
+++ b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
@@ -297,6 +297,8 @@ void tst_qdeclarativeengine::objectOwnership()
{
QObject o;
QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
+ QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::CppOwnership);
+ QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::JavaScriptOwnership);
QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::JavaScriptOwnership);
QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::CppOwnership);
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml
index 8eb9768..2f49418 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignToNamespace.qml
@@ -1,5 +1,5 @@
-import Qt 4.7 as Qt
+import Qt 4.7 as Qt47
-Qt.QtObject {
- Qt: 10
+Qt47.QtObject {
+ Qt47: 10
}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml
index e870046..c997356 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/dynamicObjectProperties.qml
@@ -1,6 +1,6 @@
import Test 1.0
import Qt 4.7
-import Qt 4.7 as Qt
+import Qt 4.7 as Qt47
QtObject {
property QtObject objectProperty
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
index 6d33361..303b5a5 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/lib/com/nokia/installedtest/InstalledTest.qml
@@ -1,2 +1,2 @@
-import Qt 4.7 as Qt
-Qt.Rectangle {}
+import Qt 4.7 as Qt47
+Qt47.Rectangle {}
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index c39e6f7..ff03005 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -48,12 +48,16 @@
#include <private/qdeclarativeproperty_p.h>
#include <private/qdeclarativemetatype_p.h>
+#include <private/qdeclarativeglobal_p.h>
#include "testtypes.h"
#include "../../../shared/util.h"
#include "testhttpserver.h"
+DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES)
+
+
/*
This test case covers QML language issues. This covers everything that does not
involve evaluating ECMAScript expressions and bindings.
@@ -1257,14 +1261,14 @@ void tst_qdeclarativelanguage::importsBuiltin_data()
<< "import com.nokia.Test 1.11\n"
"import com.nokia.Test 1.12\n"
"Test {}"
- << "TestType2"
- << "";
+ << (!qmlCheckTypes()?"TestType2":"")
+ << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
QTest::newRow("multiversion 2")
<< "import com.nokia.Test 1.11\n"
"import com.nokia.Test 1.12\n"
"OldTest {}"
- << "TestType"
- << "";
+ << (!qmlCheckTypes()?"TestType":"")
+ << (!qmlCheckTypes()?"":"OldTest is ambiguous. Found in com/nokia/Test in version 1.12 and 1.11");
QTest::newRow("qualified multiversion 3")
<< "import com.nokia.Test 1.0 as T0\n"
"import com.nokia.Test 1.8 as T8\n"
@@ -1312,12 +1316,12 @@ void tst_qdeclarativelanguage::importsLocal_data()
QTest::newRow("local import QTBUG-7721 A")
<< "subdir.Test {}" // no longer allowed (QTBUG-7721)
<< ""
- << "subdir.Test is not a type";
+ << "subdir.Test - subdir is not a namespace";
QTest::newRow("local import QTBUG-7721 B")
<< "import \"subdir\" as X\n"
"X.subsubdir.SubTest {}" // no longer allowed (QTBUG-7721)
<< ""
- << "X.subsubdir.SubTest is not a type";
+ << "X.subsubdir.SubTest - nested namespaces not allowed";
QTest::newRow("local import as")
<< "import \"subdir\" as T\n"
"T.Test {}"
@@ -1332,8 +1336,8 @@ void tst_qdeclarativelanguage::importsLocal_data()
<< "import \"subdir\"\n"
"import com.nokia.Test 1.0\n"
"Test {}"
- << "TestType"
- << "";
+ << (!qmlCheckTypes()?"TestType":"")
+ << (!qmlCheckTypes()?"":"Test is ambiguous. Found in com/nokia/Test and in subdir");
}
void tst_qdeclarativelanguage::importsLocal()
@@ -1478,46 +1482,52 @@ void tst_qdeclarativelanguage::importsOrder_data()
QTest::addColumn<QString>("type");
QTest::addColumn<QString>("error");
+ QTest::newRow("double import") <<
+ "import com.nokia.installedtest 1.4\n"
+ "import com.nokia.installedtest 1.4\n"
+ "InstalledTest {}"
+ << (!qmlCheckTypes()?"QDeclarativeText":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.4");
QTest::newRow("installed import overrides 1") <<
"import com.nokia.installedtest 1.0\n"
"import com.nokia.installedtest 1.4\n"
"InstalledTest {}"
- << "QDeclarativeText"
- << "";
+ << (!qmlCheckTypes()?"QDeclarativeText":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
QTest::newRow("installed import overrides 2") <<
"import com.nokia.installedtest 1.4\n"
"import com.nokia.installedtest 1.0\n"
"InstalledTest {}"
- << "QDeclarativeRectangle"
- << "";
+ << (!qmlCheckTypes()?"QDeclarativeRectangle":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
QTest::newRow("installed import re-overrides 1") <<
"import com.nokia.installedtest 1.4\n"
"import com.nokia.installedtest 1.0\n"
"import com.nokia.installedtest 1.4\n"
"InstalledTest {}"
- << "QDeclarativeText"
- << "";
+ << (!qmlCheckTypes()?"QDeclarativeText":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.4 and 1.0");
QTest::newRow("installed import re-overrides 2") <<
"import com.nokia.installedtest 1.4\n"
"import com.nokia.installedtest 1.0\n"
"import com.nokia.installedtest 1.4\n"
"import com.nokia.installedtest 1.0\n"
"InstalledTest {}"
- << "QDeclarativeRectangle"
- << "";
+ << (!qmlCheckTypes()?"QDeclarativeRectangle":"")
+ << (!qmlCheckTypes()?"":"InstalledTest is ambiguous. Found in lib/com/nokia/installedtest in version 1.0 and 1.4");
QTest::newRow("installed import versus builtin 1") <<
"import com.nokia.installedtest 1.5\n"
"import Qt 4.7\n"
"Rectangle {}"
- << "QDeclarativeRectangle"
- << "";
+ << (!qmlCheckTypes()?"QDeclarativeRectangle":"")
+ << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in Qt and in lib/com/nokia/installedtest");
QTest::newRow("installed import versus builtin 2") <<
"import Qt 4.7\n"
"import com.nokia.installedtest 1.5\n"
"Rectangle {}"
- << "QDeclarativeText"
- << "";
+ << (!qmlCheckTypes()?"QDeclarativeText":"")
+ << (!qmlCheckTypes()?"":"Rectangle is ambiguous. Found in lib/com/nokia/installedtest and in Qt");
QTest::newRow("namespaces cannot be overridden by types 1") <<
"import Qt 4.7 as Rectangle\n"
"import com.nokia.installedtest 1.5\n"
@@ -1537,8 +1547,8 @@ void tst_qdeclarativelanguage::importsOrder_data()
QTest::newRow("local last 2") <<
"import com.nokia.installedtest 1.0\n"
"LocalLast {}"
- << "QDeclarativeRectangle"
- << ""; // i.e. from com.nokia.installedtest, not data/LocalLast.qml
+ << (!qmlCheckTypes()?"QDeclarativeRectangle":"")// i.e. from com.nokia.installedtest, not data/LocalLast.qml
+ << (!qmlCheckTypes()?"":"LocalLast is ambiguous. Found in lib/com/nokia/installedtest and in local directory");
}
void tst_qdeclarativelanguage::importsOrder()
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index cab4d52..22eb734 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -571,6 +571,7 @@ void tst_QDeclarativeListView::removed(bool animated)
// Remove items not visible
model.removeItem(18);
+ qApp->processEvents();
// Confirm items positioned correctly
itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
@@ -586,6 +587,7 @@ void tst_QDeclarativeListView::removed(bool animated)
listview->setCurrentIndex(10);
model.removeItem(1); // post: top item will be at 40
+ qApp->processEvents();
// Confirm items positioned correctly
for (int i = 2; i < 18; ++i) {
diff --git a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml
index 59a15929..7f48639 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml
@@ -16,4 +16,14 @@ QtObject {
property string test8: Qt.formatDateTime(dateTime1)
property string test9: Qt.formatDateTime(dateTime1, Qt.DefaultLocaleLongDate)
property string test10: Qt.formatDateTime(dateTime1, "M/d/yy H:m:s a")
+
+ // Error cases
+ property string test11: Qt.formatDate()
+ property string test12: Qt.formatDate(new Date, new Object)
+
+ property string test13: Qt.formatTime()
+ property string test14: Qt.formatTime(new Date, new Object)
+
+ property string test15: Qt.formatDateTime()
+ property string test16: Qt.formatDateTime(new Date, new Object)
}
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
index f5d5926..7cbd8db 100644
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -398,6 +398,21 @@ void tst_qdeclarativeqt::consoleLog()
void tst_qdeclarativeqt::formatting()
{
QDeclarativeComponent component(&engine, TEST_FILE("formatting.qml"));
+
+ QString warning1 = component.url().toString() + ":22: Error: Qt.formatDate(): Invalid date format";
+ QString warning2 = component.url().toString() + ":21: Error: Qt.formatDate(): Invalid arguments";
+ QString warning3 = component.url().toString() + ":28: Error: Qt.formatDateTime(): Invalid datetime format";
+ QString warning4 = component.url().toString() + ":27: Error: Qt.formatDateTime(): Invalid arguments";
+ QString warning5 = component.url().toString() + ":25: Error: Qt.formatTime(): Invalid time format";
+ QString warning6 = component.url().toString() + ":24: Error: Qt.formatTime(): Invalid arguments";
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning5));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning6));
+
QObject *object = component.create();
QVERIFY(object != 0);
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index fcd7527..83ebe6c 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -644,21 +644,38 @@ void tst_qdeclarativetextinput::echoMode()
QVERIFY(input != 0);
QTRY_VERIFY(input->hasFocus() == true);
QString initial = input->text();
+ Qt::InputMethodHints ref;
QCOMPARE(initial, QLatin1String("ABCDefgh"));
QCOMPARE(input->echoMode(), QDeclarativeTextInput::Normal);
QCOMPARE(input->displayText(), input->text());
+ //Normal
+ ref &= ~Qt::ImhHiddenText;
+ ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ QCOMPARE(input->inputMethodHints(), ref);
input->setEchoMode(QDeclarativeTextInput::NoEcho);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String(""));
QCOMPARE(input->passwordCharacter(), QLatin1String("*"));
+ //NoEcho
+ ref |= Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ QCOMPARE(input->inputMethodHints(), ref);
input->setEchoMode(QDeclarativeTextInput::Password);
+ //Password
+ ref |= Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String("********"));
+ QCOMPARE(input->inputMethodHints(), ref);
input->setPasswordCharacter(QChar('Q'));
QCOMPARE(input->passwordCharacter(), QLatin1String("Q"));
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
input->setEchoMode(QDeclarativeTextInput::PasswordEchoOnEdit);
+ //PasswordEchoOnEdit
+ ref &= ~Qt::ImhHiddenText;
+ ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ QCOMPARE(input->inputMethodHints(), ref);
QCOMPARE(input->text(), initial);
QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ"));
QTest::keyPress(canvas, Qt::Key_A);//Clearing previous entry is part of PasswordEchoOnEdit
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index e2f7f18..055ae80 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -63,6 +63,7 @@
#include <QGraphicsEffect>
#include <QInputContext>
#include <QPushButton>
+#include <QLineEdit>
#include "../../shared/util.h"
@@ -445,6 +446,7 @@ private slots:
void QT_2653_fullUpdateDiscardingOpacityUpdate();
void QT_2649_focusScope();
void sortItemsWhileAdding();
+ void doNotMarkFullUpdateIfNotInScene();
private:
QList<QGraphicsItem *> paintedItems;
@@ -945,8 +947,52 @@ class ImhTester : public QGraphicsItem
void tst_QGraphicsItem::inputMethodHints()
{
- ImhTester item;
- QCOMPARE(item.inputMethodHints(), Qt::ImhNone);
+ ImhTester *item = new ImhTester;
+ item->setFlag(QGraphicsItem::ItemAcceptsInputMethod, true);
+ item->setFlag(QGraphicsItem::ItemIsFocusable, true);
+ QCOMPARE(item->inputMethodHints(), Qt::ImhNone);
+ ImhTester *item2 = new ImhTester;
+ item2->setFlag(QGraphicsItem::ItemAcceptsInputMethod, true);
+ item2->setFlag(QGraphicsItem::ItemIsFocusable, true);
+ Qt::InputMethodHints imHints = item2->inputMethodHints();
+ imHints |= Qt::ImhHiddenText;
+ item2->setInputMethodHints(imHints);
+ QGraphicsScene scene;
+ scene.addItem(item);
+ scene.addItem(item2);
+ QGraphicsView view(&scene);
+ QApplication::setActiveWindow(&view);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ item->setFocus();
+ QTRY_VERIFY(item->hasFocus());
+ QCOMPARE(view.inputMethodHints(), item->inputMethodHints());
+ item2->setFocus();
+ QTRY_VERIFY(item2->hasFocus());
+ QCOMPARE(view.inputMethodHints(), item2->inputMethodHints());
+ item->setFlag(QGraphicsItem::ItemAcceptsInputMethod, false);
+ item->setFocus();
+ QTRY_VERIFY(item->hasFocus());
+ //Focus has changed but the new item doesn't accept input method, no hints.
+ QCOMPARE(view.inputMethodHints(), 0);
+ item2->setFocus();
+ QTRY_VERIFY(item2->hasFocus());
+ QCOMPARE(view.inputMethodHints(), item2->inputMethodHints());
+ imHints = item2->inputMethodHints();
+ imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText);
+ item2->setInputMethodHints(imHints);
+ QCOMPARE(view.inputMethodHints(), item2->inputMethodHints());
+ QGraphicsProxyWidget *widget = new QGraphicsProxyWidget;
+ QLineEdit *edit = new QLineEdit;
+ edit->setEchoMode(QLineEdit::Password);
+ scene.addItem(widget);
+ widget->setFocus();
+ QTRY_VERIFY(widget->hasFocus());
+ //No widget on the proxy, so no hints
+ QCOMPARE(view.inputMethodHints(), 0);
+ widget->setWidget(edit);
+ //View should match with the line edit
+ QCOMPARE(view.inputMethodHints(), edit->inputMethodHints());
}
void tst_QGraphicsItem::toolTip()
@@ -10055,6 +10101,9 @@ void tst_QGraphicsItem::updateMicroFocus()
QApplication::setActiveWindow(&parent);
QTest::qWaitForWindowShown(&parent);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&parent));
+ //We reset the number of updates that happened previously (initialisation)
+ ic.nbUpdates = 0;
+ ic2.nbUpdates = 0;
input.doUpdateMicroFocus();
QApplication::processEvents();
QTRY_COMPARE(ic.nbUpdates, 1);
@@ -10383,5 +10432,51 @@ void tst_QGraphicsItem::sortItemsWhileAdding()
grandParent.setParentItem(&grandGrandParent);
}
+void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene()
+{
+ struct Item : public QGraphicsTextItem
+ {
+ int painted;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *opt, QWidget *wid)
+ {
+ painted++;
+ QGraphicsTextItem::paint(painter, opt, wid);
+ }
+ };
+ QGraphicsScene scene;
+ MyGraphicsView view(&scene);
+ Item *item = new Item;
+ item->painted = 0;
+ item->setPlainText("Grandparent");
+ Item *item2 = new Item;
+ item2->setPlainText("parent");
+ item2->painted = 0;
+ Item *item3 = new Item;
+ item3->setPlainText("child");
+ item3->painted = 0;
+ QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect;
+ effect->setOpacity(0.5);
+ item2->setGraphicsEffect(effect);
+ item3->setParentItem(item2);
+ item2->setParentItem(item);
+ scene.addItem(item);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(view.repaints, 1);
+ QTRY_COMPARE(item->painted, 1);
+ QTRY_COMPARE(item2->painted, 1);
+ QTRY_COMPARE(item3->painted, 1);
+ item2->update();
+ QApplication::processEvents();
+ QTRY_COMPARE(item->painted, 2);
+ QTRY_COMPARE(item2->painted, 2);
+ QTRY_COMPARE(item3->painted, 2);
+ item2->update();
+ QApplication::processEvents();
+ QTRY_COMPARE(item->painted, 3);
+ QTRY_COMPARE(item2->painted, 3);
+ QTRY_COMPARE(item3->painted, 3);
+}
+
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"
diff --git a/tools/qml/loggerwidget.cpp b/tools/qml/loggerwidget.cpp
index 015d1b0..9eca4a6 100644
--- a/tools/qml/loggerwidget.cpp
+++ b/tools/qml/loggerwidget.cpp
@@ -50,7 +50,7 @@ LoggerWidget::LoggerWidget(QWidget *parent) :
m_keepClosed(false)
{
setAttribute(Qt::WA_QuitOnClose, false);
- setWindowTitle(tr("Qt Declarative UI Viewer - Logger"));
+ setWindowTitle(tr("Logger"));
}
void LoggerWidget::append(const QString &msg)
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index cba5650..9ccc3d2 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -198,7 +198,7 @@ int main(int argc, char ** argv)
#endif
QApplication app(argc, argv);
- app.setApplicationName("viewer");
+ app.setApplicationName("QtQmlRuntime");
app.setOrganizationName("Nokia");
app.setOrganizationDomain("nokia.com");
@@ -281,7 +281,7 @@ int main(int argc, char ** argv)
if (lastArg) usage();
app.setStartDragDistance(QString(argv[++i]).toInt());
} else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) {
- qWarning("Qt Declarative UI Viewer version %s", QT_VERSION_STR);
+ qWarning("Qt Qml Runtime version %s", QT_VERSION_STR);
exit(0);
} else if (arg == "-translation") {
if (lastArg) usage();
@@ -389,8 +389,6 @@ int main(int argc, char ** argv)
usage();
}
- viewer->addLibraryPath(QCoreApplication::applicationDirPath());
-
foreach (QString lib, imports)
viewer->addLibraryPath(lib);
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index 87a4d21..008f163 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -341,14 +341,14 @@ private:
data.append("\n");
}
}
- QSettings settings("Nokia", "QtQmlViewer");
+ QSettings settings;
settings.setValue("Cookies",data);
}
void load()
{
QMutexLocker lock(&mutex);
- QSettings settings("Nokia", "QtQmlViewer");
+ QSettings settings;
QByteArray data = settings.value("Cookies").toByteArray();
setAllCookies(QNetworkCookie::parseCookies(data));
}
@@ -466,6 +466,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
, m_scriptOptions(0), tester(0), useQmlFileBrowser(true)
{
QDeclarativeViewer::registerTypes();
+ setWindowTitle(tr("Qt Qml Runtime"));
devicemode = false;
skin = 0;
@@ -537,6 +538,14 @@ QDeclarativeViewer::~QDeclarativeViewer()
delete namFactory;
}
+int QDeclarativeViewer::menuBarHeight() const
+{
+ if (!(windowFlags() & Qt::FramelessWindowHint))
+ return menuBar()->height();
+ else
+ return 0; // don't create menu
+}
+
QMenuBar *QDeclarativeViewer::menuBar() const
{
#if !defined(Q_OS_SYMBIAN)
@@ -916,7 +925,7 @@ void QDeclarativeViewer::statusChanged()
initialSize = canvas->sizeHint();
if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) {
QSize newWindowSize = initialSize;
- newWindowSize.setHeight(newWindowSize.height()+menuBar()->height());
+ newWindowSize.setHeight(newWindowSize.height()+menuBarHeight());
updateSizeHints();
resize(newWindowSize);
}
@@ -938,7 +947,7 @@ bool QDeclarativeViewer::open(const QString& file_or_url)
url = QUrl::fromLocalFile(fi.absoluteFilePath());
else
url = QUrl(file_or_url);
- setWindowTitle(tr("%1 - Qt Declarative UI Viewer").arg(file_or_url));
+ setWindowTitle(tr("%1 - Qt Qml Runtime").arg(file_or_url));
if (!m_script.isEmpty())
tester = new QDeclarativeTester(m_script, m_scriptOptions, canvas);
@@ -1065,8 +1074,10 @@ void QDeclarativeViewer::setSkin(const QString& skinDirOrName)
} else if (skin) {
skin = 0;
clearMask();
- menuBar()->clear();
- createMenu(menuBar(),0);
+ if ((windowFlags() & Qt::FramelessWindowHint)) {
+ menuBar()->clear();
+ createMenu(menuBar(),0);
+ }
canvas->setParent(this, Qt::SubWindow);
setParent(0,windowFlags()); // recreate
mb->show();
@@ -1079,7 +1090,7 @@ void QDeclarativeViewer::setSkin(const QString& skinDirOrName)
canvas->setFixedSize(initialSize);
}
QSize newWindowSize = canvas->size();
- newWindowSize.setHeight(newWindowSize.height()+menuBar()->height());
+ newWindowSize.setHeight(newWindowSize.height()+menuBarHeight());
resize(newWindowSize);
show();
}
@@ -1401,9 +1412,8 @@ void QDeclarativeViewer::updateSizeHints()
{
if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) {
QSize newWindowSize = canvas->sizeHint();
- if (!skin) {
- newWindowSize.setHeight(newWindowSize.height()+menuBar()->height());
- }
+ if (!skin)
+ newWindowSize.setHeight(newWindowSize.height()+menuBarHeight());
if (!isFullScreen() && !isMaximized()) {
resize(newWindowSize);
setFixedSize(newWindowSize);
@@ -1430,7 +1440,7 @@ void QDeclarativeViewer::registerTypes()
if (!registered) {
// registering only for exposing the DeviceOrientation::Orientation enum
- qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,6,"Orientation","");
+ qmlRegisterUncreatableType<DeviceOrientation>("Qt",4,7,"Orientation","");
registered = true;
}
}
diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h
index a00a703..2a0a07d 100644
--- a/tools/qml/qmlruntime.h
+++ b/tools/qml/qmlruntime.h
@@ -146,6 +146,7 @@ private slots:
private:
QString getVideoFileName();
+ int menuBarHeight() const;
PreviewDeviceSkin *skin;
QSize skinscreensize;