summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/declarative/flickr/mobile/TitleBar.qml1
-rw-r--r--demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml4
-rw-r--r--demos/declarative/twitter/TwitterCore/AuthView.qml2
-rw-r--r--demos/declarative/twitter/TwitterCore/HomeTitleBar.qml1
-rw-r--r--demos/declarative/twitter/TwitterCore/TitleBar.qml1
-rw-r--r--doc/src/declarative/advtutorial.qdoc24
-rw-r--r--doc/src/declarative/animation.qdoc4
-rw-r--r--doc/src/declarative/basictypes.qdoc23
-rw-r--r--doc/src/declarative/declarativeui.qdoc10
-rw-r--r--doc/src/declarative/examples.qdoc14
-rw-r--r--doc/src/declarative/extending-tutorial.qdoc356
-rw-r--r--doc/src/declarative/extending.qdoc43
-rw-r--r--doc/src/declarative/focus.qdoc2
-rw-r--r--doc/src/declarative/modules.qdoc4
-rw-r--r--doc/src/declarative/network.qdoc4
-rw-r--r--doc/src/declarative/pics/extending-tutorial-chapter1.pngbin0 -> 6687 bytes
-rw-r--r--doc/src/declarative/pics/extending-tutorial-chapter2.pngbin0 -> 7318 bytes
-rw-r--r--doc/src/declarative/pics/extending-tutorial-chapter3.pngbin0 -> 8145 bytes
-rw-r--r--doc/src/declarative/pics/extending-tutorial-chapter5.pngbin0 -> 5557 bytes
-rw-r--r--doc/src/declarative/qdeclarativedebugging.qdoc8
-rw-r--r--doc/src/declarative/qdeclarativei18n.qdoc8
-rw-r--r--doc/src/declarative/qdeclarativeintro.qdoc4
-rw-r--r--doc/src/declarative/qml-intro.qdoc10
-rw-r--r--doc/src/declarative/qmlviewer.qdoc4
-rw-r--r--doc/src/declarative/tutorial.qdoc4
-rw-r--r--examples/declarative/cppextensions/plugins/plugin.cpp6
-rw-r--r--examples/declarative/cppextensions/plugins/plugins.qml3
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/app.qml18
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro4
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/main.cpp4
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/musician.cpp66
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/musician.h68
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/app.qml24
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro4
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/main.cpp4
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/musician.cpp74
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/musician.h81
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/app.qml42
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro4
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/main.cpp4
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp76
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/musician.h82
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml18
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro8
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp56
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h63
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp8
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp67
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h78
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/app.qml53
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro20
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp56
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/instrument.h61
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp67
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/musician.h68
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp54
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h55
-rw-r--r--examples/declarative/tutorials/extending/chapter5-plugins/qmldir1
-rw-r--r--examples/declarative/tutorials/extending/extending.pro3
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/samegame.qml2
-rw-r--r--examples/declarative/ui-components/tabwidget/TabWidget.qml7
-rw-r--r--src/declarative/debugger/qdeclarativedebugtrace.cpp12
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp16
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp26
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp30
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem_p.h16
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp3
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp20
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp7
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp3
-rw-r--r--src/declarative/graphicsitems/qdeclarativepainteditem.cpp16
-rw-r--r--src/declarative/graphicsitems/qdeclarativepath.cpp7
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater.cpp38
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp20
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p_p.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp5
-rw-r--r--src/declarative/graphicsitems/qdeclarativetranslate.cpp2
-rw-r--r--src/declarative/qml/parser/qdeclarativejslexer.cpp10
-rw-r--r--src/declarative/qml/qdeclarative.h14
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp145
-rw-r--r--src/declarative/qml/qdeclarativebinding_p_p.h28
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp6
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp65
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp2
-rw-r--r--src/declarative/qml/qdeclarativecontext_p.h1
-rw-r--r--src/declarative/qml/qdeclarativedom.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp94
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp30
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp502
-rw-r--r--src/declarative/qml/qdeclarativeexpression_p.h83
-rw-r--r--src/declarative/qml/qdeclarativeextensionplugin.cpp81
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp6
-rw-r--r--src/declarative/qml/qdeclarativelist.cpp2
-rw-r--r--src/declarative/qml/qdeclarativemetatype.cpp27
-rw-r--r--src/declarative/qml/qdeclarativemetatype_p.h8
-rw-r--r--src/declarative/qml/qdeclarativeprivate.h30
-rw-r--r--src/declarative/qml/qdeclarativescriptparser.cpp97
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp2
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp271
-rw-r--r--src/declarative/util/qdeclarativeanimation_p.h6
-rw-r--r--src/declarative/util/qdeclarativeanimation_p_p.h2
-rw-r--r--src/declarative/util/qdeclarativebehavior.cpp45
-rw-r--r--src/declarative/util/qdeclarativebehavior_p.h1
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp2
-rw-r--r--src/declarative/util/qdeclarativepackage.cpp4
-rw-r--r--src/declarative/util/qdeclarativepixmapcache.cpp60
-rw-r--r--src/declarative/util/qdeclarativesmoothedanimation.cpp31
-rw-r--r--src/declarative/util/qdeclarativespringanimation.cpp39
-rw-r--r--src/declarative/util/qdeclarativestyledtext.cpp6
-rw-r--r--src/declarative/util/qdeclarativetransition.cpp4
-rw-r--r--src/declarative/util/qdeclarativeview.cpp45
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp8
-rw-r--r--src/imports/particles/qdeclarativeparticles.cpp2
-rw-r--r--src/s60installs/bwins/QtDeclarativeu.def26
-rw-r--r--src/s60installs/eabi/QtDeclarativeu.def25
-rw-r--r--tests/auto/declarative/declarative.pro3
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp46
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/heart-arm.pngbin0 -> 12596 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/heart200-arm.pngbin0 -> 8063 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp18
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/importFile.qml3
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp3
-rw-r--r--tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow1.qml3
-rw-r--r--tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow2.qml5
-rw-r--r--tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow3.qml6
-rw-r--r--tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowDisabled.qml13
-rw-r--r--tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowValueSource.qml13
-rw-r--r--tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro16
-rw-r--r--tests/auto/declarative/qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp194
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments.qml6
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments.qml2
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp64
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp72
-rw-r--r--tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp16
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp36
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp2
-rw-r--r--tests/auto/declarative/qmlvisual/focusscope/test.qml8
-rw-r--r--tests/auto/declarative/qmlvisual/focusscope/test2.qml10
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml20
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml27
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml26
-rw-r--r--tools/qml/main.cpp17
155 files changed, 1912 insertions, 2619 deletions
diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml
index c7e1a53..335c315 100644
--- a/demos/declarative/flickr/mobile/TitleBar.qml
+++ b/demos/declarative/flickr/mobile/TitleBar.qml
@@ -109,6 +109,7 @@ Item {
Item {
id: returnKey
Keys.onReturnPressed: container.accept()
+ Keys.onEnterPressed: container.accept()
Keys.onEscapePressed: titleBar.state = ""
}
}
diff --git a/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml
index 568666e..decc0fe 100644
--- a/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml
+++ b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml
@@ -64,6 +64,10 @@ Item {
container.labelChanged(textInput.text)
container.focus = true
}
+ Keys.onEnterPressed: {
+ container.labelChanged(textInput.text)
+ container.focus = true
+ }
Keys.onEscapePressed: {
textInput.text = container.label
container.focus = true
diff --git a/demos/declarative/twitter/TwitterCore/AuthView.qml b/demos/declarative/twitter/TwitterCore/AuthView.qml
index 4f75777..0d05deb 100644
--- a/demos/declarative/twitter/TwitterCore/AuthView.qml
+++ b/demos/declarative/twitter/TwitterCore/AuthView.qml
@@ -115,6 +115,7 @@ Item {
KeyNavigation.tab: guest
KeyNavigation.backtab: passIn
Keys.onReturnPressed: login.doLogin();
+ Keys.onEnterPressed: login.doLogin();
Keys.onSelectPressed: login.doLogin();
Keys.onSpacePressed: login.doLogin();
onClicked: login.doLogin();
@@ -135,6 +136,7 @@ Item {
KeyNavigation.tab: nameIn
KeyNavigation.backtab: login
Keys.onReturnPressed: guest.doGuest();
+ Keys.onEnterPressed: guest.doGuest();
Keys.onSelectPressed: guest.doGuest();
Keys.onSpacePressed: guest.doGuest();
onClicked: guest.doGuest();
diff --git a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml
index b26f7b3..56f31b1 100644
--- a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml
+++ b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml
@@ -136,6 +136,7 @@ Item {
Item {
id: returnKey
Keys.onReturnPressed: container.accept()
+ Keys.onEnterPressed: container.accept()
Keys.onEscapePressed: titleBar.state = ""
}
}
diff --git a/demos/declarative/twitter/TwitterCore/TitleBar.qml b/demos/declarative/twitter/TwitterCore/TitleBar.qml
index 6cd0a50..558bc18 100644
--- a/demos/declarative/twitter/TwitterCore/TitleBar.qml
+++ b/demos/declarative/twitter/TwitterCore/TitleBar.qml
@@ -98,6 +98,7 @@ Item {
Item {
id: returnKey
Keys.onReturnPressed: container.accept()
+ Keys.onEnterPressed: container.accept()
Keys.onEscapePressed: titleBar.state = ""
}
}
diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc
index afedb44..1341bbb 100644
--- a/doc/src/declarative/advtutorial.qdoc
+++ b/doc/src/declarative/advtutorial.qdoc
@@ -164,14 +164,22 @@ The \c createBlock() function creates a block from the \c Block.qml file
and moves the new block to its position on the game canvas. This involves several steps:
\list
-\o \l {QML:Qt::createComponent()}{Qt.createComponent()} is called to generate an element from \c Block.qml.
- If the component is ready, we can call \c createObject() to create an instance of the \c Block item.
-\o If \c createObject() returned null (i.e. if there was an error while
- loading the object), print the error information.
-\o Place the block in its position on the board and set its width and height.
- Also, store it in the blocks array for future reference.
-\o Finally, print error information to the console if the component could not be
- loaded for some reason (for example, if the file is missing).
+
+\o \l {QML:Qt::createComponent()}{Qt.createComponent()} is called to
+ generate an element from \c Block.qml. If the component is ready,
+ we can call \c createObject() to create an instance of the \c Block
+ item.
+
+\o If \c createObject() returned null (i.e. if there was an error
+ while loading the object), print the error information.
+
+\o Place the block in its position on the board and set its width and
+ height. Also, store it in the blocks array for future reference.
+
+\o Finally, print error information to the console if the component
+ could not be loaded for some reason (for example, if the file is
+ missing).
+
\endlist
diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc
index c5333df..401cf16 100644
--- a/doc/src/declarative/animation.qdoc
+++ b/doc/src/declarative/animation.qdoc
@@ -67,7 +67,9 @@ A property animation can also be specified as a resource that is manipulated fro
\snippet doc/src/snippets/declarative/animation.qml property-anim-3
As can be seen, when an animation is used like this (as opposed to as a value source) you will need
-to explicitly set the \c target and \c property to animate.
+to explicitly set the \c target and \c property to animate. This also the only case where
+an animation needs to be started explictly by either setting the \c running property to
+true or calling the \c start() method.
Animations can be joined into a group using SequentialAnimation and ParallelAnimation.
diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc
index 6aa1808..e327d4a 100644
--- a/doc/src/declarative/basictypes.qdoc
+++ b/doc/src/declarative/basictypes.qdoc
@@ -403,3 +403,26 @@
\sa {QML Basic Types}
*/
+
+/*!
+ \qmlbasictype enumeration
+ \ingroup qmlbasictypes
+
+ \brief An enumeration type consists of a set of named values.
+
+ An enumeration type consists of a set of named values.
+
+ An enumeration value may be specifed as either a string:
+ \qml
+ Text { horizontalAlignment: "AlignRight" }
+ \endqml
+
+ or as \c {<Element>.<value>}:
+ \qml
+ Text { horizontalAlignment: Text.AlignRight }
+ \endqml
+
+ The second form is preferred.
+
+ \sa {QML Basic Types}
+*/
diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc
index e9a039b..217e372 100644
--- a/doc/src/declarative/declarativeui.qdoc
+++ b/doc/src/declarative/declarativeui.qdoc
@@ -76,15 +76,15 @@ application or to build completely new applications. QML is fully \l
\list
\o \l {QML Documents}
\o \l {Property Binding}
-\o \l {Integrating JavaScript}
-\o \l {QML Scope}
\o \l {Network Transparency}
+\o \l {QML Scope}
+\o \l {Integrating JavaScript}
\o \l {Data Models}
\o \l {anchor-layout.html}{Anchor-based Layout}
\o \l {qdeclarativestates.html}{States}
\o \l {qdeclarativeanimation.html}{Animation}
-\o \l {qdeclarativemodules.html}{Modules}
\o \l {qdeclarativefocus.html}{Keyboard Focus}
+\o \l {qdeclarativemodules.html}{Modules}
\o \l {Extending types from QML}
\o \l {qdeclarativedynamicobjects.html}{Dynamic Object Creation}
\o \l {qmlruntime.html}{The Qt Declarative Runtime}
@@ -92,10 +92,10 @@ application or to build completely new applications. QML is fully \l
\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}
+\o \l {Tutorial: Writing QML extensions with C++}
+\o \l {Extending QML in C++}
\endlist
\section1 Reference
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc
index 587cdf2..39da323 100644
--- a/doc/src/declarative/examples.qdoc
+++ b/doc/src/declarative/examples.qdoc
@@ -36,11 +36,18 @@ Qt includes a set of examples and demos that show how to use various aspects
of QML. The examples are small demonstrations of particular QML components,
while the demos contain more complete and functional applications.
-To run the examples and demos, you can use Qt Creator or the included \l {Qt Declarative UI Runtime}{qmlviewer}
-command-line application. For example, from your build directory, run:
+To run the examples and demos, open them in Qt Creator or use the included
+\l {QML Viewer} tool. The \l {QML Viewer} can be run from the command line:
\code
- bin/qmlviewer $QTDIR/demos/declarative/samegame/samegame.qml
+ qmlviewer $QTDIR/demos/declarative/samegame/samegame.qml
+\endcode
+
+On Mac OS X, you can run the included "QMLViewer" application from the
+Finder, or use the command line:
+
+\code
+ QMLViewer.app/Contents/MacOS/QMLViewer $QTDIR/demos/declarative/samegame/samegame.qml
\endcode
@@ -168,6 +175,7 @@ The examples can be found in Qt's \c examples/declarative directory.
\list
\o \l{declarative/modelviews/gridview}{GridView}
\o \l{declarative/modelviews/listview}{ListView}
+\o \l{declarative/modelviews/pathview}{PathView}
\o \l{declarative/modelviews/package}{Package}
\o \l{declarative/modelviews/parallax}{Parallax}
\o \l{declarative/modelviews/visualitemmodel}{VisualItemModel}
diff --git a/doc/src/declarative/extending-tutorial.qdoc b/doc/src/declarative/extending-tutorial.qdoc
index 0cb3a7d..bc849b0 100644
--- a/doc/src/declarative/extending-tutorial.qdoc
+++ b/doc/src/declarative/extending-tutorial.qdoc
@@ -48,8 +48,9 @@ Tutorial chapters:
\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}
+\o \l{declarative/tutorials/extending/chapter5-listproperties}{Using List Property Types}
+\o \l{declarative/tutorials/extending/chapter6-plugins}{Writing an Extension Plugin}
+\o \l{qml-extending-tutorial7.html}{In Summary}
\endlist
*/
@@ -59,66 +60,99 @@ Tutorial chapters:
\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 common task when extending QML is to provide a new QML type that supports some
+ custom functionality beyond what is provided by the built-in \l {QML Elements}.
+For example, this could be done to implement particular data models, or provide
+elements with custom painting and drawing capabilities, or access system features
+like network programming that are not accessible through built-in QML features.
+
+In this tutorial, we will show how to use the C++ classes in the QtDeclarative
+module to extend QML. The end result will be a simple Pie Chart display implemented by
+several custom QML types connected together through QML features like bindings and
+signals, and made available to the QML runtime through a plugin.
+
+To begin with, let's create a new QML type called "PieChart" that has two properties: a name
+and a color. We will make it available in a \l {Modules}{module} called "Charts", with
a module version of 1.0.
-We want this \c Musician type to be usable from QML like this:
+
+We want this \c PieChart type to be usable from QML like this:
\code
- import Music 1.0
+ import Charts 1.0
- Musician {
- name: "Reddy the Rocker"
- instrument: "Guitar"
+ PieChart {
+ width: 100; height: 100
+ name: "A simple pie chart"
+ color: "red"
}
\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},
+To do this, we need a C++ class that encapsulates this \c PieChart type and its two
+properties. Since QML makes extensive use of 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
+\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:
+Here is our \c PieChart class, defined in \c piechart.h:
-\snippet declarative/tutorials/extending/chapter1-basics/musician.h 0
+\snippet declarative/tutorials/extending/chapter1-basics/piechart.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.
+The class inherits from QDeclarativeItem because we want to override
+QDeclarativeItem::paint() in order to draw. If the class just represented some
+data type and was not an item that actually needed to be displayed, it could simply inherit
+from QObject. Or, if we want to extend the functionality of an existing QObject-based
+class, it could inherit from that class instead.
-Our QML file, \c app.qml, creates a \c Musician item and display the musician's details
+The \c PieChart class defines the two properties, \c name and \c color, with the Q_PROPERTY macro,
+and overrides QDeclarativeItem::paint(). The class implementation in \c piechart.cpp
+simply sets and returns the \c m_name and \c m_color values as appropriate, and
+implements \c paint() to draw a simple pie chart. It also turns off the
+QGraphicsItem::ItemHasNoContents flag to enable painting:
+
+\snippet declarative/tutorials/extending/chapter1-basics/piechart.cpp 0
+\dots 0
+\snippet declarative/tutorials/extending/chapter1-basics/piechart.cpp 1
+
+Now that we have defined the \c PieChart type, we will use it from QML. The \c app.qml
+file creates a \c PieChart item and display the pie chart's details
using a standard QML \l Text item:
\snippet declarative/tutorials/extending/chapter1-basics/app.qml 0
+Notice that although the color is specified as a string in QML, it is automatically
+converted to a QColor object for the PieChart \c color property. Automatic conversions are
+provided for various other \l {QML Basic Types}{basic types}; for example, a string
+like "640x480" can be automatically converted to a QSize value.
+
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
+display \c app.qml. The application must register the \c PieChart 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.
+you don't register the type, \c app.qml won't be able to create a \c PieChart.
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",
+This call to qmlRegisterType() registers the \c PieChart type as a type called "PieChart", in a module named "Charts",
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.
+Now we can build and run the application:
-\example declarative/tutorials/extending/chapter1-basics
+\image extending-tutorial-chapter1.png
+
+Try it yourself with the code in Qt's \c examples/tutorials/extending/chapter1-basics directory.
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.
+This may seem odd if you're used to running QML files with the \l {QML Viewer}.
Later on, we'll show how to create a plugin so that you can run \c app.qml using the
-\c qml tool instead.
+\l {QML Viewer} instead.
*/
@@ -128,39 +162,40 @@ Later on, we'll show how to create a plugin so that you can run \c app.qml using
\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:
+Suppose we want \c PieChart to have a "clearChart()" method that erases the
+chart and then emits a "chartCleared" signal. Our \c app.qml would be able
+to call \c clearChart() and receive \c chartCleared() signals like this:
\snippet declarative/tutorials/extending/chapter2-methods/app.qml 0
-To do this, we add a \c perform() method and a \c performanceEnded() signal
+\image extending-tutorial-chapter2.png
+
+To do this, we add a \c clearChart() method and a \c chartCleared() signal
to our C++ class:
-\snippet declarative/tutorials/extending/chapter2-methods/musician.h 0
+\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 0
\dots
-\snippet declarative/tutorials/extending/chapter2-methods/musician.h 1
+\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 1
\dots
-\snippet declarative/tutorials/extending/chapter2-methods/musician.h 2
+\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 2
\dots
-\snippet declarative/tutorials/extending/chapter2-methods/musician.h 3
+\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 3
-The use of Q_INVOKABLE makes the \c perform() method available to the
+The use of Q_INVOKABLE makes the \c clearChart() 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():
+The \c clearChart() method simply changes the color to Qt::transparent,
+repaints the chart, then emits the \c chartCleared() signal:
-\snippet declarative/tutorials/extending/chapter2-methods/musician.cpp 0
+\snippet declarative/tutorials/extending/chapter2-methods/piechart.cpp 0
-Now when we run the application and click the window, the application outputs:
+Now when we run the application and click the window, the pie chart
+disappears, and the application outputs:
\code
- "Reddy the Rocker" is playing the "Guitar"
- The performance has now ended
+ The chart has been cleared
\endcode
Try out the example yourself with the updated code in Qt's \c examples/tutorials/extending/chapter2-methods directory.
@@ -174,45 +209,49 @@ Try out the example yourself with the updated code in Qt's \c examples/tutorials
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.
+other elements' values when property values are changed.
-Let's enable property bindings for the \c instrument property. That means
+Let's enable property bindings for the \c color property. That means
if we have code like this:
\snippet declarative/tutorials/extending/chapter3-bindings/app.qml 0
-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:
+\image extending-tutorial-chapter3.png
-\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
+The "color: chartA.color" statement binds the \c color value of
+\c chartB to the \c color of \c chartA.
+Whenever \c chartA's \c color value changes, \c chartB's \c color value
+updates to the same value. When the window is clicked, the \c onClicked
+handler in the MouseArea changes the color of \c chartA, thereby changing
+both charts to the color blue.
-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
+It's easy to enable property binding for the \c color property.
+We add a \l{Qt's Property System}{NOTIFY} feature to its Q_PROPERTY() declaration to indicate that a "colorChanged" signal
is emitted whenever the value changes.
-\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 0
+\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 0
\dots
-\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 1
+\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 1
\dots
-\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 2
+\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 2
\dots
-\snippet declarative/tutorials/extending/chapter3-bindings/musician.h 3
+\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 3
-Then, we emit this signal in \c setInstrument():
+Then, we emit this signal in \c setPieSlice():
-\snippet declarative/tutorials/extending/chapter3-bindings/musician.cpp 0
+\snippet declarative/tutorials/extending/chapter3-bindings/piechart.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
+It's important for \c setColor() to check that the color value has actually changed
+before emitting \c colorChanged(). This ensures the signal is not emitted unnecessarily and
also prevents loops when other elements respond to the value change.
+The use of bindings is essential to QML. You should always add NOTIFY
+signals for properties if they are able to be implemented, so that your
+properties can be used in bindings. Properties that cannot be bound cannot be
+automatically updated and cannot be used as flexibly in QML. Also, since
+bindings are invoked so often and relied upon in QML usage, users of your
+custom QML types may see unexpected behavior if bindings are not implemented.
+
*/
/*!
@@ -220,21 +259,35 @@ also prevents loops when other elements respond to the value change.
\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:
+The \c PieChart type currently has a string-type property and a color-type property.
+It could have many other types of properties. For example, it could have an
+enum-type property to store a display mode for each chart:
\code
- class Musician : public QObject
+ // C++
+ class PieChart : public QDeclarativeItem
{
+ Q_ENUMS(DisplayMode)
+ Q_PROPERTY(DisplayMode displayMode READ displayMode WRITE setDisplayMode)
...
- Q_PROPERTY(int age READ age WRITE setAge)
+
public:
- ...
- int age() const;
- void setAge(int age);
+ enum DisplayMode {
+ MultiLevel,
+ Exploded,
+ ThreeDimensional
+ };
+
+ void setDisplayMode(DisplayMode mode);
+ DisplayMode displayMode() const;
...
};
+
+ // QML
+ PieChart {
+ ...
+ displayMode: PieChart.Exploded
+ }
\endcode
We can also use various other property types. QML has built-in support for the following
@@ -257,31 +310,39 @@ types:
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:
+For example, let's replace the use of the \c property with a type called
+"PieSlice" that has a \c color property. Instead of assigning a color,
+we assign an \c PieSlice value which itself contains a \c color:
\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml 0
-Like \c Musician, this new \c Instrument type has to inherit from QObject and declare
+Like \c PieChart, this new \c PieSlice type inherits from QDeclarativeItem and declares
its properties with Q_PROPERTY():
-\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h 0
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h 0
-To use it from \c Musician, we modify the \c instrument property declaration
+To use it in \c PieChart, we modify the \c color property declaration
and associated method signatures:
-\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 0
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 0
\dots
-\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 1
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 1
\dots
-\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 2
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 2
\dots
-\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h 3
+\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 3
+
+There is one thing to be aware of when implementing \c setPieSlice(). The \c PieSlice
+is a visual item, so it must be set as a child of the \c PieChart using
+QDeclarativeItem::setParentItem() so that the \c PieChart knows to paint this child
+item when its contents are drawn:
-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/piechart.cpp 0
+
+
+Like the \c PieChart type, the \c PieSlice type has to be registered
+using qmlRegisterType() to be used from QML. As with \c PieChart, we'll add the
+type to the "Charts" module, version 1.0:
\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp 0
\dots
@@ -293,16 +354,66 @@ Try it out with the code in Qt's \c examples/tutorials/extending/chapter4-custom
*/
+
/*!
-\title Chapter 5: Writing an Extension Plugin
+\title Chapter 5: Using List Property Types
+
+\example declarative/tutorials/extending/chapter5-listproperties
+
+Right now, a \c PieChart can only have one \c PieSlice. Ideally a chart would
+have multiple slices, with different colors and sizes. To do this, we could
+have a \c slices property that accepts a list of \c PieSlice items:
+
+\snippet declarative/tutorials/extending/chapter5-listproperties/app.qml 0
-\example declarative/tutorials/extending/chapter5-plugins
+\image extending-tutorial-chapter5.png
-Currently the \c Musician and \c Instrument types are used by \c app.qml,
+To do this, we replace the \c pieSlice property in \c PieChart with a \c slices property,
+declared as a QDeclarativeListProperty type. The QDeclarativeListProperty class enables the
+creation of list properties in QML extensions. We replace the \c pieSlice()
+function with a \c slices() function that returns a list of slices, and add
+an internal \c append_slice() function (discussed below). We also use a QList to
+store the internal list of slices as \c m_slices:
+
+\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 0
+\dots
+\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 1
+\dots
+\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 2
+
+Although the \c slices property does not have an associated \c WRITE function,
+it is still modifiable because of the way QDeclarativeListProperty works.
+In the \c PieChart implementation, we implement \c PieChart::slices() to
+return a QDeclarativeListProperty value and indicate that the internal
+\c PieChart::append_slice() function is to be called whenever a request is made from QML
+to add items to the list:
+
+\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.cpp 0
+
+The \c append_slice() function simply sets the parent item as before,
+and adds the new item to the \c m_slices list. As you can see, the append function for a
+QDeclarativeListProperty is called with two arguments: the list property, and
+the item that is to be appended.
+
+The \c PieSlice class has also been modified to include \c fromAngle and \c angleSpan
+properties and to draw the slice according to these values. This is a straightforward
+modification if you have read the previous pages in this tutorial, so the code is not shown here.
+
+The complete code can be seen in the updated \c examples/tutorials/extending/chapter5-listproperties directory.
+
+*/
+
+
+/*!
+\title Chapter 6: Writing an Extension Plugin
+
+\example declarative/tutorials/extending/chapter6-plugins
+
+Currently the \c PieChart and \c PieSlice 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
+to the QML engine. This allows \c app.qml to be loaded with the \l {QML Viewer}
+(or some other QML \l{Qt Declarative UI Runtime}{runtime} application) instead of writing a \c main.cpp file and
loading our own C++ application.
To create a plugin library, we need:
@@ -313,45 +424,48 @@ To create a plugin library, we need:
\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
+First, we create a plugin class named \c ChartsPlugin. 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:
+Here is the \c ChartsPlugin definition in \c chartsplugin.h:
-\snippet declarative/tutorials/extending/chapter5-plugins/musicplugin.h 0
+\snippet declarative/tutorials/extending/chapter6-plugins/chartsplugin.h 0
-And its implementation in \c musicplugin.cpp:
+And its implementation in \c chartsplugin.cpp:
-\snippet declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp 0
+\snippet declarative/tutorials/extending/chapter6-plugins/chartsplugin.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
+\quotefile declarative/tutorials/extending/chapter6-plugins/chapter6-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
+Here, we specify that a plugin named "chapter6-plugin" (the name
of the example project) can be found in the "lib" subdirectory:
-\quotefile declarative/tutorials/extending/chapter5-plugins/qmldir
+\quotefile declarative/tutorials/extending/chapter6-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:
+the project and then load the QML file in the \l {QML Viewer}:
\code
- qml app.qml
+ qmlviewer app.qml
\endcode
-Notice the "import Music 1.0" statement has disappeared from \c app.qml. This is
+(On Mac OS X, you can launch the "QMLViewer" application instead.)
+
+Notice the "import Charts 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
+having PieChart.qml and PieSlice.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
+\page qml-extending-tutorial7.html
+\title Chapter 7: In Summary
In this tutorial, we've shown the basic steps for creating a QML extension:
@@ -360,47 +474,33 @@ In this tutorial, we've shown the basic steps for creating a QML extension:
\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 Define list property types using QDeclarativeListProperty
\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:
+QML extensions. For example, we could use \l{Default Property}{default properties} to allow
+slices to be added without using the \c slices property:
\code
- Musician {
- instruments: [
- Instrument { type: "Guitar" }
- Instrument { type: "Drums" }
- Instrument { type: "Keyboard" }
- ]
+ PieChart {
+ PieSlice { ... }
+ PieSlice { ... }
+ PieSlice { ... }
}
\endcode
-Or use \l{Default Property}{default properties} and avoid an
-\c instruments property altogether:
+Or randomly add and remove slices from time to time using \l{Property Value Sources}{property value sources}:
\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 {}
+ PieChart {
+ PieSliceRandomizer on slices {}
}
\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 2fd6fa8..3acfbdf 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -704,10 +704,6 @@ of some of the types. For the remaining types the default values are undefined.
\row \o color \o #000000 (black)
\endtable
-If specified, the optional "default" attribute marks the new property as the
-types default property, overriding any existing default property. Using the
-default attribute twice in the same type block is an error.
-
The following example shows how to declare a new "innerColor" property that
controls the color of the inner rectangle.
@@ -725,6 +721,9 @@ controls the color of the inner rectangle.
}
\endcode
+
+\section3 Property signal handlers
+
Adding a property to an item automatically adds a \e{value-changed}
signal handler to the item. The signal hander is named
\c{on<Property_name>Changed}, with the first letter of the property
@@ -743,6 +742,42 @@ example shows how to output to a text console a new value of property
}
\endcode
+
+\section3 Setting default properties
+
+The optional \c default attribute for a property marks it as the \e {default property}
+for a type. This allows other items to specify the default property's value
+as child elements. For example, the \l Item element's default property is its
+\l{Item::children}{children} property. This allows the children of an \l Item
+to be set like this:
+
+\qml
+Item {
+ Rectangle {}
+ Rectangle {}
+}
+\endqml
+
+If the \l{Item::children}{children} property was not the default property for
+\l Item, its value would have to be set like this instead:
+
+\qml
+Item {
+ children: [
+ Rectangle {}
+ Rectangle {}
+ ]
+}
+\endqml
+
+See the \l{declarative/ui-components/tabwidget}{TabWidget} example for a
+demonstration of using default properties.
+
+Specifying a default property overrides any existing default property (for
+example, any default property inherited from a parent item). Using the
+default attribute twice in the same type block is an error.
+
+
\target qml-property-aliases
\section2 Property aliases
diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc
index 661930f..e3ca963 100644
--- a/doc/src/declarative/focus.qdoc
+++ b/doc/src/declarative/focus.qdoc
@@ -87,7 +87,7 @@ Text {
An \l Item requests focus by setting the \c {Item::focus} property to true.
For very simple cases simply setting the \c {Item::focus} property is sometimes
-sufficient. If we run the following example with the \l {Qt Declarative UI Runtime}{qml} tool, we see that
+sufficient. If we run the following example with the \l {QML Viewer}, we see that
the \c {keyHandler} element has \e {active focus} and pressing the 'A', 'B'
or 'C' keys modifies the text appropriately.
diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc
index 36570da..938222a 100644
--- a/doc/src/declarative/modules.qdoc
+++ b/doc/src/declarative/modules.qdoc
@@ -72,7 +72,7 @@ The second exception is explained in more detail in the section below on Namespa
\section2 The Import Path
Installed modules are searched for on the import path.
-The \c -I option to the \l {Qt Declarative UI Runtime}{qml} runtime adds paths to the import path.
+The \c -I option to the \l {QML Viewer} adds paths to the import path.
From C++, the path is available via \l QDeclarativeEngine::importPathList() and can be prepended to
using \l QDeclarativeEngine::addImportPath().
@@ -129,7 +129,7 @@ to the module.
of the plugin binary, which is platform dependent; e.g. the library MyAppTypes would produce
a libMyAppTypes.so on Linux and MyAppTypes.dll on Windows.
By default the engine searches for the plugin library in the directory containing the \c qmldir
-file. The \c -P option to the \l {Qt Declarative UI Runtime}{qml} runtime adds paths to the
+file. The \c -P option to the \l {QML Viewer} adds paths to the
plugin search path.
From C++, the path is available via \l QDeclarativeEngine::pluginPathList() and can be prepended to
using \l QDeclarativeEngine::addPluginPath().
diff --git a/doc/src/declarative/network.qdoc b/doc/src/declarative/network.qdoc
index b0d19e2..60359de 100644
--- a/doc/src/declarative/network.qdoc
+++ b/doc/src/declarative/network.qdoc
@@ -54,7 +54,7 @@ Network transparency is supported throughout QML, for example:
\o WebViews - the \c url property of WebView (obviously!)
\endlist
-Even QML types themselves can be on the network - if the \l {Qt Declarative UI Runtime}{qml} tool is used to load
+Even QML types themselves can be on the network - if the \l {QML Viewer} is used to load
\tt http://example.com/mystuff/Hello.qml and that content refers to a type "World", the engine
will load \tt http://example.com/mystuff/qmldir and resolve the type just as it would for a local file.
For example if the qmldir file contains the line "World World.qml", it will load
@@ -119,7 +119,7 @@ All network access from QML is managed by a QNetworkAccessManager set on the QDe
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
+For example, the \l {QML Viewer} 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.
diff --git a/doc/src/declarative/pics/extending-tutorial-chapter1.png b/doc/src/declarative/pics/extending-tutorial-chapter1.png
new file mode 100644
index 0000000..9f5836b
--- /dev/null
+++ b/doc/src/declarative/pics/extending-tutorial-chapter1.png
Binary files differ
diff --git a/doc/src/declarative/pics/extending-tutorial-chapter2.png b/doc/src/declarative/pics/extending-tutorial-chapter2.png
new file mode 100644
index 0000000..5c8f222
--- /dev/null
+++ b/doc/src/declarative/pics/extending-tutorial-chapter2.png
Binary files differ
diff --git a/doc/src/declarative/pics/extending-tutorial-chapter3.png b/doc/src/declarative/pics/extending-tutorial-chapter3.png
new file mode 100644
index 0000000..825553f
--- /dev/null
+++ b/doc/src/declarative/pics/extending-tutorial-chapter3.png
Binary files differ
diff --git a/doc/src/declarative/pics/extending-tutorial-chapter5.png b/doc/src/declarative/pics/extending-tutorial-chapter5.png
new file mode 100644
index 0000000..0c2e69e
--- /dev/null
+++ b/doc/src/declarative/pics/extending-tutorial-chapter5.png
Binary files differ
diff --git a/doc/src/declarative/qdeclarativedebugging.qdoc b/doc/src/declarative/qdeclarativedebugging.qdoc
index da6e407..ea21852 100644
--- a/doc/src/declarative/qdeclarativedebugging.qdoc
+++ b/doc/src/declarative/qdeclarativedebugging.qdoc
@@ -47,7 +47,7 @@ Rectangle {
When a transition doesn't look quite right, it can be helpful to view it in slow
motion to see what is happening more clearly. This functionality is supported
-in the \l {Qt Declarative UI Runtime}{qmlviewer} tool: to enable this,
+in the \l {QML Viewer} tool: to enable this,
click on the "Debugging" menu, then "Slow Down Animations".
@@ -64,7 +64,7 @@ import Qt 4.7
Rectangle { width: 100; height: 100 }
\endqml
-If you set \c {QML_IMPORT_TRACE=1} before running the \l {Qt Declarative UI Runtime}{qmlviewer}
+If you set \c {QML_IMPORT_TRACE=1} before running the \l {QML Viewer}
(or your QML C++ application), you will see output similar to this:
\code
@@ -85,11 +85,11 @@ show QML debugging information and options for your application, including
object inspection, property monitoring and application frame-rate analysis.
Creator can be used to debug both local and remote QML applications. To
-enable remote debugging, start the \l {Qt Declarative UI Runtime}{qml} tool
+enable remote debugging, start the \l {QML Viewer}
on the remote device with a debugging port defined, like this:
\code
- QML_DEBUG_SERVER_PORT=3768 qml myqmlfile.qml
+ QML_DEBUG_SERVER_PORT=3768 qmlviewer myqmlfile.qml
\endcode
In Creator, open the project settings pane and set the server and port
diff --git a/doc/src/declarative/qdeclarativei18n.qdoc b/doc/src/declarative/qdeclarativei18n.qdoc
index 40f7919..b6e6c6e 100644
--- a/doc/src/declarative/qdeclarativei18n.qdoc
+++ b/doc/src/declarative/qdeclarativei18n.qdoc
@@ -49,7 +49,7 @@ capabilities are described more fully in:
\o \l {Qt Linguist Manual}
\endlist
-You can test a translation with the \l {Qt Declarative UI Runtime}{qml} tool using the -translation option.
+You can test a translation with the \l {QML Viewer} using the -translation option.
\section1 Example
@@ -61,8 +61,8 @@ hello.qml:
import Qt 4.7
Rectangle {
- width: 200; height: 200
- Text { text: qsTr("Hello"); anchors.centerIn: parent }
+ width: 200; height: 200
+ Text { text: qsTr("Hello"); anchors.centerIn: parent }
}
\endqml
@@ -76,7 +76,7 @@ a translation and create the release file \c hello.qm.
Finally, we can test the translation:
\code
-qml -translation hello.qm hello.qml
+qmlviewer -translation hello.qm hello.qml
\endcode
diff --git a/doc/src/declarative/qdeclarativeintro.qdoc b/doc/src/declarative/qdeclarativeintro.qdoc
index 9126a79..75055d8 100644
--- a/doc/src/declarative/qdeclarativeintro.qdoc
+++ b/doc/src/declarative/qdeclarativeintro.qdoc
@@ -129,7 +129,7 @@ Commenting in QML is similar to JavaScript.
\o Multiline comments start with /* and finish with *\/
\endlist
-\quotefile doc/src/snippets/declarative/comments.qml
+\snippet doc/src/snippets/declarative/comments.qml 0
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
@@ -314,7 +314,7 @@ Item {
\section2 Signal Handlers
-Signal handlers allow actions to be taken in reponse to an event. For instance,
+Signal handlers allow actions to be taken in response to an event. For instance,
the \l MouseArea element has signal handlers to handle mouse press, release
and click:
diff --git a/doc/src/declarative/qml-intro.qdoc b/doc/src/declarative/qml-intro.qdoc
index a98d0f9..fbab001 100644
--- a/doc/src/declarative/qml-intro.qdoc
+++ b/doc/src/declarative/qml-intro.qdoc
@@ -105,9 +105,17 @@ This is a valid QML script. To run it, copy it and save it to a file, say
myexample.qml, and on the command line run the command
\code
- qml myexample.qml
+ qmlviewer myexample.qml
\endcode
+On Mac OS X, open the "QMLViewer" application instead and open the
+\c myexample.qml file, or run it from the command line:
+
+ \code
+ QMLViewer.app/Contents/MacOS/QMLViewer myexample.qml
+ \endcode
+
+
It will create a very boring rectangle in its own window.
diff --git a/doc/src/declarative/qmlviewer.qdoc b/doc/src/declarative/qmlviewer.qdoc
index efff9cc..5efc0ce 100644
--- a/doc/src/declarative/qmlviewer.qdoc
+++ b/doc/src/declarative/qmlviewer.qdoc
@@ -42,7 +42,7 @@ deployment of QML applications. In those cases, the QML runtime should be invoke
from a Qt application instead; see \l {Qt Declarative UI Runtime} for more
information.
-The viewer is located at QTDIR/bin/qmlviewer. To load a \c .qml file
+The viewer is located at \c QTDIR/bin/qmlviewer. To load a \c .qml file
with the viewer, run the viewer and select the file to be opened, or provide the
file path on the command line:
@@ -50,7 +50,7 @@ file path on the command line:
qmlviewer myqmlfile.qml
\endcode
-On Mac OS X, the QML Viewer application is named \c QMLViewer.app instead. You
+On Mac OS X, the QML Viewer application is named "QMLViewer" instead. You
can launch the viewer by opening the QMLViewer application from the Finder, or
from the command line:
diff --git a/doc/src/declarative/tutorial.qdoc b/doc/src/declarative/tutorial.qdoc
index c884486..7a97eb1 100644
--- a/doc/src/declarative/tutorial.qdoc
+++ b/doc/src/declarative/tutorial.qdoc
@@ -101,11 +101,11 @@ The \c font.pointSize and \c font.bold properties are related to fonts and use t
\section2 Viewing the example
-To view what you have created, run the \l{Qt Declarative UI Runtime}{qml} tool (located in the \c bin directory) with your filename as the first argument.
+To view what you have created, run the \l{QML Viewer} tool (located in the \c bin directory) with your filename as the first argument.
For example, to run the provided completed Tutorial 1 example from the install location, you would type:
\code
-bin/qml $QTDIR/examples/declarative/tutorials/helloworld/tutorial1.qml
+bin/qmlviewer $QTDIR/examples/declarative/tutorials/helloworld/tutorial1.qml
\endcode
*/
diff --git a/examples/declarative/cppextensions/plugins/plugin.cpp b/examples/declarative/cppextensions/plugins/plugin.cpp
index 355ca3f..01d5361 100644
--- a/examples/declarative/cppextensions/plugins/plugin.cpp
+++ b/examples/declarative/cppextensions/plugins/plugin.cpp
@@ -96,11 +96,13 @@ private:
QBasicTimer timer;
};
+//![0]
class TimeModel : public QObject
{
Q_OBJECT
Q_PROPERTY(int hour READ hour NOTIFY timeChanged)
Q_PROPERTY(int minute READ minute NOTIFY timeChanged)
+//![0]
public:
TimeModel(QObject *parent=0) : QObject(parent)
@@ -135,6 +137,7 @@ private:
int TimeModel::instances=0;
MinuteTimer *TimeModel::timer=0;
+//![plugin]
class QExampleQmlPlugin : public QDeclarativeExtensionPlugin
{
Q_OBJECT
@@ -145,7 +148,10 @@ public:
qmlRegisterType<TimeModel>(uri, 1, 0, "Time");
}
};
+//![plugin]
#include "plugin.moc"
+//![export]
Q_EXPORT_PLUGIN2(qmlqtimeexampleplugin, QExampleQmlPlugin);
+//![export]
diff --git a/examples/declarative/cppextensions/plugins/plugins.qml b/examples/declarative/cppextensions/plugins/plugins.qml
index 1832017..8d1085c 100644
--- a/examples/declarative/cppextensions/plugins/plugins.qml
+++ b/examples/declarative/cppextensions/plugins/plugins.qml
@@ -37,7 +37,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
+//![0]
import com.nokia.TimeExample 1.0 // import types from the plugin
Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml)
@@ -49,3 +49,4 @@ Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml)
hours: time.hour
minutes: time.minute
}
+//![0]
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/app.qml b/examples/declarative/tutorials/extending/chapter1-basics/app.qml
index 9af155c..ada088d 100644
--- a/examples/declarative/tutorials/extending/chapter1-basics/app.qml
+++ b/examples/declarative/tutorials/extending/chapter1-basics/app.qml
@@ -38,21 +38,23 @@
**
****************************************************************************/
//![0]
-import Music 1.0
+import Charts 1.0
import Qt 4.7
-Rectangle {
+Item {
width: 300; height: 200
- Musician {
- id: aMusician
- name: "Reddy the Rocker"
- instrument: "Guitar"
+ PieChart {
+ id: aPieChart
+ anchors.centerIn: parent
+ width: 100; height: 100
+ name: "A simple pie chart"
+ color: "red"
}
Text {
- anchors.fill: parent
- text: aMusician.name + " plays the " + aMusician.instrument
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: aPieChart.name
}
}
//![0]
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro
index bd05ebe..0f04167 100644
--- a/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro
+++ b/examples/declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro
@@ -1,5 +1,5 @@
QT += declarative
-HEADERS += musician.h
-SOURCES += musician.cpp \
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
main.cpp
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/main.cpp b/examples/declarative/tutorials/extending/chapter1-basics/main.cpp
index 8ef6965..a5dbab3 100644
--- a/examples/declarative/tutorials/extending/chapter1-basics/main.cpp
+++ b/examples/declarative/tutorials/extending/chapter1-basics/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
//![0]
-#include "musician.h"
+#include "piechart.h"
#include <qdeclarative.h>
#include <QDeclarativeView>
#include <QApplication>
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- qmlRegisterType<Musician>("Music", 1, 0, "Musician");
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
QDeclarativeView view;
view.setSource(QUrl::fromLocalFile("app.qml"));
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/musician.cpp b/examples/declarative/tutorials/extending/chapter1-basics/musician.cpp
deleted file mode 100644
index 6c42f31..0000000
--- a/examples/declarative/tutorials/extending/chapter1-basics/musician.cpp
+++ /dev/null
@@ -1,66 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
deleted file mode 100644
index f9a0537..0000000
--- a/examples/declarative/tutorials/extending/chapter1-basics/musician.h
+++ /dev/null
@@ -1,68 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
index 02d33c2..0b55f7c 100644
--- a/examples/declarative/tutorials/extending/chapter2-methods/app.qml
+++ b/examples/declarative/tutorials/extending/chapter2-methods/app.qml
@@ -38,23 +38,29 @@
**
****************************************************************************/
//![0]
-import Music 1.0
+import Charts 1.0
import Qt 4.7
-Rectangle {
- width: 200; height: 200
+Item {
+ width: 300; height: 200
- Musician {
- id: aMusician
- name: "Reddy the Rocker"
- instrument: "Guitar"
+ PieChart {
+ id: aPieChart
+ anchors.centerIn: parent
+ width: 100; height: 100
+ color: "red"
- onPerformanceEnded: console.log("The performance has now ended")
+ onChartCleared: console.log("The chart has been cleared")
}
MouseArea {
anchors.fill: parent
- onClicked: aMusician.perform()
+ onClicked: aPieChart.clearChart()
+ }
+
+ Text {
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: "Click anywhere to clear the chart"
}
}
//![0]
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro
index bd05ebe..0f04167 100644
--- a/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro
+++ b/examples/declarative/tutorials/extending/chapter2-methods/chapter2-methods.pro
@@ -1,5 +1,5 @@
QT += declarative
-HEADERS += musician.h
-SOURCES += musician.cpp \
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
main.cpp
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/main.cpp b/examples/declarative/tutorials/extending/chapter2-methods/main.cpp
index 8ef6965..a5dbab3 100644
--- a/examples/declarative/tutorials/extending/chapter2-methods/main.cpp
+++ b/examples/declarative/tutorials/extending/chapter2-methods/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
//![0]
-#include "musician.h"
+#include "piechart.h"
#include <qdeclarative.h>
#include <QDeclarativeView>
#include <QApplication>
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- qmlRegisterType<Musician>("Music", 1, 0, "Musician");
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
QDeclarativeView view;
view.setSource(QUrl::fromLocalFile("app.qml"));
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/musician.cpp b/examples/declarative/tutorials/extending/chapter2-methods/musician.cpp
deleted file mode 100644
index 0ce0022..0000000
--- a/examples/declarative/tutorials/extending/chapter2-methods/musician.cpp
+++ /dev/null
@@ -1,74 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
deleted file mode 100644
index 86849ba..0000000
--- a/examples/declarative/tutorials/extending/chapter2-methods/musician.h
+++ /dev/null
@@ -1,81 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
index 8bf6ecf..2ff6ae1 100644
--- a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml
@@ -38,35 +38,37 @@
**
****************************************************************************/
//![0]
-import Music 1.0
+import Charts 1.0
import Qt 4.7
-Rectangle {
- width: 200; height: 200
+Item {
+ width: 300; height: 200
- Musician {
- id: reddy
- name: "Reddy the Rocker"
- instrument: "Guitar"
- }
+ Row {
+ anchors.centerIn: parent
+ spacing: 20
+
+ PieChart {
+ id: chartA
+ width: 100; height: 100
+ color: "red"
+ }
- Musician {
- id: craig
- name: "Craig the Copycat"
- instrument: reddy.instrument
+ PieChart {
+ id: chartB
+ width: 100; height: 100
+ color: chartA.color
+ }
}
MouseArea {
anchors.fill: parent
- onClicked: {
- reddy.perform()
- craig.perform()
-
- reddy.instrument = "Drums"
+ onClicked: { chartA.color = "blue" }
+ }
- reddy.perform()
- craig.perform()
- }
+ Text {
+ anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 }
+ text: "Click anywhere to change the chart color"
}
}
//![0]
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
index bd05ebe..0f04167 100644
--- a/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/chapter3-bindings.pro
@@ -1,5 +1,5 @@
QT += declarative
-HEADERS += musician.h
-SOURCES += musician.cpp \
+HEADERS += piechart.h
+SOURCES += piechart.cpp \
main.cpp
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp
index 8ef6965..a5dbab3 100644
--- a/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
//![0]
-#include "musician.h"
+#include "piechart.h"
#include <qdeclarative.h>
#include <QDeclarativeView>
#include <QApplication>
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- qmlRegisterType<Musician>("Music", 1, 0, "Musician");
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
QDeclarativeView view;
view.setSource(QUrl::fromLocalFile("app.qml"));
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp b/examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp
deleted file mode 100644
index 5f9ead4..0000000
--- a/examples/declarative/tutorials/extending/chapter3-bindings/musician.cpp
+++ /dev/null
@@ -1,76 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
deleted file mode 100644
index 0b0addb..0000000
--- a/examples/declarative/tutorials/extending/chapter3-bindings/musician.h
+++ /dev/null
@@ -1,82 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
index d76f801..fcd3806 100644
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
@@ -38,17 +38,23 @@
**
****************************************************************************/
//![0]
-import Music 1.0
+import Charts 1.0
import Qt 4.7
Item {
+ width: 300; height: 200
- Musician {
- id: reddy
- name: "Reddy the Rocker"
- instrument: Instrument { type: "Guitar" }
+ PieChart {
+ id: chart
+ anchors.centerIn: parent
+ width: 100; height: 100
+
+ pieSlice: PieSlice {
+ anchors.fill: parent
+ color: "red"
+ }
}
- Component.onCompleted: console.log("Reddy plays the " + reddy.instrument.type)
+ Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color)
}
//![0]
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
index aea07a0..c3f5402 100644
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro
@@ -1,7 +1,7 @@
QT += declarative
-HEADERS += musician.h \
- instrument.h
-SOURCES += musician.cpp \
- instrument.cpp \
+HEADERS += piechart.h \
+ pieslice.h
+SOURCES += piechart.cpp \
+ pieslice.cpp \
main.cpp
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp
deleted file mode 100644
index 9ca96f6..0000000
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.cpp
+++ /dev/null
@@ -1,56 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "instrument.h"
-
-Instrument::Instrument(QObject *parent)
- : QObject(parent)
-{
-}
-
-QString Instrument::type() const
-{
- return m_type;
-}
-
-void Instrument::setType(const QString &type)
-{
- m_type = type;
-}
-
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h
deleted file mode 100644
index 9971207..0000000
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/instrument.h
+++ /dev/null
@@ -1,63 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
index d94cb03..fd518a2 100644
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp
@@ -37,8 +37,8 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include "musician.h"
-#include "instrument.h"
+#include "piechart.h"
+#include "pieslice.h"
#include <qdeclarative.h>
#include <QDeclarativeView>
@@ -50,10 +50,10 @@ int main(int argc, char *argv[])
//![0]
QApplication app(argc, argv);
- qmlRegisterType<Musician>("Music", 1, 0, "Musician");
+ qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart");
//![1]
- qmlRegisterType<Instrument>("Music", 1, 0, "Instrument");
+ qmlRegisterType<PieSlice>("Charts", 1, 0, "PieSlice");
//![1]
QDeclarativeView view;
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp
deleted file mode 100644
index e62efb1..0000000
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.cpp
+++ /dev/null
@@ -1,67 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
deleted file mode 100644
index 8f67f61..0000000
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/musician.h
+++ /dev/null
@@ -1,78 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
deleted file mode 100644
index 9c050b8..0000000
--- a/examples/declarative/tutorials/extending/chapter5-plugins/app.qml
+++ /dev/null
@@ -1,53 +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 QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import 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
deleted file mode 100644
index 483da8f..0000000
--- a/examples/declarative/tutorials/extending/chapter5-plugins/chapter5-plugins.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-TEMPLATE = lib
-CONFIG += qt plugin
-QT += declarative
-
-DESTDIR = lib
-OBJECTS_DIR = tmp
-MOC_DIR = tmp
-
-HEADERS += musician.h \
- instrument.h \
- musicplugin.h
-
-SOURCES += musician.cpp \
- instrument.cpp \
- musicplugin.cpp
-
-symbian {
- include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
- TARGET.EPOCALLOWDLLDATA = 1
-}
diff --git a/examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp b/examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp
deleted file mode 100644
index 9ca96f6..0000000
--- a/examples/declarative/tutorials/extending/chapter5-plugins/instrument.cpp
+++ /dev/null
@@ -1,56 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
deleted file mode 100644
index ce1e7ce..0000000
--- a/examples/declarative/tutorials/extending/chapter5-plugins/instrument.h
+++ /dev/null
@@ -1,61 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
deleted file mode 100644
index e62efb1..0000000
--- a/examples/declarative/tutorials/extending/chapter5-plugins/musician.cpp
+++ /dev/null
@@ -1,67 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
deleted file mode 100644
index b920631..0000000
--- a/examples/declarative/tutorials/extending/chapter5-plugins/musician.h
+++ /dev/null
@@ -1,68 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
deleted file mode 100644
index 76acf01..0000000
--- a/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.cpp
+++ /dev/null
@@ -1,54 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
deleted file mode 100644
index d6a5392..0000000
--- a/examples/declarative/tutorials/extending/chapter5-plugins/musicplugin.h
+++ /dev/null
@@ -1,55 +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:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#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
deleted file mode 100644
index c3afd6b..0000000
--- a/examples/declarative/tutorials/extending/chapter5-plugins/qmldir
+++ /dev/null
@@ -1 +0,0 @@
-plugin chapter5-plugins lib
diff --git a/examples/declarative/tutorials/extending/extending.pro b/examples/declarative/tutorials/extending/extending.pro
index 0c86fed..967473f 100644
--- a/examples/declarative/tutorials/extending/extending.pro
+++ b/examples/declarative/tutorials/extending/extending.pro
@@ -5,5 +5,6 @@ SUBDIRS += \
chapter2-methods \
chapter3-bindings \
chapter4-customPropertyTypes \
- chapter5-plugins
+ chapter5-listproperties \
+ chapter6-plugins
diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml
index 68f8712..80567ef 100644
--- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml
@@ -55,7 +55,7 @@ Rectangle {
Image {
id: background
anchors.fill: parent
- source: "../shared/pics/background.jpg"
+ source: "../shared/pics/background.png"
fillMode: Image.PreserveAspectCrop
}
}
diff --git a/examples/declarative/ui-components/tabwidget/TabWidget.qml b/examples/declarative/ui-components/tabwidget/TabWidget.qml
index 9642e04..ce57213 100644
--- a/examples/declarative/ui-components/tabwidget/TabWidget.qml
+++ b/examples/declarative/ui-components/tabwidget/TabWidget.qml
@@ -43,9 +43,14 @@ import Qt 4.7
Item {
id: tabWidget
- property int current: 0
+ // Setting the default property to stack.children means any child items
+ // of the TabWidget are actually added to the 'stack' item's children.
+ // See the "Extending Types from QML" documentation for details on default
+ // properties.
default property alias content: stack.children
+ property int current: 0
+
onCurrentChanged: setOpacities()
Component.onCompleted: setOpacities()
diff --git a/src/declarative/debugger/qdeclarativedebugtrace.cpp b/src/declarative/debugger/qdeclarativedebugtrace.cpp
index 5e6d5e7..b2b0c8a 100644
--- a/src/declarative/debugger/qdeclarativedebugtrace.cpp
+++ b/src/declarative/debugger/qdeclarativedebugtrace.cpp
@@ -78,6 +78,9 @@ void QDeclarativeDebugTrace::endRange(RangeType t)
void QDeclarativeDebugTrace::addEventImpl(EventType event)
{
+ if (!isEnabled())
+ return;
+
QByteArray data;
QDataStream ds(&data, QIODevice::WriteOnly);
ds << m_timer.elapsed() << (int)Event << (int)event;
@@ -86,6 +89,9 @@ void QDeclarativeDebugTrace::addEventImpl(EventType event)
void QDeclarativeDebugTrace::startRangeImpl(RangeType range)
{
+ if (!isEnabled())
+ return;
+
QByteArray data;
QDataStream ds(&data, QIODevice::WriteOnly);
ds << m_timer.elapsed() << (int)RangeStart << (int)range;
@@ -94,6 +100,9 @@ void QDeclarativeDebugTrace::startRangeImpl(RangeType range)
void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QUrl &u)
{
+ if (!isEnabled())
+ return;
+
QByteArray data;
QDataStream ds(&data, QIODevice::WriteOnly);
ds << m_timer.elapsed() << (int)RangeData << (int)range << (QString)u.toString();
@@ -102,6 +111,9 @@ void QDeclarativeDebugTrace::rangeDataImpl(RangeType range, const QUrl &u)
void QDeclarativeDebugTrace::endRangeImpl(RangeType range)
{
+ if (!isEnabled())
+ return;
+
QByteArray data;
QDataStream ds(&data, QIODevice::WriteOnly);
ds << m_timer.elapsed() << (int)RangeEnd << (int)range;
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 805e623..b286e11 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -1342,7 +1342,7 @@ bool QDeclarativeFlickable::isFlickingVertically() const
This property holds the time to delay (ms) delivering a press to
children of the Flickable. This can be useful where reacting
- to a press before a flicking action has undesireable effects.
+ to a press before a flicking action has undesirable effects.
If the flickable is dragged/flicked before the delay times out
the press event will not be delivered. If the button is released
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 14a4f08..89b3958 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -1293,9 +1293,15 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate)
\qmlproperty int GridView::currentIndex
\qmlproperty Item GridView::currentItem
- \c currentIndex holds the index of the current item.
- \c currentItem is the current item. Note that the position of the current item
- may only be approximate until it becomes visible in the view.
+ The \c currentIndex property holds the index of the current item, and
+ \c currentItem holds the current item.
+
+ If highlightFollowsCurrentItem is \c true, setting either of these
+ properties will smoothly scroll the GridView so that the current
+ item becomes visible.
+
+ Note that the position of the current item
+ may only be approximate until it becomes visible in the view.
*/
int QDeclarativeGridView::currentIndex() const
{
@@ -1385,7 +1391,7 @@ void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight)
\qmlproperty bool GridView::highlightFollowsCurrentItem
This property sets whether the highlight is managed by the view.
- If this property is true, the highlight is moved smoothly
+ If this property is true (the default value), the highlight is moved smoothly
to follow the current item. Otherwise, the
highlight is not moved by the view, and any movement must be implemented
by the highlight.
@@ -1568,6 +1574,8 @@ void QDeclarativeGridView::setFlow(Flow flow)
If this is true, key navigation that would move the current item selection
past one end of the view instead wraps around and moves the selection to
the other end of the view.
+
+ By default, key navigation is not wrapped.
*/
bool QDeclarativeGridView::isWrapEnabled() const
{
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index 5146070..37736cc 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -65,18 +65,20 @@ QT_BEGIN_NAMESPACE
Image { source: "qtlogo.png" }
\endqml
\endtable
-
- If a size is not specified explicitly, the Image element is sized to the loaded image.
- Image elements can be stretched and tiled using the \l fillMode property.
- If the image \l source is a network resource, the image is loaded asynchronous and the
- \l progress and \l status properties are updated appropriately. Otherwise, if the image is
- available locally, it is loaded immediately and the user interface is blocked until loading is
- complete. (This is typically the correct behavior for user interface elements.)
- For large local images, which do not need to be visible immediately, it may be preferable to
- enable \l asynchronous loading. This loads the image in the background using a low priority thread.
+ If the \l {Item::width}{width} and \l{Item::height}{height} properties are not specified,
+ the Image element is automatically sized to the loaded image. Image elements can be
+ stretched and tiled using the \l fillMode property.
+
+ By default, locally available images are loaded immediately, and the user interface
+ is blocked until loading is complete. If a large image is to be loaded, it may be
+ preferable to load the image in a low priority thread, by enabling the \l asynchronous
+ property.
- Images are cached and shared internally, so if several Image elements have the same source
+ If the image is from a network rather than a local resource, it is automatically loaded
+ asynchronously, and the \l progress and \l status properties are updated as appropriate.
+
+ Images are cached and shared internally, so if several Image elements have the same \l source,
only one copy of the image will be loaded.
\bold Note: Images are often the greatest user of memory in QML user interfaces. It is recommended
@@ -84,7 +86,7 @@ QT_BEGIN_NAMESPACE
size bounded via the \l sourceSize property. This is especially important for content
that is loaded from external sources or provided by the user.
- \sa {declarative/imageelements/image}{Image example}
+ \sa {declarative/imageelements/image}{Image example}, QDeclarativeImageProvider
*/
/*!
@@ -415,7 +417,7 @@ void QDeclarativeImage::geometryChanged(const QRectF &newGeometry, const QRectF
asynchronously in a separate thread. The default value is
false, causing the user interface thread to block while the
image is loaded. Setting \a asynchronous to true is useful where
- maintaining a responsive user interface is more desireable
+ maintaining a responsive user interface is more desirable
than having images immediately visible.
Note that this property is only valid for images read from the
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index 23735f2..83f9b20 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -1582,7 +1582,7 @@ QDeclarativeItem *QDeclarativeItem::parentItem() const
Returns true if construction of the QML component is complete; otherwise
returns false.
- It is often desireable to delay some processing until the component is
+ It is often desirable to delay some processing until the component is
completed.
\sa componentComplete()
@@ -1590,7 +1590,7 @@ QDeclarativeItem *QDeclarativeItem::parentItem() const
bool QDeclarativeItem::isComponentComplete() const
{
Q_D(const QDeclarativeItem);
- return d->_componentComplete;
+ return d->componentComplete;
}
void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty<QObject> *prop, QObject *o)
@@ -1731,7 +1731,7 @@ QRectF QDeclarativeItem::childrenRect()
Q_D(QDeclarativeItem);
if (!d->_contents) {
d->_contents = new QDeclarativeContents(this);
- if (d->_componentComplete)
+ if (d->componentComplete)
d->_contents->complete();
}
return d->_contents->rectF();
@@ -2131,19 +2131,19 @@ QDeclarativeAnchorLine QDeclarativeItemPrivate::baseline() const
qreal QDeclarativeItem::baselineOffset() const
{
Q_D(const QDeclarativeItem);
- if (!d->_baselineOffset.isValid()) {
+ if (!d->baselineOffset.isValid()) {
return 0.0;
} else
- return d->_baselineOffset;
+ return d->baselineOffset;
}
void QDeclarativeItem::setBaselineOffset(qreal offset)
{
Q_D(QDeclarativeItem);
- if (offset == d->_baselineOffset)
+ if (offset == d->baselineOffset)
return;
- d->_baselineOffset = offset;
+ d->baselineOffset = offset;
for(int ii = 0; ii < d->changeListeners.count(); ++ii) {
const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii);
@@ -2276,7 +2276,7 @@ void QDeclarativeItem::setBaselineOffset(qreal offset)
bool QDeclarativeItem::keepMouseGrab() const
{
Q_D(const QDeclarativeItem);
- return d->_keepMouse;
+ return d->keepMouse;
}
/*!
@@ -2300,7 +2300,7 @@ bool QDeclarativeItem::keepMouseGrab() const
void QDeclarativeItem::setKeepMouseGrab(bool keep)
{
Q_D(QDeclarativeItem);
- d->_keepMouse = keep;
+ d->keepMouse = keep;
}
/*!
@@ -2574,7 +2574,7 @@ QDeclarativeListProperty<QGraphicsTransform> QDeclarativeItem::transform()
void QDeclarativeItem::classBegin()
{
Q_D(QDeclarativeItem);
- d->_componentComplete = false;
+ d->componentComplete = false;
if (d->_stateGroup)
d->_stateGroup->classBegin();
if (d->_anchors)
@@ -2585,14 +2585,14 @@ void QDeclarativeItem::classBegin()
\internal
componentComplete() is called when all items in the component
- have been constructed. It is often desireable to delay some
+ have been constructed. It is often desirable to delay some
processing until the component is complete an all bindings in the
component have been resolved.
*/
void QDeclarativeItem::componentComplete()
{
Q_D(QDeclarativeItem);
- d->_componentComplete = true;
+ d->componentComplete = true;
if (d->_stateGroup)
d->_stateGroup->componentComplete();
if (d->_anchors) {
@@ -2610,7 +2610,7 @@ QDeclarativeStateGroup *QDeclarativeItemPrivate::_states()
Q_Q(QDeclarativeItem);
if (!_stateGroup) {
_stateGroup = new QDeclarativeStateGroup;
- if (!_componentComplete)
+ if (!componentComplete)
_stateGroup->classBegin();
QObject::connect(_stateGroup, SIGNAL(stateChanged(QString)),
q, SIGNAL(stateChanged(QString)));
@@ -2694,7 +2694,7 @@ bool QDeclarativeItem::sceneEvent(QEvent *event)
}
/*!
- \reimp
+ \internal
Note that unlike QGraphicsItems, QDeclarativeItem::itemChange() is \e not called
during initial widget polishing. Items wishing to optimize start-up construction
@@ -2858,7 +2858,7 @@ void QDeclarativeItem::setSmooth(bool smooth)
*/
/*!
- \property QDeclarativeItem::wantsFocus
+ \property QDeclarativeItem::activeFocus
\internal
*/
diff --git a/src/declarative/graphicsitems/qdeclarativeitem_p.h b/src/declarative/graphicsitems/qdeclarativeitem_p.h
index 84b0f51..8c3e084 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem_p.h
@@ -120,11 +120,11 @@ class Q_DECLARATIVE_EXPORT QDeclarativeItemPrivate : public QGraphicsItemPrivate
public:
QDeclarativeItemPrivate()
: _anchors(0), _contents(0),
- _baselineOffset(0),
+ baselineOffset(0),
_anchorLines(0),
_stateGroup(0), origin(QDeclarativeItem::Center),
widthValid(false), heightValid(false),
- _componentComplete(true), _keepMouse(false),
+ componentComplete(true), keepMouse(false),
smooth(false), transformOriginDirty(true), doneEventPreHandler(false), keyHandler(0),
mWidth(0), mHeight(0), implicitWidth(0), implicitHeight(0)
{
@@ -144,12 +144,10 @@ public:
QDeclarative_setParent_noEvent(q, parent);
q->setParentItem(parent);
}
- _baselineOffset.invalidate();
+ baselineOffset.invalidate();
mouseSetsFocus = false;
}
- QString _id;
-
// Private Properties
qreal width() const;
void setWidth(qreal);
@@ -203,7 +201,7 @@ public:
if (!_anchors) {
Q_Q(QDeclarativeItem);
_anchors = new QDeclarativeAnchors(q);
- if (!_componentComplete)
+ if (!componentComplete)
_anchors->classBegin();
}
return _anchors;
@@ -211,7 +209,7 @@ public:
QDeclarativeAnchors *_anchors;
QDeclarativeContents *_contents;
- QDeclarativeNullableValue<qreal> _baselineOffset;
+ QDeclarativeNullableValue<qreal> baselineOffset;
struct AnchorLines {
AnchorLines(QGraphicsObject *);
@@ -260,8 +258,8 @@ public:
QDeclarativeItem::TransformOrigin origin:4;
bool widthValid:1;
bool heightValid:1;
- bool _componentComplete:1;
- bool _keepMouse:1;
+ bool componentComplete:1;
+ bool keepMouse:1;
bool smooth:1;
bool transformOriginDirty : 1;
bool doneEventPreHandler : 1;
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
index b198077..5d623dc 100644
--- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
@@ -95,7 +95,8 @@ static QDeclarativePrivate::AutoParentResult qgraphicsobject_autoParent(QObject
void QDeclarativeItemModule::defineModule()
{
- QDeclarativePrivate::registerAutoParentFunction(qgraphicsobject_autoParent);
+ QDeclarativePrivate::RegisterAutoParent autoparent = { 0, &qgraphicsobject_autoParent };
+ QDeclarativePrivate::qmlregister(QDeclarativePrivate::AutoParentRegistration, &autoparent);
#ifdef QT_NO_MOVIE
qmlRegisterTypeNotAvailable("Qt",4,7,"AnimatedImage",
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 6d127b5..8b616ce 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -1632,8 +1632,14 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate)
\qmlproperty int ListView::currentIndex
\qmlproperty Item ListView::currentItem
- \c currentIndex holds the index of the current item.
- \c currentItem is the current item. Note that the position of the current item
+ The \c currentIndex property holds the index of the current item, and
+ \c currentItem holds the current item.
+
+ If highlightFollowsCurrentItem is \c true, setting either of these
+ properties will smoothly scroll the ListView so that the current
+ item becomes visible.
+
+ Note that the position of the current item
may only be approximate until it becomes visible in the view.
*/
int QDeclarativeListView::currentIndex() const
@@ -1727,12 +1733,12 @@ void QDeclarativeListView::setHighlight(QDeclarativeComponent *highlight)
\qmlproperty bool ListView::highlightFollowsCurrentItem
This property holds whether the highlight is managed by the view.
- If this property is true, the highlight is moved smoothly
+ If this property is true (the default value), the highlight is moved smoothly
to follow the current item. Otherwise, the
highlight is not moved by the view, and any movement must be implemented
by the highlight.
- Here is a highlight with its motion defined by a \l {SpringAniamtion} item:
+ Here is a highlight with its motion defined by a \l {SpringAnimation} item:
\snippet doc/src/snippets/declarative/listview/listview.qml highlightFollowsCurrentItem
@@ -1848,6 +1854,8 @@ void QDeclarativeListView::setHighlightRangeMode(HighlightRangeMode mode)
\qmlproperty real ListView::spacing
This property holds the spacing between items.
+
+ The default value is 0.
*/
qreal QDeclarativeListView::spacing() const
{
@@ -1914,11 +1922,13 @@ void QDeclarativeListView::setOrientation(QDeclarativeListView::Orientation orie
/*!
\qmlproperty bool ListView::keyNavigationWraps
- This property holds whether the list wraps key navigation.
+ This property holds whether the list wraps key navigation.
If this is true, key navigation that would move the current item selection
past the end of the list instead wraps around and moves the selection to
the start of the list, and vice-versa.
+
+ By default, key navigation is not wrapped.
*/
bool QDeclarativeListView::isWrapEnabled() const
{
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index e745ca6..cc7f8e5 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -118,9 +118,9 @@ void QDeclarativeLoaderPrivate::initResize()
be instantiated may be specified directly by the \l sourceComponent
property, or loaded from a URL via the \l source property.
- Loader can be used to delay the creation of a component until it is required.
- For example, this loads "Page1.qml" as a component into the Loader element
- when the \l MouseArea is clicked:
+ Loader can be used to delay the creation of a component until it
+ is required. For example, this loads "Page1.qml" as a component
+ into the Loader element, when the \l MouseArea is clicked:
\code
import Qt 4.7
@@ -165,7 +165,6 @@ void QDeclarativeLoaderPrivate::initResize()
/*!
\internal
\class QDeclarativeLoader
- \qmlclass Loader
*/
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index 40c621a..dcdb9f6 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -521,7 +521,8 @@ void QDeclarativeMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
// If we don't accept hover, we need to reset containsMouse.
if (!acceptHoverEvents())
setHovered(false);
- if (scene()->mouseGrabberItem() == this)
+ QGraphicsScene *s = scene();
+ if (s && s->mouseGrabberItem() == this)
ungrabMouse();
setKeepMouseGrab(false);
}
diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
index 3b9b8df..a6db1fa 100644
--- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
@@ -90,6 +90,8 @@ QT_BEGIN_NAMESPACE
static int inpaint=0;
static int inpaint_clearcache=0;
+extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled;
+
/*!
Marks areas of the cache that intersect with the given \a rect as dirty and
in need of being refreshed.
@@ -287,7 +289,14 @@ void QDeclarativePaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem
QRectF target(area.x(), area.y(), area.width(), area.height());
if (!d->cachefrozen) {
if (!d->imagecache[i]->dirty.isNull() && topaint.contains(d->imagecache[i]->dirty)) {
+#ifdef Q_WS_MAC
+ bool oldSmooth = qt_applefontsmoothing_enabled;
+ qt_applefontsmoothing_enabled = false;
+#endif
QPainter qp(&d->imagecache[i]->image);
+#ifdef Q_WS_MAC
+ qt_applefontsmoothing_enabled = oldSmooth;
+#endif
qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache);
qp.translate(-area.x(), -area.y());
qp.scale(d->contentsScale,d->contentsScale);
@@ -349,7 +358,14 @@ void QDeclarativePaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem
if (d->fillColor.isValid())
img.fill(d->fillColor);
{
+#ifdef Q_WS_MAC
+ bool oldSmooth = qt_applefontsmoothing_enabled;
+ qt_applefontsmoothing_enabled = false;
+#endif
QPainter qp(&img);
+#ifdef Q_WS_MAC
+ qt_applefontsmoothing_enabled = oldSmooth;
+#endif
qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache);
qp.translate(-r.x(),-r.y());
diff --git a/src/declarative/graphicsitems/qdeclarativepath.cpp b/src/declarative/graphicsitems/qdeclarativepath.cpp
index a904869..80196a1 100644
--- a/src/declarative/graphicsitems/qdeclarativepath.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepath.cpp
@@ -533,6 +533,13 @@ void QDeclarativeCurve::setY(qreal y)
/*!
\qmlproperty string PathAttribute::name
the name of the attribute to change.
+
+ This attribute will be available to the delegate as PathView.<name>
+
+ Note that using an existing Item property name such as "opacity" as an
+ attribute is allowed. This is because path attributes add a new
+ \l{qdeclarativeintroduction.html#attached-properties} {Attached Property}
+ which in no way clashes with existing properties.
*/
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index b23a3c3..acf9827 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -329,6 +329,10 @@ void QDeclarativePathViewPrivate::regenerate()
\image pathview.gif
+ (Note the above example uses PathAttribute to scale and modify the
+ opacity of the items as they rotate. This additional code can be seen in the
+ PathAttribute documentation.)
+
Delegates are instantiated as needed and may be destroyed at any time.
State should \e never be stored in a delegate.
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
index 8ba80ad..2b268fb 100644
--- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
@@ -85,6 +85,19 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate()
The \l model of a Repeater can be any of the supported \l {qmlmodels}{Data Models}.
+ Items instantiated by the Repeater are inserted, in order, as
+ children of the Repeater's parent. The insertion starts immediately after
+ the repeater's position in its parent stacking list. This allows
+ a Repeater to be used inside a layout. For example, the following Repeater's
+ items are stacked between a red rectangle and a blue rectangle:
+
+ \snippet doc/src/snippets/declarative/repeater.qml layout
+
+ \image repeater.png
+
+
+ \section2 The \c index and \c modelData properties
+
The index of a delegate is exposed as an accessible \c index property in the delegate.
Properties of the model are also available depending upon the type of \l {qmlmodels}{Data Model}.
@@ -105,25 +118,22 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate()
\o \image repeater-modeldata.png
\endtable
- Items instantiated by the Repeater are inserted, in order, as
- children of the Repeater's parent. The insertion starts immediately after
- the repeater's position in its parent stacking list. This allows
- a Repeater to be used inside a layout. For example, the following Repeater's
- items are stacked between a red rectangle and a blue rectangle:
-
- \snippet doc/src/snippets/declarative/repeater.qml layout
-
- \image repeater.png
A Repeater item owns all items it instantiates. Removing or dynamically destroying
an item created by a Repeater results in unpredictable behavior.
- Note that if a repeater is
- required to instantiate a large number of items, it may be more efficient to
- use other view elements such as ListView.
- \note Repeater is \l {Item}-based, and can only repeat \l {Item}-derived objects.
- For example, it cannot be used to repeat QtObjects.
+ \section2 Considerations when using Repeater
+
+ The Repeater element creates all of its delegate items when the repeater is first
+ created. This can be inefficient if there are a large number of delegate items and
+ not all of the items are required to be visible at the same time. If this is the case,
+ consider using other view elements like ListView (which only creates delegate items
+ when they are scrolled into view) or use the \l {Dynamic Object Creation} methods to
+ create items as they are required.
+
+ Also, note that Repeater is \l {Item}-based, and can only repeat \l {Item}-derived objects.
+ For example, it cannot be used to repeat QtObjects:
\badcode
Item {
//XXX does not work! Can't repeat QtObject as it doesn't derive from Item.
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index 83911cb..ab2be9c 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -57,6 +57,8 @@
QT_BEGIN_NAMESPACE
+extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled;
+
class QTextDocumentWithImageResources : public QTextDocument {
Q_OBJECT
@@ -747,7 +749,7 @@ void QDeclarativeText::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
Q_D(QDeclarativeText);
- if (newGeometry.width() != oldGeometry.width()) {
+ if (!d->internalWidthUpdate && newGeometry.width() != oldGeometry.width()) {
if (d->wrapMode != QDeclarativeText::NoWrap || d->elideMode != QDeclarativeText::ElideNone) {
//re-elide if needed
if (d->singleline && d->elideMode != QDeclarativeText::ElideNone &&
@@ -847,7 +849,9 @@ void QDeclarativeTextPrivate::updateSize()
q->setBaselineOffset(fm.ascent() + yoff);
//### need to comfirm cost of always setting these for richText
+ internalWidthUpdate = true;
q->setImplicitWidth(size.width());
+ internalWidthUpdate = false;
q->setImplicitHeight(size.height());
emit q->paintedSizeChanged();
} else {
@@ -1001,7 +1005,14 @@ QPixmap QDeclarativeTextPrivate::wrappedTextImage(bool drawStyle)
QPixmap img(size);
if (!size.isEmpty()) {
img.fill(Qt::transparent);
+#ifdef Q_WS_MAC
+ bool oldSmooth = qt_applefontsmoothing_enabled;
+ qt_applefontsmoothing_enabled = false;
+#endif
QPainter p(&img);
+#ifdef Q_WS_MAC
+ qt_applefontsmoothing_enabled = oldSmooth;
+#endif
drawWrappedText(&p, QPointF(0,0), drawStyle);
}
return img;
@@ -1024,7 +1035,14 @@ QPixmap QDeclarativeTextPrivate::richTextImage(bool drawStyle)
//paint text
QPixmap img(size);
img.fill(Qt::transparent);
+#ifdef Q_WS_MAC
+ bool oldSmooth = qt_applefontsmoothing_enabled;
+ qt_applefontsmoothing_enabled = false;
+#endif
QPainter p(&img);
+#ifdef Q_WS_MAC
+ qt_applefontsmoothing_enabled = oldSmooth;
+#endif
QAbstractTextDocumentLayout::PaintContext context;
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p_p.h b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
index 51a5514..48552a7 100644
--- a/src/declarative/graphicsitems/qdeclarativetext_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetext_p_p.h
@@ -72,7 +72,7 @@ public:
QDeclarativeTextPrivate()
: color((QRgb)0), style(QDeclarativeText::Normal),
hAlign(QDeclarativeText::AlignLeft), vAlign(QDeclarativeText::AlignTop), elideMode(QDeclarativeText::ElideNone),
- imgDirty(true), dirty(true), richText(false), singleline(false), cache(true), doc(0),
+ imgDirty(true), dirty(true), richText(false), singleline(false), cache(true), internalWidthUpdate(false), doc(0),
format(QDeclarativeText::AutoText), wrapMode(QDeclarativeText::NoWrap)
{
#if defined(QML_NO_TEXT_CACHE)
@@ -119,6 +119,7 @@ public:
bool richText:1;
bool singleline:1;
bool cache:1;
+ bool internalWidthUpdate:1;
QTextDocumentWithImageResources *doc;
QTextLayout layout;
QSize cachedLayoutSize;
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 55b802f..8117676 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -202,8 +202,9 @@ QString QDeclarativeTextEdit::text() const
Sets the font size in pixels.
- Using this function makes the font device dependent.
- Use \l font.pointSize to set the size of the font in a device independent manner.
+ Using this function makes the font device dependent. Use
+ \l{TextEdit::font.pointSize} to set the size of the font in a
+ device independent manner.
*/
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativetranslate.cpp b/src/declarative/graphicsitems/qdeclarativetranslate.cpp
index 17daac7..16a1127 100644
--- a/src/declarative/graphicsitems/qdeclarativetranslate.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetranslate.cpp
@@ -117,7 +117,7 @@ void QDeclarativeTranslate::setY(qreal y)
}
/*!
- \reimp
+ \internal
*/
void QDeclarativeTranslate::applyTo(QMatrix4x4 *matrix) const
{
diff --git a/src/declarative/qml/parser/qdeclarativejslexer.cpp b/src/declarative/qml/parser/qdeclarativejslexer.cpp
index fcaaece..65a6af2 100644
--- a/src/declarative/qml/parser/qdeclarativejslexer.cpp
+++ b/src/declarative/qml/parser/qdeclarativejslexer.cpp
@@ -103,7 +103,7 @@ Lexer::Lexer(Engine *eng, bool tokenizeComments)
prohibitAutomaticSemicolon(false),
tokenizeComments(tokenizeComments)
{
- driver->setLexer(this);
+ if (driver) driver->setLexer(this);
// allocate space for read buffers
buffer8 = new char[size8];
buffer16 = new QChar[size16];
@@ -677,9 +677,9 @@ int Lexer::lex()
setDone(Other);
} else
state = Start;
- driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
} else if (current == 0) {
- driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
setDone(Eof);
}
@@ -689,14 +689,14 @@ int Lexer::lex()
setDone(Bad);
err = UnclosedComment;
errmsg = QCoreApplication::translate("QDeclarativeParser", "Unclosed comment at end of file");
- driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
} else if (isLineTerminator()) {
shiftWindowsLineBreak();
yylineno++;
} else if (current == '*' && next1 == '/') {
state = Start;
shift(1);
- driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
+ if (driver) driver->addComment(startpos, tokenLength(), startlineno, startcolumn);
}
break;
diff --git a/src/declarative/qml/qdeclarative.h b/src/declarative/qml/qdeclarative.h
index 53ff51c..c6b64ae 100644
--- a/src/declarative/qml/qdeclarative.h
+++ b/src/declarative/qml/qdeclarative.h
@@ -116,7 +116,7 @@ int qmlRegisterType()
0
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message);
@@ -151,7 +151,7 @@ int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMin
0
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
template<typename T>
@@ -184,7 +184,7 @@ int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const c
0
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
template<typename T, typename E>
@@ -217,7 +217,7 @@ int qmlRegisterExtendedType()
0
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
template<typename T, typename E>
@@ -258,7 +258,7 @@ int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor,
0
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
template<typename T>
@@ -278,7 +278,7 @@ int qmlRegisterInterface(const char *typeName)
qobject_interface_iid<T *>()
};
- return QDeclarativePrivate::registerType(interface);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::InterfaceRegistration, &interface);
}
template<typename T>
@@ -312,7 +312,7 @@ int qmlRegisterCustomType(const char *uri, int versionMajor, int versionMinor,
parser
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
class QDeclarativeContext;
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
index 882e981..e096305 100644
--- a/src/declarative/qml/qdeclarativebinding.cpp
+++ b/src/declarative/qml/qdeclarativebinding.cpp
@@ -54,27 +54,20 @@
QT_BEGIN_NAMESPACE
-QDeclarativeBindingData::QDeclarativeBindingData()
-: updating(false), enabled(false)
+void QDeclarativeBindingPrivate::refresh()
{
+ Q_Q(QDeclarativeBinding);
+ q->update();
}
-QDeclarativeBindingData::~QDeclarativeBindingData()
-{
- removeError();
-}
-
-void QDeclarativeBindingData::refresh()
+QDeclarativeBindingPrivate::QDeclarativeBindingPrivate()
+: updating(false), enabled(false), deleted(0)
{
- if (enabled && !updating && q) {
- QDeclarativeBinding *b = static_cast<QDeclarativeBinding *>(QDeclarativeExpressionPrivate::get(q));
- b->update();
- }
}
-QDeclarativeBindingPrivate::QDeclarativeBindingPrivate()
-: QDeclarativeExpressionPrivate(new QDeclarativeBindingData)
+QDeclarativeBindingPrivate::~QDeclarativeBindingPrivate()
{
+ if (deleted) *deleted = true;
}
QDeclarativeBinding::QDeclarativeBinding(void *data, QDeclarativeRefCount *rc, QObject *obj,
@@ -109,7 +102,7 @@ QDeclarativeBinding::~QDeclarativeBinding()
void QDeclarativeBinding::setTarget(const QDeclarativeProperty &prop)
{
Q_D(QDeclarativeBinding);
- d->bindingData()->property = prop;
+ d->property = prop;
update();
}
@@ -117,50 +110,53 @@ void QDeclarativeBinding::setTarget(const QDeclarativeProperty &prop)
QDeclarativeProperty QDeclarativeBinding::property() const
{
Q_D(const QDeclarativeBinding);
- return d->bindingData()->property;
+ return d->property;
}
void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags)
{
Q_D(QDeclarativeBinding);
- QDeclarativeBindingData *data = d->bindingData();
-
- if (!data->enabled || !data->context() || !data->context()->isValid())
+ if (!d->enabled || !d->context() || !d->context()->isValid())
return;
- data->addref();
-
- if (!data->updating) {
- data->updating = true;
+ if (!d->updating) {
+ d->updating = true;
+ bool wasDeleted = false;
+ d->deleted = &wasDeleted;
- if (data->property.propertyType() == qMetaTypeId<QDeclarativeBinding *>()) {
+ if (d->property.propertyType() == qMetaTypeId<QDeclarativeBinding *>()) {
- int idx = data->property.index();
+ int idx = d->property.index();
Q_ASSERT(idx != -1);
-
QDeclarativeBinding *t = this;
int status = -1;
void *a[] = { &t, 0, &status, &flags };
- QMetaObject::metacall(data->property.object(),
+ QMetaObject::metacall(d->property.object(),
QMetaObject::WriteProperty,
idx, a);
+ if (wasDeleted)
+ return;
+
} else {
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(data->context()->engine);
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(d->context()->engine);
bool isUndefined = false;
QVariant value;
QScriptValue scriptValue = d->scriptValue(0, &isUndefined);
- if (data->property.propertyTypeCategory() == QDeclarativeProperty::List) {
+ if (wasDeleted)
+ return;
+
+ if (d->property.propertyTypeCategory() == QDeclarativeProperty::List) {
value = ep->scriptValueToVariant(scriptValue, qMetaTypeId<QList<QObject *> >());
} else if (scriptValue.isNull() &&
- data->property.propertyTypeCategory() == QDeclarativeProperty::Object) {
+ d->property.propertyTypeCategory() == QDeclarativeProperty::Object) {
value = QVariant::fromValue((QObject *)0);
} else {
- value = ep->scriptValueToVariant(scriptValue, data->property.propertyType());
+ value = ep->scriptValueToVariant(scriptValue, d->property.propertyType());
if (value.userType() == QMetaType::QObjectStar && !qvariant_cast<QObject*>(value)) {
// If the object is null, we extract the predicted type. While this isn't
// 100% reliable, in many cases it gives us better error messages if we
@@ -172,73 +168,78 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags)
}
- if (data->error.isValid()) {
+ if (d->error.isValid()) {
- } else if (isUndefined && data->property.isResettable()) {
+ } else if (isUndefined && d->property.isResettable()) {
- data->property.reset();
+ d->property.reset();
- } else if (isUndefined && data->property.propertyType() == qMetaTypeId<QVariant>()) {
+ } else if (isUndefined && d->property.propertyType() == qMetaTypeId<QVariant>()) {
- QDeclarativePropertyPrivate::write(data->property, QVariant(), flags);
+ QDeclarativePropertyPrivate::write(d->property, QVariant(), flags);
} else if (isUndefined) {
- QUrl url = QUrl(data->url);
- int line = data->line;
+ QUrl url = QUrl(d->url);
+ int line = d->line;
if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>"));
- data->error.setUrl(url);
- data->error.setLine(line);
- data->error.setColumn(-1);
- data->error.setDescription(QLatin1String("Unable to assign [undefined] to ")
- + QLatin1String(QMetaType::typeName(data->property.propertyType()))
- + QLatin1String(" ") + data->property.name());
+ d->error.setUrl(url);
+ d->error.setLine(line);
+ d->error.setColumn(-1);
+ d->error.setDescription(QLatin1String("Unable to assign [undefined] to ") +
+ QLatin1String(QMetaType::typeName(d->property.propertyType())) +
+ QLatin1String(" ") + d->property.name());
} else if (!scriptValue.isRegExp() && scriptValue.isFunction()) {
- QUrl url = QUrl(data->url);
- int line = data->line;
+ QUrl url = QUrl(d->url);
+ int line = d->line;
if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>"));
- data->error.setUrl(url);
- data->error.setLine(line);
- data->error.setColumn(-1);
- data->error.setDescription(QLatin1String("Unable to assign a function to a property."));
+ d->error.setUrl(url);
+ d->error.setLine(line);
+ d->error.setColumn(-1);
+ d->error.setDescription(QLatin1String("Unable to assign a function to a property."));
+
+ } else if (d->property.object() &&
+ !QDeclarativePropertyPrivate::write(d->property, value, flags)) {
- } else if (data->property.object() &&
- !QDeclarativePropertyPrivate::write(data->property, value, flags)) {
+ if (wasDeleted)
+ return;
- QUrl url = QUrl(data->url);
- int line = data->line;
+ QUrl url = QUrl(d->url);
+ int line = d->line;
if (url.isEmpty()) url = QUrl(QLatin1String("<Unknown File>"));
const char *valueType = 0;
if (value.userType() == QVariant::Invalid) valueType = "null";
else valueType = QMetaType::typeName(value.userType());
- data->error.setUrl(url);
- data->error.setLine(line);
- data->error.setColumn(-1);
- data->error.setDescription(QLatin1String("Unable to assign ") +
- QLatin1String(valueType) +
- QLatin1String(" to ") +
- QLatin1String(QMetaType::typeName(data->property.propertyType())));
+ d->error.setUrl(url);
+ d->error.setLine(line);
+ d->error.setColumn(-1);
+ d->error.setDescription(QLatin1String("Unable to assign ") +
+ QLatin1String(valueType) +
+ QLatin1String(" to ") +
+ QLatin1String(QMetaType::typeName(d->property.propertyType())));
}
- if (data->error.isValid()) {
- if (!data->addError(ep)) ep->warning(this->error());
+ if (wasDeleted)
+ return;
+
+ if (d->error.isValid()) {
+ if (!d->addError(ep)) ep->warning(this->error());
} else {
- data->removeError();
+ d->removeError();
}
}
- data->updating = false;
+ d->updating = false;
+ d->deleted = 0;
} else {
- qmlInfo(data->property.object()) << tr("Binding loop detected for property \"%1\"").arg(data->property.name());
+ qmlInfo(d->property.object()) << tr("Binding loop detected for property \"%1\"").arg(d->property.name());
}
-
- data->release();
}
void QDeclarativeBindingPrivate::emitValueChanged()
@@ -250,13 +251,13 @@ void QDeclarativeBindingPrivate::emitValueChanged()
void QDeclarativeBinding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteFlags flags)
{
Q_D(QDeclarativeBinding);
- d->bindingData()->enabled = e;
+ d->enabled = e;
setNotifyOnValueChanged(e);
QDeclarativeAbstractBinding::setEnabled(e, flags);
if (e) {
- addToObject(d->bindingData()->property.object());
+ addToObject(d->property.object());
update(flags);
} else {
removeFromObject();
@@ -266,14 +267,14 @@ void QDeclarativeBinding::setEnabled(bool e, QDeclarativePropertyPrivate::WriteF
int QDeclarativeBinding::propertyIndex()
{
Q_D(QDeclarativeBinding);
- return QDeclarativePropertyPrivate::bindingIndex(d->bindingData()->property);
+ return QDeclarativePropertyPrivate::bindingIndex(d->property);
}
bool QDeclarativeBinding::enabled() const
{
Q_D(const QDeclarativeBinding);
- return d->bindingData()->enabled;
+ return d->enabled;
}
QString QDeclarativeBinding::expression() const
diff --git a/src/declarative/qml/qdeclarativebinding_p_p.h b/src/declarative/qml/qdeclarativebinding_p_p.h
index 617ec4b..6926158 100644
--- a/src/declarative/qml/qdeclarativebinding_p_p.h
+++ b/src/declarative/qml/qdeclarativebinding_p_p.h
@@ -60,30 +60,24 @@
QT_BEGIN_NAMESPACE
-class QDeclarativeBindingData : public QDeclarativeExpressionData
-{
-public:
- QDeclarativeBindingData();
- virtual ~QDeclarativeBindingData();
-
- bool updating:1;
- bool enabled:1;
-
- QDeclarativeProperty property;
-
- virtual void refresh();
-};
-
class QDeclarativeBindingPrivate : public QDeclarativeExpressionPrivate
{
Q_DECLARE_PUBLIC(QDeclarativeBinding)
public:
QDeclarativeBindingPrivate();
-
- QDeclarativeBindingData *bindingData() { return static_cast<QDeclarativeBindingData *>(data); }
- const QDeclarativeBindingData *bindingData() const { return static_cast<const QDeclarativeBindingData *>(data); }
+ ~QDeclarativeBindingPrivate();
virtual void emitValueChanged();
+
+protected:
+ virtual void refresh();
+
+private:
+ bool updating:1;
+ bool enabled:1;
+ QDeclarativeProperty property;
+
+ bool *deleted;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 623e3df..23307c9 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -228,10 +228,10 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop,
}
break;
case QMetaType::Float:
- if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: float expected"));
+ if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: number expected"));
break;
case QVariant::Double:
- if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: double expected"));
+ if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: number expected"));
break;
case QVariant::Color:
{
@@ -2449,7 +2449,7 @@ bool QDeclarativeCompiler::buildDynamicMeta(QDeclarativeParser::Object *obj, Dyn
for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
Object::DynamicSlot &s = obj->dynamicSlots[ii];
QByteArray sig(s.name + '(');
- QString funcScript(QLatin1String("(function("));
+ QString funcScript(QLatin1String("(function ") + s.name + QLatin1Char('('));
for (int jj = 0; jj < s.parameterNames.count(); ++jj) {
if (jj) {
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 9d3032c..36c4b49 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -68,37 +68,85 @@ class QByteArray;
/*!
\class QDeclarativeComponent
\since 4.7
- \brief The QDeclarativeComponent class encapsulates a QML component description.
+ \brief The QDeclarativeComponent class encapsulates a QML component definition.
\mainclass
+
+ Components are reusable, encapsulated QML elements with well-defined interfaces.
+ They are often defined in \l {qdeclarativedocuments.html}{Component Files}.
+
+ A QDeclarativeComponent instance can be created from a QML file.
+ For example, if there is a \c main.qml file like this:
+
+ \qml
+ import Qt 4.7
+
+ Item {
+ width: 200
+ height: 200
+ }
+ \endqml
+
+ The following code loads this QML file as a component, creates an instance of
+ this component using create(), and then queries the \l Item's \l {Item::}{width}
+ value:
+
+ \code
+ QDeclarativeEngine *engine = new QDeclarativeEngine;
+ QDeclarativeComponent component(engine, QUrl::fromLocalFile("main.qml"));
+
+ QObject *myObject = component.create();
+ QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(myObject);
+ int width = item->width(); // width = 200
+ \endcode
+
+ \sa {Using QML in C++ Applications}, {Integrating QML with existing Qt UI code}
*/
/*!
\qmlclass Component QDeclarativeComponent
\since 4.7
- \brief The Component element encapsulates a QML component description.
+ \brief The Component element encapsulates a QML component definition.
Components are reusable, encapsulated QML elements with well-defined interfaces.
- They are often defined in \l {qdeclarativedocuments.html}{Component Files}.
- The \e Component element allows defining components within a QML file.
- This can be useful for reusing a small component within a single QML
- file, or for defining a component that logically belongs with the
- file containing it.
+ Components are often defined by \l {qdeclarativedocuments.html}{component files} -
+ that is, \c .qml files. The \e Component element allows components to be defined
+ within QML items rather than in a separate file. This may be useful for reusing
+ a small component within a QML file, or for defining a component that logically
+ belongs with other QML components within a file.
+
+ For example, here is a component that is used by multiple \l Loader objects:
\qml
Item {
Component {
id: redSquare
+
Rectangle {
color: "red"
width: 10
height: 10
}
}
+
Loader { sourceComponent: redSquare }
Loader { sourceComponent: redSquare; x: 20 }
}
\endqml
+
+ Notice that while a \l Rectangle by itself would be automatically
+ rendered and displayed, this is not the case for the above rectangle
+ because it is defined inside a \c Component. The component encapsulates the
+ QML elements within, as if they were defined in a separate \c .qml
+ file, and is not loaded until requested (in this case, by the
+ two \l Loader objects).
+
+ The Component element is commonly used to provide graphical components
+ for views. For example, the ListView::delegate property requires a Component
+ to specify how each list item is to be displayed.
+
+ Component objects can also be dynamically generated using
+ \l{Qt::createComponent}{Qt.createComponent()}.
*/
/*!
@@ -448,7 +496,8 @@ void QDeclarativeComponent::loadUrl(const QUrl &url)
d->clear();
- if (url.isRelative() && !url.isEmpty())
+ if ((url.isRelative() && !url.isEmpty())
+ || url.scheme() == QLatin1String("file")) // Workaround QTBUG-11929
d->url = d->engine->baseUrl().resolved(url);
else
d->url = url;
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index 60e9dd3..3d25291 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -145,6 +145,8 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate()
has been created in that context is an expensive operation (essentially forcing all bindings
to reevaluate). Thus whenever possible you should complete "setup" of the context
before using it to create any objects.
+
+ \sa {Using QML in C++ Applications}
*/
/*! \internal */
diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h
index 1f5aaf1..c5a039a 100644
--- a/src/declarative/qml/qdeclarativecontext_p.h
+++ b/src/declarative/qml/qdeclarativecontext_p.h
@@ -198,6 +198,7 @@ public:
// context
QDeclarativeComponentAttached *componentAttached;
+ // Return the outermost id for obj, if any.
QString findObjectId(const QObject *obj) const;
static QDeclarativeContextData *get(QDeclarativeContext *context) {
diff --git a/src/declarative/qml/qdeclarativedom.cpp b/src/declarative/qml/qdeclarativedom.cpp
index a3cddb5..5b30bde 100644
--- a/src/declarative/qml/qdeclarativedom.cpp
+++ b/src/declarative/qml/qdeclarativedom.cpp
@@ -493,7 +493,7 @@ int QDeclarativeDomDynamicProperty::propertyType() const
return QMetaType::type("int");
case QDeclarativeParser::Object::DynamicProperty::Real:
- return QMetaType::type("double");
+ return sizeof(qreal) == sizeof(double) ? QMetaType::type("double") : QMetaType::type("float");
case QDeclarativeParser::Object::DynamicProperty::String:
return QMetaType::type("QString");
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index a31448f..e3ebca3 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -115,22 +115,55 @@ QT_BEGIN_NAMESPACE
/*!
\qmlclass QtObject QObject
\since 4.7
- \brief The QtObject element is the most basic element in QML
+ \brief The QtObject element is the most basic element in QML.
The QtObject element is a non-visual element which contains only the
- objectName property. It is useful for when you need an extremely
- lightweight element to place your own custom properties in.
+ objectName property.
+
+ It can be useful to create a QtObject if you need an extremely
+ lightweight element to enclose a set of custom properties:
+
+ \snippet doc/src/snippets/declarative/qtobject.qml 0
It can also be useful for C++ integration, as it is just a plain
QObject. See the QObject documentation for further details.
*/
/*!
\qmlproperty string QML:QtObject::objectName
- This property allows you to give a name to this specific object instance.
+ This property holds the QObject::objectName for this specific object instance.
+
+ This allows a C++ application to locate an item within a QML component
+ using the QObject::findChild() method. For example, the following C++
+ application locates the child \l Rectangle item and dynamically changes its
+ \c color value:
+
+ \qml
+ // MyRect.qml
+
+ import Qt 4.7
+
+ Item {
+ width: 200; height: 200
- See \l{scripting.html#accessing-child-qobjects}{Accessing Child QObjects}
- in the scripting documentation for details how objectName can be used from
- scripts.
+ Rectangle {
+ anchors.fill: parent
+ color: "red"
+ objectName: "myRect"
+ }
+ }
+ \endqml
+
+ \code
+ // main.cpp
+
+ QDeclarativeView view;
+ view.setSource(QUrl::fromLocalFile("MyRect.qml"));
+ view.show();
+
+ QDeclarativeItem *item = view.rootObject()->findChild<QDeclarativeItem*>("myRect");
+ if (item)
+ item->setProperty("color", QColor(Qt::yellow));
+ \endcode
*/
struct StaticQtMetaObject : public QObject
@@ -219,7 +252,7 @@ of their use.
QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
-: captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false),
+: captureProperties(false), rootContext(0), isDebugging(false),
outputWarningsToStdErr(true), contextClass(0), sharedContext(0), sharedScope(0),
objectClass(0), valueTypeClass(0), globalClass(0), cleanup(0), erroredBindings(0),
inProgressCreations(0), scriptEngine(this), workerScriptEngine(0), componentAttached(0),
@@ -1080,13 +1113,20 @@ Here is an example. Notice it checks whether the component \l{Component::status}
\c Component.Ready before calling \l {Component::createObject()}{createObject()}
in case the QML file is loaded over a network and thus is not ready immediately.
-\snippet doc/src/snippets/declarative/componentCreation.js 0
+\snippet doc/src/snippets/declarative/componentCreation.js vars
+\codeline
+\snippet doc/src/snippets/declarative/componentCreation.js func
+\snippet doc/src/snippets/declarative/componentCreation.js remote
+\snippet doc/src/snippets/declarative/componentCreation.js func-end
\codeline
-\snippet doc/src/snippets/declarative/componentCreation.js 1
+\snippet doc/src/snippets/declarative/componentCreation.js finishCreation
-If you are certain the files will be local, you could simplify to:
+If you are certain the QML file to be loaded is a local file, you could omit the \c finishCreation()
+function and call \l {Component::createObject()}{createObject()} immediately:
-\snippet doc/src/snippets/declarative/componentCreation.js 2
+\snippet doc/src/snippets/declarative/componentCreation.js func
+\snippet doc/src/snippets/declarative/componentCreation.js local
+\snippet doc/src/snippets/declarative/componentCreation.js func-end
To create a QML object from an arbitrary string of QML (instead of a file),
use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}.
@@ -1271,11 +1311,12 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE
QDate date = ctxt->argument(0).toDateTime().date();
Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
if (argCount == 2) {
- if (ctxt->argument(1).isString()) {
- QString format = ctxt->argument(1).toString();
+ QScriptValue formatArg = ctxt->argument(1);
+ if (formatArg.isString()) {
+ QString format = formatArg.toString();
return engine->newVariant(qVariantFromValue(date.toString(format)));
- } else if (ctxt->argument(1).isNumber()) {
- enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32());
+ } else if (formatArg.isNumber()) {
+ enumFormat = Qt::DateFormat(formatArg.toUInt32());
} else {
return ctxt->throwError(QLatin1String("Qt.formatDate(): Invalid date format"));
}
@@ -1298,11 +1339,12 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE
QTime date = ctxt->argument(0).toDateTime().time();
Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
if (argCount == 2) {
- if (ctxt->argument(1).isString()) {
- QString format = ctxt->argument(1).toString();
+ QScriptValue formatArg = ctxt->argument(1);
+ if (formatArg.isString()) {
+ QString format = formatArg.toString();
return engine->newVariant(qVariantFromValue(date.toString(format)));
- } else if (ctxt->argument(1).isNumber()) {
- enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32());
+ } else if (formatArg.isNumber()) {
+ enumFormat = Qt::DateFormat(formatArg.toUInt32());
} else {
return ctxt->throwError(QLatin1String("Qt.formatTime(): Invalid time format"));
}
@@ -1388,11 +1430,12 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr
QDateTime date = ctxt->argument(0).toDateTime();
Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate;
if (argCount == 2) {
- if (ctxt->argument(1).isString()) {
- QString format = ctxt->argument(1).toString();
+ QScriptValue formatArg = ctxt->argument(1);
+ if (formatArg.isString()) {
+ QString format = formatArg.toString();
return engine->newVariant(qVariantFromValue(date.toString(format)));
- } else if (ctxt->argument(1).isNumber()) {
- enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32());
+ } else if (formatArg.isNumber()) {
+ enumFormat = Qt::DateFormat(formatArg.toUInt32());
} else {
return ctxt->throwError(QLatin1String("Qt.formatDateTime(): Invalid datetime format"));
}
@@ -1740,8 +1783,7 @@ void QDeclarativeEnginePrivate::warning(QDeclarativeEnginePrivate *engine, const
/*!
\qmlmethod Qt::quit()
This function causes the QDeclarativeEngine::quit() signal to be emitted.
-Within the \l {Qt Declarative UI Runtime}{qml} application this causes the
-launcher application to exit.
+Within the \l {QML Viewer}, this causes the launcher application to exit.
*/
QScriptValue QDeclarativeEnginePrivate::quit(QScriptContext * /*ctxt*/, QScriptEngine *e)
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index f457b53..a5c8c38 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -162,7 +162,6 @@ public:
QPODVector<CapturedProperty> capturedProperties;
QDeclarativeContext *rootContext;
- QDeclarativeExpression *currentExpression;
bool isDebugging;
bool outputWarningsToStdErr;
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index 008d054..1837366 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -485,24 +485,22 @@ void QDeclarativeEngineDebugServer::setBinding(int objectId,
if (object && context) {
+ QDeclarativeProperty property(object, propertyName, context);
if (isLiteralValue) {
- QDeclarativeProperty literalProperty(object, propertyName, context);
- literalProperty.write(expression);
+ property.write(expression);
+ } else if (hasValidSignal(object, propertyName)) {
+ QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString());
+ QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression);
+ } else if (property.isProperty()) {
+ QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context);
+ binding->setTarget(property);
+ binding->setNotifyOnValueChanged(true);
+ QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding);
+ if (oldBinding)
+ oldBinding->destroy();
+ binding->update();
} else {
- if (hasValidSignal(object, propertyName)) {
- QDeclarativeProperty property(object, propertyName);
- QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString());
- QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression);
- } else {
- QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context);
- QDeclarativeProperty property(object, propertyName, context);
- binding->setTarget(property);
- binding->setNotifyOnValueChanged(true);
- QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding);
- if (oldBinding)
- oldBinding->destroy();
- binding->update();
- }
+ qWarning() << "QDeclarativeEngineDebugServer::setBinding: unable to set property" << propertyName << "on object" << object;
}
}
}
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index 8ae5f2f..9935e38 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -71,109 +71,95 @@ bool QDeclarativeDelayedError::addError(QDeclarativeEnginePrivate *e)
return true;
}
-QDeclarativeExpressionData::QDeclarativeExpressionData()
-: q(0), dataRef(0), expressionFunctionValid(false), expressionRewritten(false), me(0),
- trackChange(false), isShared(false), line(-1), guardList(0), guardListLength(0)
+QDeclarativeQtScriptExpression::QDeclarativeQtScriptExpression()
+: dataRef(0), expressionFunctionMode(ExplicitContext), scopeObject(0), trackChange(false),
+ guardList(0), guardListLength(0), guardObject(0), guardObjectNotifyIndex(-1), deleted(0)
{
}
-QDeclarativeExpressionData::~QDeclarativeExpressionData()
+QDeclarativeQtScriptExpression::~QDeclarativeQtScriptExpression()
{
if (guardList) { delete [] guardList; guardList = 0; }
if (dataRef) dataRef->release();
+ if (deleted) *deleted = true;
}
QDeclarativeExpressionPrivate::QDeclarativeExpressionPrivate()
-: data(new QDeclarativeExpressionData)
+: expressionFunctionValid(true), line(-1)
{
- data->q = this;
-}
-
-QDeclarativeExpressionPrivate::QDeclarativeExpressionPrivate(QDeclarativeExpressionData *d)
-: data(d)
-{
- data->q = this;
}
QDeclarativeExpressionPrivate::~QDeclarativeExpressionPrivate()
{
- if (data) {
- delete [] data->guardList;
- data->guardList = 0;
- data->guardListLength = 0;
- data->q = 0;
- data->release();
- data = 0;
- }
}
void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, const QString &expr,
QObject *me)
{
- data->expression = expr;
+ expression = expr;
- data->QDeclarativeAbstractExpression::setContext(ctxt);
- data->me = me;
+ QDeclarativeAbstractExpression::setContext(ctxt);
+ scopeObject = me;
+ expressionFunctionValid = false;
}
-void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, void *expr, QDeclarativeRefCount *rc,
- QObject *me, const QString &url, int lineNumber)
+void QDeclarativeExpressionPrivate::init(QDeclarativeContextData *ctxt, void *expr,
+ QDeclarativeRefCount *rc,
+ QObject *me, const QString &srcUrl, int lineNumber)
{
- data->url = url;
- data->line = lineNumber;
+ url = srcUrl;
+ line = lineNumber;
- if (data->dataRef) data->dataRef->release();
- data->dataRef = rc;
- if (data->dataRef) data->dataRef->addref();
+ if (dataRef) dataRef->release();
+ dataRef = rc;
+ if (dataRef) dataRef->addref();
quint32 *exprData = (quint32 *)expr;
QDeclarativeCompiledData *dd = (QDeclarativeCompiledData *)rc;
- data->expressionRewritten = true;
- data->expression = QString::fromRawData((QChar *)(exprData + 2), exprData[1]);
+ expression = QString::fromRawData((QChar *)(exprData + 2), exprData[1]);
int progIdx = *(exprData);
- bool isShared = progIdx & 0x80000000;
+ bool isSharedProgram = progIdx & 0x80000000;
progIdx &= 0x7FFFFFFF;
QDeclarativeEngine *engine = ctxt->engine;
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
- if (isShared) {
+ if (isSharedProgram) {
if (!dd->cachedClosures.at(progIdx)) {
QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
scriptContext->pushScope(ep->contextClass->newSharedContext());
scriptContext->pushScope(ep->globalClass->staticGlobalObject());
- dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(data->expression, data->url, data->line));
+ dd->cachedClosures[progIdx] = new QScriptValue(scriptEngine->evaluate(expression, url, line));
scriptEngine->popContext();
}
- data->expressionFunction = *dd->cachedClosures.at(progIdx);
- data->isShared = true;
- data->expressionFunctionValid = true;
+ expressionFunction = *dd->cachedClosures.at(progIdx);
+ expressionFunctionMode = SharedContext;
+ expressionFunctionValid = true;
} else {
#if !defined(Q_OS_SYMBIAN) //XXX Why doesn't this work?
if (!dd->cachedPrograms.at(progIdx)) {
- dd->cachedPrograms[progIdx] =
- new QScriptProgram(data->expression, data->url, data->line);
+ dd->cachedPrograms[progIdx] = new QScriptProgram(expression, url, line);
}
- data->expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx),
- &data->expressionContext);
+ expressionFunction = evalInObjectScope(ctxt, me, *dd->cachedPrograms.at(progIdx),
+ &expressionContext);
#else
- data->expressionFunction = evalInObjectScope(ctxt, me, data->expression,
- &data->expressionContext);
+ expressionFunction = evalInObjectScope(ctxt, me, expression, &expressionContext);
#endif
- data->expressionFunctionValid = true;
+ expressionFunctionMode = ExplicitContext;
+ expressionFunctionValid = true;
}
- data->QDeclarativeAbstractExpression::setContext(ctxt);
- data->me = me;
+ QDeclarativeAbstractExpression::setContext(ctxt);
+ scopeObject = me;
}
QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContextData *context, QObject *object,
@@ -214,10 +200,34 @@ QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContex
/*!
\class QDeclarativeExpression
- \since 4.7
+ \since 4.7
\brief The QDeclarativeExpression class evaluates JavaScript in a QML context.
+
+ For example, given a file \c main.qml like this:
+
+ \qml
+ import Qt 4.7
+
+ Item {
+ width: 200; height: 200
+ }
+ \endqml
+
+ The following code evaluates a JavaScript expression in the context of the
+ above QML:
+
+ \code
+ QDeclarativeEngine *engine = new QDeclarativeEngine;
+ QDeclarativeComponent component(engine, QUrl::fromLocalFile("main.qml"));
+
+ QObject *myObject = component.create();
+ QDeclarativeExpression *expr = new QDeclarativeExpression(engine->rootContext(), myObject, "width * 2");
+ int result = expr->evaluate().toInt(); // result = 400
+ \endcode
*/
+static int QDeclarativeExpression_notifyIdx = -1;
+
/*!
Create an invalid QDeclarativeExpression.
@@ -227,6 +237,11 @@ QScriptValue QDeclarativeExpressionPrivate::evalInObjectScope(QDeclarativeContex
QDeclarativeExpression::QDeclarativeExpression()
: QObject(*new QDeclarativeExpressionPrivate, 0)
{
+ Q_D(QDeclarativeExpression);
+
+ if (QDeclarativeExpression_notifyIdx == -1)
+ QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
+ d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
}
/*! \internal */
@@ -238,6 +253,10 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, vo
{
Q_D(QDeclarativeExpression);
d->init(ctxt, expr, rc, me, url, lineNumber);
+
+ if (QDeclarativeExpression_notifyIdx == -1)
+ QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
+ d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
}
/*!
@@ -255,6 +274,10 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt,
{
Q_D(QDeclarativeExpression);
d->init(QDeclarativeContextData::get(ctxt), expression, scope);
+
+ if (QDeclarativeExpression_notifyIdx == -1)
+ QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
+ d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
}
/*!
@@ -266,6 +289,10 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QO
{
Q_D(QDeclarativeExpression);
d->init(ctxt, expression, scope);
+
+ if (QDeclarativeExpression_notifyIdx == -1)
+ QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
+ d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
}
/*! \internal */
@@ -275,6 +302,10 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QO
{
Q_D(QDeclarativeExpression);
d->init(ctxt, expression, scope);
+
+ if (QDeclarativeExpression_notifyIdx == -1)
+ QDeclarativeExpression_notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
+ d->setNotifyObject(this, QDeclarativeExpression_notifyIdx);
}
/*!
@@ -291,7 +322,7 @@ QDeclarativeExpression::~QDeclarativeExpression()
QDeclarativeEngine *QDeclarativeExpression::engine() const
{
Q_D(const QDeclarativeExpression);
- return d->data->context()?d->data->context()->engine:0;
+ return d->context()?d->context()->engine:0;
}
/*!
@@ -301,7 +332,7 @@ QDeclarativeEngine *QDeclarativeExpression::engine() const
QDeclarativeContext *QDeclarativeExpression::context() const
{
Q_D(const QDeclarativeExpression);
- QDeclarativeContextData *data = d->data->context();
+ QDeclarativeContextData *data = d->context();
return data?data->asQDeclarativeContext():0;
}
@@ -311,7 +342,7 @@ QDeclarativeContext *QDeclarativeExpression::context() const
QString QDeclarativeExpression::expression() const
{
Q_D(const QDeclarativeExpression);
- return d->data->expression;
+ return d->expression;
}
/*!
@@ -321,12 +352,10 @@ void QDeclarativeExpression::setExpression(const QString &expression)
{
Q_D(QDeclarativeExpression);
- d->clearGuards();
-
- d->data->expression = expression;
- d->data->expressionFunctionValid = false;
- d->data->expressionRewritten = false;
- d->data->expressionFunction = QScriptValue();
+ d->resetNotifyOnChange();
+ d->expression = expression;
+ d->expressionFunctionValid = false;
+ d->expressionFunction = QScriptValue();
}
void QDeclarativeExpressionPrivate::exceptionToError(QScriptEngine *scriptEngine,
@@ -356,59 +385,108 @@ void QDeclarativeExpressionPrivate::exceptionToError(QScriptEngine *scriptEngine
}
}
-QScriptValue QDeclarativeExpressionPrivate::eval(QObject *secondaryScope, bool *isUndefined)
+bool QDeclarativeQtScriptExpression::notifyOnValueChange() const
{
- QDeclarativeExpressionData *data = this->data;
- QDeclarativeEngine *engine = data->context()->engine;
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+ return trackChange;
+}
- QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+void QDeclarativeQtScriptExpression::setNotifyOnValueChange(bool notify)
+{
+ trackChange = notify;
+ if (!notify && guardList)
+ clearGuards();
+}
- if (!data->expressionFunctionValid) {
+void QDeclarativeQtScriptExpression::resetNotifyOnChange()
+{
+ clearGuards();
+}
- QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
- data->expressionContext = ep->contextClass->newContext(data->context(), data->me);
- scriptContext->pushScope(data->expressionContext);
- scriptContext->pushScope(ep->globalClass->staticGlobalObject());
+void QDeclarativeQtScriptExpression::setNotifyObject(QObject *object, int notifyIndex)
+{
+ if (guardList) clearGuards();
+
+ if (!object || notifyIndex == -1) {
+ guardObject = 0;
+ notifyIndex = -1;
+ } else {
+ guardObject = object;
+ guardObjectNotifyIndex = notifyIndex;
+
+ }
+}
+
+QScriptValue QDeclarativeQtScriptExpression::scriptValue(QObject *secondaryScope, bool *isUndefined)
+{
+ Q_ASSERT(context() && context()->engine);
+ Q_ASSERT(!trackChange || (guardObject && guardObjectNotifyIndex != -1));
+
+ if (!expressionFunction.isValid()) {
+ if (isUndefined) *isUndefined = true;
+ return QScriptValue();
+ }
+
+ DeleteWatcher watcher(this);
+
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(context()->engine);
+
+ bool lastCaptureProperties = ep->captureProperties;
+ QPODVector<QDeclarativeEnginePrivate::CapturedProperty> lastCapturedProperties;
+ ep->captureProperties = trackChange;
+ ep->capturedProperties.copyAndClear(lastCapturedProperties);
+
+ QScriptValue value = eval(secondaryScope, isUndefined);
+
+ if (!watcher.wasDeleted() && trackChange) {
+ if (ep->capturedProperties.count() == 0) {
+
+ if (guardList) clearGuards();
- if (data->expressionRewritten) {
- data->expressionFunction = scriptEngine->evaluate(data->expression,
- data->url, data->line);
} else {
- QDeclarativeRewrite::RewriteBinding rewriteBinding;
- bool ok = true;
- const QString code = rewriteBinding(data->expression, &ok);
- if (!ok) {
- scriptEngine->popContext();
- return QScriptValue();
- }
- data->expressionFunction = scriptEngine->evaluate(code, data->url, data->line);
- }
+ updateGuards(ep->capturedProperties);
- scriptEngine->popContext();
- data->expressionFunctionValid = true;
+ }
}
+ lastCapturedProperties.copyAndClear(ep->capturedProperties);
+ ep->captureProperties = lastCaptureProperties;
+
+ return value;
+}
+
+QScriptValue QDeclarativeQtScriptExpression::eval(QObject *secondaryScope, bool *isUndefined)
+{
+ Q_ASSERT(context() && context()->engine);
+
+ DeleteWatcher watcher(this);
+
+ QDeclarativeEngine *engine = context()->engine;
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
+
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
+
QDeclarativeContextData *oldSharedContext = 0;
QObject *oldSharedScope = 0;
QObject *oldOverride = 0;
- if (data->isShared) {
+ bool isShared = (expressionFunctionMode == SharedContext);
+
+ if (isShared) {
oldSharedContext = ep->sharedContext;
oldSharedScope = ep->sharedScope;
- ep->sharedContext = data->context();
- ep->sharedScope = data->me;
+ ep->sharedContext = context();
+ ep->sharedScope = scopeObject;
} else {
- oldOverride = ep->contextClass->setOverrideObject(data->expressionContext, secondaryScope);
+ oldOverride = ep->contextClass->setOverrideObject(expressionContext, secondaryScope);
}
- QScriptValue svalue = data->expressionFunction.call();
+ QScriptValue svalue = expressionFunction.call(); // This could cause this to be deleted
- if (data->isShared) {
+ if (isShared) {
ep->sharedContext = oldSharedContext;
ep->sharedScope = oldSharedScope;
- } else {
- ep->contextClass->setOverrideObject(data->expressionContext, oldOverride);
+ } else if (!watcher.wasDeleted()) {
+ ep->contextClass->setOverrideObject(expressionContext, oldOverride);
}
if (isUndefined)
@@ -416,63 +494,134 @@ QScriptValue QDeclarativeExpressionPrivate::eval(QObject *secondaryScope, bool *
// Handle exception
if (scriptEngine->hasUncaughtException()) {
- exceptionToError(scriptEngine, data->error);
+ if (!watcher.wasDeleted())
+ QDeclarativeExpressionPrivate::exceptionToError(scriptEngine, error);
+
scriptEngine->clearExceptions();
return QScriptValue();
} else {
- data->error = QDeclarativeError();
+ if (!watcher.wasDeleted())
+ error = QDeclarativeError();
+
return svalue;
}
}
-QScriptValue QDeclarativeExpressionPrivate::scriptValue(QObject *secondaryScope, bool *isUndefined)
+void QDeclarativeQtScriptExpression::updateGuards(const QPODVector<QDeclarativeEnginePrivate::CapturedProperty> &properties)
{
- Q_Q(QDeclarativeExpression);
- Q_ASSERT(q->engine());
+ Q_ASSERT(guardObject);
+ Q_ASSERT(guardObjectNotifyIndex != -1);
- if (data->expression.isEmpty())
- return QScriptValue();
+ if (properties.count() != guardListLength) {
+ QDeclarativeNotifierEndpoint *newGuardList = new QDeclarativeNotifierEndpoint[properties.count()];
- QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(q->engine());
+ for (int ii = 0; ii < qMin(guardListLength, properties.count()); ++ii)
+ guardList[ii].copyAndClear(newGuardList[ii]);
- QDeclarativeExpression *lastCurrentExpression = ep->currentExpression;
- bool lastCaptureProperties = ep->captureProperties;
- QPODVector<QDeclarativeEnginePrivate::CapturedProperty> lastCapturedProperties;
- ep->capturedProperties.copyAndClear(lastCapturedProperties);
+ delete [] guardList;
+ guardList = newGuardList;
+ guardListLength = properties.count();
+ }
- ep->currentExpression = q;
- ep->captureProperties = data->trackChange;
+ bool outputWarningHeader = false;
+ bool noChanges = true;
+ for (int ii = 0; ii < properties.count(); ++ii) {
+ QDeclarativeNotifierEndpoint &guard = guardList[ii];
+ const QDeclarativeEnginePrivate::CapturedProperty &property = properties.at(ii);
- // This object might be deleted during the eval
- QDeclarativeExpressionData *localData = data;
- localData->addref();
+ guard.target = guardObject;
+ guard.targetMethod = guardObjectNotifyIndex;
- QScriptValue value = eval(secondaryScope, isUndefined);
+ if (property.notifier != 0) {
- ep->currentExpression = lastCurrentExpression;
- ep->captureProperties = lastCaptureProperties;
+ if (!noChanges && guard.isConnected(property.notifier)) {
+ // Nothing to do
- // Check if we were deleted
- if (localData->q) {
- if ((!data->trackChange || !ep->capturedProperties.count()) && data->guardList) {
- clearGuards();
- } else if(data->trackChange) {
- updateGuards(ep->capturedProperties);
+ } else {
+ noChanges = false;
+
+ bool existing = false;
+ for (int jj = 0; !existing && jj < ii; ++jj)
+ if (guardList[jj].isConnected(property.notifier))
+ existing = true;
+
+ if (existing) {
+ // duplicate
+ guard.disconnect();
+ } else {
+ guard.connect(property.notifier);
+ }
+ }
+
+
+ } else if (property.notifyIndex != -1) {
+
+ if (!noChanges && guard.isConnected(property.object, property.notifyIndex)) {
+ // Nothing to do
+
+ } else {
+ noChanges = false;
+
+ bool existing = false;
+ for (int jj = 0; !existing && jj < ii; ++jj)
+ if (guardList[jj].isConnected(property.object, property.notifyIndex))
+ existing = true;
+
+ if (existing) {
+ // duplicate
+ guard.disconnect();
+ } else {
+ guard.connect(property.object, property.notifyIndex);
+ }
+ }
+
+ } else {
+ if (!outputWarningHeader) {
+ outputWarningHeader = true;
+ qWarning() << "QDeclarativeExpression: Expression" << expression
+ << "depends on non-NOTIFYable properties:";
+ }
+
+ const QMetaObject *metaObj = property.object->metaObject();
+ QMetaProperty metaProp = metaObj->property(property.coreIndex);
+
+ qWarning().nospace() << " " << metaObj->className() << "::" << metaProp.name();
}
}
+}
- localData->release();
+QScriptValue QDeclarativeExpressionPrivate::scriptValue(QObject *secondaryScope, bool *isUndefined)
+{
+ if (!expressionFunctionValid) {
+ QDeclarativeEngine *engine = context()->engine;
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine);
- lastCapturedProperties.copyAndClear(ep->capturedProperties);
+ QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine);
- return value;
+ QScriptContext *scriptContext = QScriptDeclarativeClass::pushCleanContext(scriptEngine);
+ expressionContext = ep->contextClass->newContext(context(), scopeObject);
+ scriptContext->pushScope(expressionContext);
+ scriptContext->pushScope(ep->globalClass->staticGlobalObject());
+
+ QDeclarativeRewrite::RewriteBinding rewriteBinding;
+ bool ok = true;
+ const QString code = rewriteBinding(expression, &ok);
+ if (ok)
+ expressionFunction = scriptEngine->evaluate(code, url, line);
+
+ scriptEngine->popContext();
+ expressionFunctionMode = ExplicitContext;
+ expressionFunctionValid = true;
+ }
+
+ return QDeclarativeQtScriptExpression::scriptValue(secondaryScope, isUndefined);
}
QVariant QDeclarativeExpressionPrivate::value(QObject *secondaryScope, bool *isUndefined)
{
Q_Q(QDeclarativeExpression);
- if (!data || !data->context() || !data->context()->isValid()) {
+ if (!context() || !context()->isValid()) {
qWarning("QDeclarativeExpression: Attempted to evaluate an expression in an invalid context");
return QVariant();
}
@@ -504,7 +653,7 @@ value changes.
bool QDeclarativeExpression::notifyOnValueChanged() const
{
Q_D(const QDeclarativeExpression);
- return d->data->trackChange;
+ return d->notifyOnValueChange();
}
/*!
@@ -526,7 +675,7 @@ bool QDeclarativeExpression::notifyOnValueChanged() const
void QDeclarativeExpression::setNotifyOnValueChanged(bool notifyOnChange)
{
Q_D(QDeclarativeExpression);
- d->data->trackChange = notifyOnChange;
+ d->setNotifyOnValueChange(notifyOnChange);
}
/*!
@@ -536,7 +685,7 @@ void QDeclarativeExpression::setNotifyOnValueChanged(bool notifyOnChange)
QString QDeclarativeExpression::sourceFile() const
{
Q_D(const QDeclarativeExpression);
- return d->data->url;
+ return d->url;
}
/*!
@@ -546,7 +695,7 @@ QString QDeclarativeExpression::sourceFile() const
int QDeclarativeExpression::lineNumber() const
{
Q_D(const QDeclarativeExpression);
- return d->data->line;
+ return d->line;
}
/*!
@@ -556,8 +705,8 @@ int QDeclarativeExpression::lineNumber() const
void QDeclarativeExpression::setSourceLocation(const QString &url, int line)
{
Q_D(QDeclarativeExpression);
- d->data->url = url;
- d->data->line = line;
+ d->url = url;
+ d->line = line;
}
/*!
@@ -569,7 +718,7 @@ void QDeclarativeExpression::setSourceLocation(const QString &url, int line)
QObject *QDeclarativeExpression::scopeObject() const
{
Q_D(const QDeclarativeExpression);
- return d->data->me;
+ return d->scopeObject;
}
/*!
@@ -581,7 +730,7 @@ QObject *QDeclarativeExpression::scopeObject() const
bool QDeclarativeExpression::hasError() const
{
Q_D(const QDeclarativeExpression);
- return d->data->error.isValid();
+ return d->error.isValid();
}
/*!
@@ -593,7 +742,7 @@ bool QDeclarativeExpression::hasError() const
void QDeclarativeExpression::clearError()
{
Q_D(QDeclarativeExpression);
- d->data->error = QDeclarativeError();
+ d->error = QDeclarativeError();
}
/*!
@@ -606,7 +755,7 @@ void QDeclarativeExpression::clearError()
QDeclarativeError QDeclarativeExpression::error() const
{
Q_D(const QDeclarativeExpression);
- return d->data->error;
+ return d->error;
}
/*! \internal */
@@ -615,98 +764,11 @@ void QDeclarativeExpressionPrivate::_q_notify()
emitValueChanged();
}
-void QDeclarativeExpressionPrivate::clearGuards()
+void QDeclarativeQtScriptExpression::clearGuards()
{
- delete [] data->guardList;
- data->guardList = 0;
- data->guardListLength = 0;
-}
-
-void QDeclarativeExpressionPrivate::updateGuards(const QPODVector<QDeclarativeEnginePrivate::CapturedProperty> &properties)
-{
- Q_Q(QDeclarativeExpression);
-
- static int notifyIdx = -1;
- if (notifyIdx == -1)
- notifyIdx = QDeclarativeExpression::staticMetaObject.indexOfMethod("_q_notify()");
-
- if (properties.count() != data->guardListLength) {
- QDeclarativeNotifierEndpoint *newGuardList =
- new QDeclarativeNotifierEndpoint[properties.count()];
-
- for (int ii = 0; ii < qMin(data->guardListLength, properties.count()); ++ii)
- data->guardList[ii].copyAndClear(newGuardList[ii]);
-
- delete [] data->guardList;
- data->guardList = newGuardList;
- data->guardListLength = properties.count();
- }
-
- bool outputWarningHeader = false;
- bool noChanges = true;
- for (int ii = 0; ii < properties.count(); ++ii) {
- QDeclarativeNotifierEndpoint &guard = data->guardList[ii];
- const QDeclarativeEnginePrivate::CapturedProperty &property = properties.at(ii);
-
- guard.target = q;
- guard.targetMethod = notifyIdx;
-
- if (property.notifier != 0) {
-
- if (!noChanges && guard.isConnected(property.notifier)) {
- // Nothing to do
-
- } else {
- noChanges = false;
-
- bool existing = false;
- for (int jj = 0; !existing && jj < ii; ++jj)
- if (data->guardList[jj].isConnected(property.notifier))
- existing = true;
-
- if (existing) {
- // duplicate
- guard.disconnect();
- } else {
- guard.connect(property.notifier);
- }
- }
-
-
- } else if (property.notifyIndex != -1) {
-
- if (!noChanges && guard.isConnected(property.object, property.notifyIndex)) {
- // Nothing to do
-
- } else {
- noChanges = false;
-
- bool existing = false;
- for (int jj = 0; !existing && jj < ii; ++jj)
- if (data->guardList[jj].isConnected(property.object, property.notifyIndex))
- existing = true;
-
- if (existing) {
- // duplicate
- guard.disconnect();
- } else {
- guard.connect(property.object, property.notifyIndex);
- }
- }
-
- } else {
- if (!outputWarningHeader) {
- outputWarningHeader = true;
- qWarning() << "QDeclarativeExpression: Expression" << q->expression()
- << "depends on non-NOTIFYable properties:";
- }
-
- const QMetaObject *metaObj = property.object->metaObject();
- QMetaProperty metaProp = metaObj->property(property.coreIndex);
-
- qWarning().nospace() << " " << metaObj->className() << "::" << metaProp.name();
- }
- }
+ delete [] guardList;
+ guardList = 0;
+ guardListLength = 0;
}
/*!
diff --git a/src/declarative/qml/qdeclarativeexpression_p.h b/src/declarative/qml/qdeclarativeexpression_p.h
index 4ff3162..b629e20 100644
--- a/src/declarative/qml/qdeclarativeexpression_p.h
+++ b/src/declarative/qml/qdeclarativeexpression_p.h
@@ -107,56 +107,73 @@ private:
QDeclarativeDelayedError **prevError;
};
-class QDeclarativeExpressionData : public QDeclarativeAbstractExpression, public QDeclarativeDelayedError, public QDeclarativeRefCount
+class QDeclarativeQtScriptExpression : public QDeclarativeAbstractExpression,
+ public QDeclarativeDelayedError
{
public:
- QDeclarativeExpressionData();
- virtual ~QDeclarativeExpressionData();
+ enum Mode { SharedContext, ExplicitContext };
- QDeclarativeExpressionPrivate *q;
+ QDeclarativeQtScriptExpression();
+ virtual ~QDeclarativeQtScriptExpression();
QDeclarativeRefCount *dataRef;
+
QString expression;
- bool expressionFunctionValid:1;
- bool expressionRewritten:1;
+
+ Mode expressionFunctionMode;
QScriptValue expressionFunction;
- QScriptValue expressionContext;
- QObject *me;
- bool trackChange;
+ QScriptValue expressionContext; // Only used in ExplicitContext
+ QObject *scopeObject; // Only used in SharedContext
- bool isShared;
+ bool notifyOnValueChange() const;
+ void setNotifyOnValueChange(bool);
+ void resetNotifyOnChange();
+ void setNotifyObject(QObject *, int );
- QString url; // This is a QString for a reason. QUrls are slooooooow...
- int line;
+ QScriptValue scriptValue(QObject *secondaryScope, bool *isUndefined);
+
+ class DeleteWatcher {
+ public:
+ inline DeleteWatcher(QDeclarativeQtScriptExpression *data);
+ inline ~DeleteWatcher();
+ inline bool wasDeleted() const;
+ private:
+ bool *m_wasDeleted;
+ bool m_wasDeletedStorage;
+ QDeclarativeQtScriptExpression *m_d;
+ };
+
+private:
+ void clearGuards();
+ QScriptValue eval(QObject *secondaryScope, bool *isUndefined);
+ void updateGuards(const QPODVector<QDeclarativeEnginePrivate::CapturedProperty> &properties);
+
+ bool trackChange;
QDeclarativeNotifierEndpoint *guardList;
int guardListLength;
+
+ QObject *guardObject;
+ int guardObjectNotifyIndex;
+ bool *deleted;
};
class QDeclarativeExpression;
class QString;
-class QDeclarativeExpressionPrivate : public QObjectPrivate
+class QDeclarativeExpressionPrivate : public QObjectPrivate, public QDeclarativeQtScriptExpression
{
Q_DECLARE_PUBLIC(QDeclarativeExpression)
public:
QDeclarativeExpressionPrivate();
- QDeclarativeExpressionPrivate(QDeclarativeExpressionData *);
~QDeclarativeExpressionPrivate();
void init(QDeclarativeContextData *, const QString &, QObject *);
void init(QDeclarativeContextData *, void *, QDeclarativeRefCount *, QObject *, const QString &, int);
- QDeclarativeExpressionData *data;
-
QVariant value(QObject *secondaryScope = 0, bool *isUndefined = 0);
QScriptValue scriptValue(QObject *secondaryScope = 0, bool *isUndefined = 0);
- QScriptValue eval(QObject *secondaryScope, bool *isUndefined = 0);
-
- void updateGuards(const QPODVector<QDeclarativeEnginePrivate::CapturedProperty> &properties);
- void clearGuards();
-
static QDeclarativeExpressionPrivate *get(QDeclarativeExpression *expr) {
return static_cast<QDeclarativeExpressionPrivate *>(QObjectPrivate::get(expr));
}
@@ -172,8 +189,32 @@ public:
int, QScriptValue *);
static QScriptValue evalInObjectScope(QDeclarativeContextData *, QObject *, const QScriptProgram &,
QScriptValue *);
+
+ bool expressionFunctionValid:1;
+
+ QString url; // This is a QString for a reason. QUrls are slooooooow...
+ int line;
};
+QDeclarativeQtScriptExpression::DeleteWatcher::DeleteWatcher(QDeclarativeQtScriptExpression *data)
+: m_wasDeletedStorage(false), m_d(data)
+{
+ if (!m_d->deleted)
+ m_d->deleted = &m_wasDeletedStorage;
+ m_wasDeleted = m_d->deleted;
+}
+
+QDeclarativeQtScriptExpression::DeleteWatcher::~DeleteWatcher()
+{
+ if (false == *m_wasDeleted && m_wasDeleted == m_d->deleted)
+ m_d->deleted = 0;
+}
+
+bool QDeclarativeQtScriptExpression::DeleteWatcher::wasDeleted() const
+{
+ return *m_wasDeleted;
+}
+
QT_END_NAMESPACE
#endif // QDECLARATIVEEXPRESSION_P_H
diff --git a/src/declarative/qml/qdeclarativeextensionplugin.cpp b/src/declarative/qml/qdeclarativeextensionplugin.cpp
index c2e8300..448fde2 100644
--- a/src/declarative/qml/qdeclarativeextensionplugin.cpp
+++ b/src/declarative/qml/qdeclarativeextensionplugin.cpp
@@ -50,27 +50,78 @@ QT_BEGIN_NAMESPACE
\ingroup plugins
- QDeclarativeExtensionPlugin is a plugin interface that makes it
- possible to offer extensions that can be loaded dynamically into
- applications using the QDeclarativeEngine class.
-
- Writing a QML extension plugin is achieved by subclassing this
- base class, reimplementing the pure virtual registerTypes()
- function, and exporting the class using the Q_EXPORT_PLUGIN2()
- macro.
+ QDeclarativeExtensionPlugin is a plugin interface that makes it possible to
+ create QML extensions that can be loaded dynamically into QML applications.
+ These extensions allow custom QML types to be made available to the QML engine.
+
+ To write a QML extension plugin:
+
+ \list
+ \o Subclass QDeclarativeExtensionPlugin, implement registerTypes() method
+ to register types using qmlRegisterType(), and export the class using the Q_EXPORT_PLUGIN2() macro
+ \o Write an appropriate project file for the plugin
+ \o Create a \l{The qmldir file}{qmldir file} to describe the plugin
+ \endlist
QML extension plugins can be used to provide either application-specific or
library-like plugins. Library plugins should limit themselves to registering types,
as any manipulation of the engine's root context may cause conflicts
or other issues in the library user's code.
- 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/cppextensions/plugins}{plugins} example.
-
- Also see \l {How to Create Qt Plugins} for general Qt plugin documentation.
- \sa QDeclarativeEngine::importPlugin()
+ \section1 An example
+
+ Suppose there is a new \c TimeModel C++ class that should be made available
+ as a new QML element. It provides the current time through \c hour and \c minute
+ properties, like this:
+
+ \snippet examples/declarative/cppextensions/plugins/plugin.cpp 0
+ \dots
+
+ To make this class available as a QML type, create a plugin that registers
+ this type using qmlRegisterType(). For this example the plugin
+ module will be named \c com.nokia.TimeExample (as defined in the project
+ file further below).
+
+ \snippet examples/declarative/cppextensions/plugins/plugin.cpp plugin
+ \codeline
+ \snippet examples/declarative/cppextensions/plugins/plugin.cpp export
+
+ This registers the \c TimeModel class with the 1.0 version of this
+ plugin library, as a QML type called \c Time. The Q_ASSERT statement
+ ensures the module is imported correctly by any QML components that use this plugin.
+
+ The project file defines the project as a plugin library and specifies
+ it should be built into the \c com/nokia/TimeExample directory:
+
+ \code
+ TEMPLATE = lib
+ CONFIG += qt plugin
+ QT += declarative
+
+ DESTDIR = com/nokia/TimeExample
+ TARGET = qmlqtimeexampleplugin
+ ...
+ \endcode
+
+ Finally, a \l{The qmldir file}{qmldir file} is required in the \c com/nokia/TimeExample directory
+ that describes the plugin. This directory includes a \c Clock.qml file that
+ should be bundled with the plugin, so it needs to be specified in the \c qmldir
+ file:
+
+ \quotefile examples/declarative/cppextensions/plugins/com/nokia/TimeExample/qmldir
+
+ Once the project is built and installed, the new \c Time element can be
+ used by any QML component that imports the \c com.nokia.TimeExample module:
+
+ \snippet examples/declarative/cppextensions/plugins/plugins.qml 0
+
+ The full source code is available in the \l {declarative/cppextensions/plugins}{plugins example}.
+
+ The \l {Tutorial: Writing QML extensions with C++} also contains a chapter
+ on creating QML plugins.
+
+ \sa QDeclarativeEngine::importPlugin(), {How to Create Qt Plugins}
*/
/*!
@@ -97,7 +148,7 @@ QDeclarativeExtensionPlugin::QDeclarativeExtensionPlugin(QObject *parent)
}
/*!
- Destroys the plugin.
+ \internal
*/
QDeclarativeExtensionPlugin::~QDeclarativeExtensionPlugin()
{
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index e917cf6..8d81b34 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -409,7 +409,8 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(importUrl);
if (!localFileOrQrc.isEmpty()) {
QString dir = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri)));
- if (dir.isEmpty() || !QDir().exists(dir)) {
+ QFileInfo dirinfo(dir);
+ if (dir.isEmpty() || !dirinfo.exists() || !dirinfo.isDir()) {
if (errorString)
*errorString = QDeclarativeImportDatabase::tr("\"%1\": no such directory").arg(uri_arg);
return false; // local import dirs must exist
@@ -425,7 +426,8 @@ bool QDeclarativeImportsPrivate::add(const QDeclarativeDirComponents &qmldircomp
if (prefix.isEmpty()) {
// directory must at least exist for valid import
QString localFileOrQrc = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(base.resolved(QUrl(uri)));
- if (localFileOrQrc.isEmpty() || !QDir().exists(localFileOrQrc)) {
+ QFileInfo dirinfo(localFileOrQrc);
+ if (localFileOrQrc.isEmpty() || !dirinfo.exists() || !dirinfo.isDir()) {
if (errorString) {
if (localFileOrQrc.isEmpty())
*errorString = QDeclarativeImportDatabase::tr("import \"%1\" has no qmldir and no namespace").arg(uri);
diff --git a/src/declarative/qml/qdeclarativelist.cpp b/src/declarative/qml/qdeclarativelist.cpp
index 7c89672..9598d98 100644
--- a/src/declarative/qml/qdeclarativelist.cpp
+++ b/src/declarative/qml/qdeclarativelist.cpp
@@ -306,7 +306,7 @@ int QDeclarativeListReference::count() const
/*!
\class QDeclarativeListProperty
\since 4.7
-\brief The QDeclarativeListProperty class allows applications to explose list-like
+\brief The QDeclarativeListProperty class allows applications to expose list-like
properties to QML.
QML has many list properties, where more than one object value can be assigned.
diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp
index c32cab6..a5c878f 100644
--- a/src/declarative/qml/qdeclarativemetatype.cpp
+++ b/src/declarative/qml/qdeclarativemetatype.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
+#include <QtDeclarative/qdeclarativeprivate.h>
#include "private/qdeclarativemetatype_p.h"
#include "private/qdeclarativeproxymetaobject_p.h"
@@ -485,17 +486,17 @@ int QDeclarativeType::index() const
return d->m_index;
}
-int QDeclarativePrivate::registerAutoParentFunction(AutoParentFunction function)
+int registerAutoParentFunction(QDeclarativePrivate::RegisterAutoParent &autoparent)
{
QWriteLocker lock(metaTypeDataLock());
QDeclarativeMetaTypeData *data = metaTypeData();
- data->parentFunctions.append(function);
+ data->parentFunctions.append(autoparent.function);
return data->parentFunctions.count() - 1;
}
-int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterface &interface)
+int registerInterface(const QDeclarativePrivate::RegisterInterface &interface)
{
if (interface.version > 0)
qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
@@ -524,7 +525,7 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterfa
return index;
}
-int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &type)
+int registerType(const QDeclarativePrivate::RegisterType &type)
{
if (type.elementName) {
for (int ii = 0; type.elementName[ii]; ++ii) {
@@ -576,6 +577,22 @@ int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &t
}
/*
+This method is "over generalized" to allow us to (potentially) register more types of things in
+the future without adding exported symbols.
+*/
+int QDeclarativePrivate::qmlregister(RegistrationType type, void *data)
+{
+ if (type == TypeRegistration) {
+ return registerType(*reinterpret_cast<RegisterType *>(data));
+ } else if (type == InterfaceRegistration) {
+ return registerInterface(*reinterpret_cast<RegisterInterface *>(data));
+ } else if (type == AutoParentRegistration) {
+ return registerAutoParentFunction(*reinterpret_cast<RegisterAutoParent *>(data));
+ }
+ return -1;
+}
+
+/*
Have any types been registered for \a module with at least versionMajor.versionMinor, and types
for \a module with at most versionMajor.versionMinor.
@@ -1152,7 +1169,7 @@ bool QDeclarativeMetaType::copy(int type, void *data, const void *copy)
*static_cast<float *>(data) = float(0);
return true;
case QMetaType::Double:
- *static_cast<double *>(data) = double();
+ *static_cast<double *>(data) = double(0);
return true;
case QMetaType::QChar:
*static_cast<NS(QChar) *>(data) = NS(QChar)();
diff --git a/src/declarative/qml/qdeclarativemetatype_p.h b/src/declarative/qml/qdeclarativemetatype_p.h
index 4c98b6f..f410547 100644
--- a/src/declarative/qml/qdeclarativemetatype_p.h
+++ b/src/declarative/qml/qdeclarativemetatype_p.h
@@ -63,6 +63,8 @@ QT_BEGIN_NAMESPACE
class QDeclarativeType;
class QDeclarativeCustomParser;
+class QDeclarativeTypePrivate;
+
class Q_DECLARATIVE_EXPORT QDeclarativeMetaType
{
public:
@@ -103,7 +105,6 @@ public:
static QList<QDeclarativePrivate::AutoParentFunction> parentFunctions();
};
-class QDeclarativeTypePrivate;
class Q_DECLARATIVE_EXPORT QDeclarativeType
{
public:
@@ -144,11 +145,12 @@ public:
int propertyValueInterceptorCast() const;
int index() const;
+
private:
friend class QDeclarativeTypePrivate;
friend struct QDeclarativeMetaTypeData;
- friend int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterInterface &);
- friend int QDeclarativePrivate::registerType(const QDeclarativePrivate::RegisterType &);
+ friend int registerType(const QDeclarativePrivate::RegisterType &);
+ friend int registerInterface(const QDeclarativePrivate::RegisterInterface &);
QDeclarativeType(int, const QDeclarativePrivate::RegisterInterface &);
QDeclarativeType(int, const QDeclarativePrivate::RegisterType &);
~QDeclarativeType();
diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h
index cd859fe..b2d7451 100644
--- a/src/declarative/qml/qdeclarativeprivate.h
+++ b/src/declarative/qml/qdeclarativeprivate.h
@@ -42,6 +42,17 @@
#ifndef QDECLARATIVEPRIVATE_H
#define QDECLARATIVEPRIVATE_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtCore/qglobal.h>
#include <QtCore/qvariant.h>
#ifndef Q_OS_WIN
@@ -177,6 +188,9 @@ namespace QDeclarativePrivate
return AttachedPropertySelector<T, has_attachedPropertiesMethod<T, has_attachedPropertiesMember<T>::value>::value>::metaObject();
}
+ enum AutoParentResult { Parented, IncompatibleObject, IncompatibleParent };
+ typedef AutoParentResult (*AutoParentFunction)(QObject *object, QObject *parent);
+
struct RegisterType {
int version;
@@ -214,13 +228,19 @@ namespace QDeclarativePrivate
const char *iid;
};
- enum AutoParentResult { Parented, IncompatibleObject, IncompatibleParent };
- typedef AutoParentResult (*AutoParentFunction)(QObject *object, QObject *parent);
+ struct RegisterAutoParent {
+ int version;
- int Q_DECLARATIVE_EXPORT registerAutoParentFunction(AutoParentFunction);
- int Q_DECLARATIVE_EXPORT registerType(const RegisterType &);
- int Q_DECLARATIVE_EXPORT registerType(const RegisterInterface &);
+ AutoParentFunction function;
+ };
+
+ enum RegistrationType {
+ TypeRegistration = 0,
+ InterfaceRegistration = 1,
+ AutoParentRegistration = 2
+ };
+ int Q_DECLARATIVE_EXPORT qmlregister(RegistrationType, void *);
}
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp
index 219d759..4d98ca8 100644
--- a/src/declarative/qml/qdeclarativescriptparser.cpp
+++ b/src/declarative/qml/qdeclarativescriptparser.cpp
@@ -896,6 +896,14 @@ QList<QDeclarativeError> QDeclarativeScriptParser::errors() const
return _errors;
}
+static void replaceWithSpace(QString &str, int idx, int n)
+{
+ QChar *data = str.data() + idx;
+ QChar space(' ');
+ for (int ii = 0; ii < n; ++ii)
+ *data++ = space;
+}
+
/*
Searches for ".pragma <value>" declarations within \a script. Currently supported pragmas
are:
@@ -905,83 +913,48 @@ QDeclarativeParser::Object::ScriptBlock::Pragmas QDeclarativeScriptParser::extra
{
QDeclarativeParser::Object::ScriptBlock::Pragmas rv = QDeclarativeParser::Object::ScriptBlock::None;
- const QChar forwardSlash(QLatin1Char('/'));
- const QChar star(QLatin1Char('*'));
- const QChar newline(QLatin1Char('\n'));
- const QChar dot(QLatin1Char('.'));
- const QChar semicolon(QLatin1Char(';'));
- const QChar space(QLatin1Char(' '));
- const QString pragma(QLatin1String(".pragma "));
-
- const QChar *pragmaData = pragma.constData();
-
- const QChar *data = script.constData();
- const int length = script.count();
- for (int ii = 0; ii < length; ++ii) {
- const QChar &c = data[ii];
-
- if (c.isSpace())
- continue;
-
- if (c == forwardSlash) {
- ++ii;
- if (ii >= length)
- return rv;
-
- const QChar &c = data[ii];
- if (c == forwardSlash) {
- // Find next newline
- while (ii < length && data[++ii] != newline) {};
- } else if (c == star) {
- // Find next star
- while (true) {
- while (ii < length && data[++ii] != star) {};
- if (ii + 1 >= length)
- return rv;
-
- if (data[ii + 1] == forwardSlash) {
- ++ii;
- break;
- }
- }
- } else {
- return rv;
- }
- } else if (c == dot) {
- // Could be a pragma!
- if (ii + pragma.length() >= length ||
- 0 != ::memcmp(data + ii, pragmaData, sizeof(QChar) * pragma.length()))
- return rv;
+ const QString pragma(QLatin1String("pragma"));
+ const QString library(QLatin1String("library"));
- int pragmaStatementIdx = ii;
+ QDeclarativeJS::Lexer l(0);
+ l.setCode(script, 0);
- ii += pragma.length();
+ int token = l.lex();
- while (ii < length && data[ii].isSpace()) { ++ii; }
+ while (true) {
+ if (token != QDeclarativeJSGrammar::T_DOT)
+ return rv;
- int startIdx = ii;
+ int startOffset = l.tokenOffset();
+ int startLine = l.currentLineNo();
- while (ii < length && data[ii].isLetter()) { ++ii; }
+ token = l.lex();
- int endIdx = ii;
+ if (token != QDeclarativeJSGrammar::T_IDENTIFIER ||
+ l.currentLineNo() != startLine ||
+ script.mid(l.tokenOffset(), l.tokenLength()) != pragma)
+ return rv;
- if (ii != length && data[ii] != forwardSlash && !data[ii].isSpace() && data[ii] != semicolon)
- return rv;
+ token = l.lex();
- QString p(data + startIdx, endIdx - startIdx);
+ if (token != QDeclarativeJSGrammar::T_IDENTIFIER ||
+ l.currentLineNo() != startLine)
+ return rv;
- if (p == QLatin1String("library"))
- rv |= QDeclarativeParser::Object::ScriptBlock::Shared;
- else
- return rv;
+ QString pragmaValue = script.mid(l.tokenOffset(), l.tokenLength());
+ int endOffset = l.tokenLength() + l.tokenOffset();
- for (int jj = pragmaStatementIdx; jj < endIdx; ++jj) script[jj] = space;
+ token = l.lex();
+ if (l.currentLineNo() == startLine)
+ return rv;
+ if (pragmaValue == QLatin1String("library")) {
+ rv |= QDeclarativeParser::Object::ScriptBlock::Shared;
+ replaceWithSpace(script, startOffset, endOffset - startOffset);
} else {
return rv;
}
}
-
return rv;
}
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index 61e550a..98e9a58 100644
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -74,7 +74,7 @@ int qmlRegisterValueTypeEnums(const char *qmlName)
0
};
- return QDeclarativePrivate::registerType(type);
+ return QDeclarativePrivate::qmlregister(QDeclarativePrivate::TypeRegistration, &type);
}
QDeclarativeValueTypeFactory::QDeclarativeValueTypeFactory()
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index e558784..1a223d5 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -142,8 +142,8 @@ bool QDeclarativeAbstractAnimation::isRunning() const
return d->running;
}
-// the behavior connects the animation to this slot
-void QDeclarativeAbstractAnimation::behaviorControlRunningChanged(bool running)
+// the behavior calls this function
+void QDeclarativeAbstractAnimation::notifyRunningChanged(bool running)
{
Q_D(QDeclarativeAbstractAnimation);
if (d->disableUserControl && d->running != running) {
@@ -632,17 +632,18 @@ QAbstractAnimation *QDeclarativePauseAnimation::qtAnimation()
\qmlclass ColorAnimation QDeclarativeColorAnimation
\since 4.7
\inherits PropertyAnimation
- \brief The ColorAnimation element allows you to animate color changes.
+ \brief The ColorAnimation element animates changes in color values.
- ColorAnimation defines an animation to be applied when a color value
- changes.
+ ColorAnimation is a specialized PropertyAnimation that defines an
+ animation to be applied when a color value changes.
Here is a ColorAnimation applied to the \c color property of a \l Rectangle
- as a property value source:
+ as a property value source. It animates the \c color property's value from
+ its current value to a value of "red", over 1000 milliseconds:
\snippet doc/src/snippets/declarative/coloranimation.qml 0
- Like any other animation element, a NumberAnimation can be applied in a
+ Like any other animation element, a ColorAnimation can be applied in a
number of ways, including transitions, behaviors and property value
sources. The \l PropertyAnimation documentation shows a variety of methods
for creating animations.
@@ -674,11 +675,12 @@ QDeclarativeColorAnimation::~QDeclarativeColorAnimation()
/*!
\qmlproperty color ColorAnimation::from
- This property holds the starting color.
+ This property holds the color value at which the animation should begin.
For example, the following animation is not applied until a color value
has reached "#c0c0c0":
+ \qml
Item {
states: [ ... ]
@@ -686,6 +688,11 @@ QDeclarativeColorAnimation::~QDeclarativeColorAnimation()
NumberAnimation { from: "#c0c0c0"; duration: 2000 }
}
}
+ \endqml
+
+ If this value is not set and the ColorAnimation is defined within
+ a \l Transition, it defaults to the value defined in the starting
+ state of the \l Transition.
*/
QColor QDeclarativeColorAnimation::from() const
{
@@ -700,7 +707,12 @@ void QDeclarativeColorAnimation::setFrom(const QColor &f)
/*!
\qmlproperty color ColorAnimation::to
- This property holds the ending color.
+
+ This property holds the color value at which the animation should end.
+
+ If this value is not set and the ColorAnimation is defined within
+ a \l Transition or \l Behavior, it defaults to the value defined in the end
+ state of the \l Transition or \l Behavior.
*/
QColor QDeclarativeColorAnimation::to() const
{
@@ -869,18 +881,27 @@ QAbstractAnimation *QDeclarativeScriptAction::qtAnimation()
\inherits Animation
\brief The PropertyAction element allows immediate property changes during animation.
- Explicitly set \c theimage.smooth=true during a transition:
+ PropertyAction is used to specify an immediate property change
+ during an animation. The property change is not animated.
+
+ For example, to explicitly set \c {theImage.smooth = true} during a \l Transition:
\code
- PropertyAction { target: theimage; property: "smooth"; value: true }
+ transitions: Transition {
+ ...
+ PropertyAction { target: theImage; property: "smooth"; value: true }
+ ...
+ }
\endcode
- Set \c thewebview.url to the value set for the destination state:
+ Or, to set \c theWebView.url to the value set for the destination state:
\code
- PropertyAction { target: thewebview; property: "url" }
+ transitions: Transition {
+ ...
+ PropertyAction { target: theWebView; property: "url" }
+ ...
+ }
\endcode
- The PropertyAction is immediate -
- the target property is not animated to the selected value in any way.
\sa QtDeclarative
*/
@@ -906,14 +927,6 @@ void QDeclarativePropertyActionPrivate::init()
QDeclarative_setParent_noEvent(spa, q);
}
-/*!
- \qmlproperty Object PropertyAction::target
- This property holds an explicit target object to animate.
-
- The exact effect of the \c target property depends on how the animation
- is being used. Refer to the \l {QML Animation} documentation for details.
-*/
-
QObject *QDeclarativePropertyAction::target() const
{
Q_D(const QDeclarativePropertyAction);
@@ -945,12 +958,12 @@ void QDeclarativePropertyAction::setProperty(const QString &n)
}
/*!
+ \qmlproperty Object PropertyAction::target
\qmlproperty list<Object> PropertyAction::targets
\qmlproperty string PropertyAction::property
\qmlproperty string PropertyAction::properties
- \qmlproperty Object PropertyAction::target
- These properties are used as a set to determine which properties should be
+ These properties determine the items and their properties that are
affected by this action.
The details of how these properties are interpreted in different situations
@@ -982,7 +995,7 @@ QDeclarativeListProperty<QObject> QDeclarativePropertyAction::targets()
/*!
\qmlproperty list<Object> PropertyAction::exclude
- This property holds the objects not to be affected by this animation.
+ This property holds the objects that should not be affected by this action.
\sa targets
*/
@@ -1117,13 +1130,14 @@ void QDeclarativePropertyAction::transition(QDeclarativeStateActions &actions,
\qmlclass NumberAnimation QDeclarativeNumberAnimation
\since 4.7
\inherits PropertyAnimation
- \brief The NumberAnimation element allows you to animate changes in properties of type qreal.
+ \brief The NumberAnimation element animates changes in qreal-type values.
- NumberAnimation defines an animation to be applied when a numerical value
- changes.
+ NumberAnimation is a specialized PropertyAnimation that defines an
+ animation to be applied when a numerical value changes.
Here is a NumberAnimation applied to the \c x property of a \l Rectangle
- as a property value source:
+ as a property value source. It animates the \c x value from its current
+ value to a value of 50, over 1000 milliseconds:
\snippet doc/src/snippets/declarative/numberanimation.qml 0
@@ -1174,6 +1188,7 @@ void QDeclarativeNumberAnimation::init()
For example, the following animation is not applied until the \c x value
has reached 100:
+ \qml
Item {
states: [ ... ]
@@ -1181,8 +1196,10 @@ void QDeclarativeNumberAnimation::init()
NumberAnimation { properties: "x"; from: 100; duration: 200 }
}
}
+ \endqml
- If this value is not set, it defaults to the value defined in the start
+ If this value is not set and the NumberAnimation is defined within
+ a \l Transition, it defaults to the value defined in the start
state of the \l Transition.
*/
@@ -1201,7 +1218,8 @@ void QDeclarativeNumberAnimation::setFrom(qreal f)
\qmlproperty real NumberAnimation::to
This property holds the ending number value.
- If this value is not set, it defaults to the value defined in the end
+ If this value is not set and the NumberAnimation is defined within
+ a \l Transition or \l Behavior, it defaults to the value defined in the end
state of the \l Transition or \l Behavior.
*/
qreal QDeclarativeNumberAnimation::to() const
@@ -1221,7 +1239,10 @@ void QDeclarativeNumberAnimation::setTo(qreal t)
\qmlclass Vector3dAnimation QDeclarativeVector3dAnimation
\since 4.7
\inherits PropertyAnimation
- \brief The Vector3dAnimation element allows you to animate changes in properties of type QVector3d.
+ \brief The Vector3dAnimation element animates changes in QVector3d values.
+
+ Vector3dAnimation is a specialized PropertyAnimation that defines an
+ animation to be applied when a Vector3d value changes.
\sa {QML Animation}, {declarative/animation/basics}{Animation basics example}
*/
@@ -1286,31 +1307,32 @@ void QDeclarativeVector3dAnimation::setTo(QVector3D t)
\qmlclass RotationAnimation QDeclarativeRotationAnimation
\since 4.7
\inherits PropertyAnimation
- \brief The RotationAnimation element allows you to animate rotations.
+ \brief The RotationAnimation element animates changes in rotation values.
RotationAnimation is a specialized PropertyAnimation that gives control
- over the direction of rotation. By default, it will rotate in the direction
+ over the direction of rotation during an animation.
+
+ By default, it rotates in the direction
of the numerical change; a rotation from 0 to 240 will rotate 220 degrees
clockwise, while a rotation from 240 to 0 will rotate 220 degrees
- counterclockwise.
+ counterclockwise. The \l direction property can be set to specify the
+ direction in which the rotation should occur.
+
+ In the following example we use RotationAnimation to animate the rotation
+ between states via the shortest path:
- When used in a transition RotationAnimation will rotate all
+ \snippet doc/src/snippets/declarative/rotationanimation.qml 0
+
+ Notice the RotationAnimation did not need to set a \l {RotationAnimation::}{target}
+ value. As a convenience, when used in a transition, RotationAnimation will rotate all
properties named "rotation" or "angle". You can override this by providing
your own properties via \l {PropertyAnimation::properties}{properties} or
\l {PropertyAnimation::property}{property}.
- In the following example we use RotationAnimation to animate the rotation
- between states via the shortest path.
- \qml
- states: {
- State { name: "180"; PropertyChanges { target: myItem; rotation: 180 } }
- State { name: "90"; PropertyChanges { target: myItem; rotation: 90 } }
- State { name: "-90"; PropertyChanges { target: myItem; rotation: -90 } }
- }
- transition: Transition {
- RotationAnimation { direction: RotationAnimation.Shortest }
- }
- \endqml
+ Like any other animation element, a RotationAnimation can be applied in a
+ number of ways, including transitions, behaviors and property value
+ sources. The \l PropertyAnimation documentation shows a variety of methods
+ for creating animations.
\sa {QML Animation}, {declarative/animation/basics}{Animation basics example}
*/
@@ -1377,6 +1399,7 @@ QDeclarativeRotationAnimation::~QDeclarativeRotationAnimation()
For example, the following animation is not applied until the \c angle value
has reached 100:
+ \qml
Item {
states: [ ... ]
@@ -1384,6 +1407,7 @@ QDeclarativeRotationAnimation::~QDeclarativeRotationAnimation()
RotationAnimation { properties: "angle"; from: 100; duration: 2000 }
}
}
+ \endqml
If this value is not set, it defaults to the value defined in the start
state of the \l Transition.
@@ -1419,7 +1443,7 @@ void QDeclarativeRotationAnimation::setTo(qreal t)
/*!
\qmlproperty enumeration RotationAnimation::direction
- The direction in which to rotate.
+ This property holds the direction of the rotation.
Possible values are:
@@ -1512,19 +1536,26 @@ QDeclarativeListProperty<QDeclarativeAbstractAnimation> QDeclarativeAnimationGro
\qmlclass SequentialAnimation QDeclarativeSequentialAnimation
\since 4.7
\inherits Animation
- \brief The SequentialAnimation element allows you to run animations sequentially.
+ \brief The SequentialAnimation element allows animations to be run sequentially.
- Animations controlled in SequentialAnimation will be run one after the other.
+ The SequentialAnimation and ParallelAnimation elements allow multiple
+ animations to be run together. Animations defined in a SequentialAnimation
+ are run one after the other, while animations defined in a ParallelAnimation
+ are run at the same time.
- The following example chains two numeric animations together. The \c MyItem
- object will animate from its current x position to 100, and then back to 0.
+ The following example runs two number animations in a sequence. The \l Rectangle
+ animates to a \c x position of 50, then to a \c y position of 50.
- \code
- SequentialAnimation {
- NumberAnimation { target: MyItem; property: "x"; to: 100 }
- NumberAnimation { target: MyItem; property: "x"; to: 0 }
- }
- \endcode
+ \snippet doc/src/snippets/declarative/sequentialanimation.qml 0
+
+ Animations defined within a \l Transition are automatically run in parallel,
+ so SequentialAnimation can be used to enclose the animations in a \l Transition
+ if this is the preferred behavior.
+
+ Like any other animation element, a SequentialAnimation can be applied in a
+ number of ways, including transitions, behaviors and property value
+ sources. The \l PropertyAnimation documentation shows a variety of methods
+ for creating animations.
\sa ParallelAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example}
*/
@@ -1574,19 +1605,22 @@ void QDeclarativeSequentialAnimation::transition(QDeclarativeStateActions &actio
\qmlclass ParallelAnimation QDeclarativeParallelAnimation
\since 4.7
\inherits Animation
- \brief The ParallelAnimation element allows you to run animations in parallel.
+ \brief The ParallelAnimation element allows animations to be run in parallel.
- Animations contained in ParallelAnimation will be run at the same time.
+ The SequentialAnimation and ParallelAnimation elements allow multiple
+ animations to be run together. Animations defined in a SequentialAnimation
+ are run one after the other, while animations defined in a ParallelAnimation
+ are run at the same time.
- The following animation demonstrates animating the \c MyItem item
- to (100,100) by animating the x and y properties in parallel.
+ The following animation runs two number animations in parallel. The \l Rectangle
+ moves to (50,50) by animating its \c x and \c y properties at the same time.
- \code
- ParallelAnimation {
- NumberAnimation { target: MyItem; property: "x"; to: 100 }
- NumberAnimation { target: MyItem; property: "y"; to: 100 }
- }
- \endcode
+ \snippet doc/src/snippets/declarative/parallelanimation.qml 0
+
+ Like any other animation element, a ParallelAnimation can be applied in a
+ number of ways, including transitions, behaviors and property value
+ sources. The \l PropertyAnimation documentation shows a variety of methods
+ for creating animations.
\sa SequentialAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example}
*/
@@ -1685,7 +1719,7 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
\qmlclass PropertyAnimation QDeclarativePropertyAnimation
\since 4.7
\inherits Animation
- \brief The PropertyAnimation element allows you to animate property changes.
+ \brief The PropertyAnimation element animates changes in property values.
PropertyAnimation provides a way to animate changes to a property's value.
@@ -1736,6 +1770,9 @@ void QDeclarativePropertyAnimationPrivate::convertVariant(QVariant &variant, int
different. For more information see the individual property documentation, as well
as the \l{QML Animation} introduction.
+ Note that PropertyAnimation inherits the abstract \l Animation element.
+ This includes additional properties and methods for controlling the animation.
+
\sa {QML Animation}, {declarative/animation/basics}{Animation basics example}
*/
@@ -2034,17 +2071,16 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t)
QEasingCurve QDeclarativePropertyAnimation::easing() const
{
Q_D(const QDeclarativePropertyAnimation);
- return d->easing;
+ return d->va->easingCurve();
}
void QDeclarativePropertyAnimation::setEasing(const QEasingCurve &e)
{
Q_D(QDeclarativePropertyAnimation);
- if (d->easing == e)
+ if (d->va->easingCurve() == e)
return;
- d->easing = e;
- d->va->setEasingCurve(d->easing);
+ d->va->setEasingCurve(e);
emit easingChanged(e);
}
@@ -2350,43 +2386,30 @@ void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions
\qmlclass ParentAnimation QDeclarativeParentAnimation
\since 4.7
\inherits Animation
- \brief The ParentAnimation element allows you to animate parent changes.
+ \brief The ParentAnimation element animates changes in parent values.
- ParentAnimation is used in conjunction with NumberAnimation to smoothly
- animate changing an item's parent. In the following example,
- ParentAnimation wraps a NumberAnimation which animates from the
- current position in the old parent to the new position in the new
- parent.
+ ParentAnimation defines an animation to applied when a ParentChange
+ occurs. This allows parent changes to be smoothly animated.
- \qml
- ...
- State {
- //reparent myItem to newParent. myItem's final location
- //should be 10,10 in newParent.
- ParentChange {
- target: myItem
- parent: newParent
- x: 10; y: 10
- }
- }
- ...
- Transition {
- //smoothly reparent myItem and move into new position
- ParentAnimation {
- target: theItem
- NumberAnimation { properties: "x,y" }
- }
- }
- \endqml
+ For example, the following ParentChange changes \c blueRect to become
+ a child of \c redRect when it is clicked. The inclusion of the
+ ParentAnimation, which defines a NumberAnimation to be applied during
+ the transition, ensures the item animates smoothly as it moves to
+ its new parent:
+
+ \snippet doc/src/snippets/declarative/parentanimation.qml 0
- ParentAnimation can wrap any number of animations -- those animations will
- be run in parallel (like those in a ParallelAnimation group).
+ A ParentAnimation can contain any number of animations. These animations will
+ be run in parallel; to run them sequentially, define them within a
+ SequentialAnimation.
- In some cases, such as reparenting between items with clipping, it's useful
- to animate the parent change via another item with no clipping.
+ In some cases, such as when reparenting between items with clipping enabled, it is useful
+ to animate the parent change via another item that does not have clipping
+ enabled. Such an item can be set using the \l via property.
- When used in a transition, ParentAnimation will by default animate
- all ParentChanges.
+ By default, when used in a transition, ParentAnimation animates all parent
+ changes. This can be overriden by setting a specific target item using the
+ \l target property.
\sa {QML Animation}, {declarative/animation/basics}{Animation basics example}
*/
@@ -2423,8 +2446,8 @@ QDeclarativeParentAnimation::~QDeclarativeParentAnimation()
\qmlproperty Item ParentAnimation::target
The item to reparent.
- When used in a transition, if no target is specified all
- ParentChanges will be animated by the ParentAnimation.
+ When used in a transition, if no target is specified, all
+ ParentChange occurrences are animated by the ParentAnimation.
*/
QDeclarativeItem *QDeclarativeParentAnimation::target() const
{
@@ -2467,7 +2490,7 @@ void QDeclarativeParentAnimation::setNewParent(QDeclarativeItem *newParent)
/*!
\qmlproperty Item ParentAnimation::via
The item to reparent via. This provides a way to do an unclipped animation
- when both the old parent and new parent are clipped
+ when both the old parent and new parent are clipped.
\qml
ParentAnimation {
@@ -2717,28 +2740,14 @@ QAbstractAnimation *QDeclarativeParentAnimation::qtAnimation()
\qmlclass AnchorAnimation QDeclarativeAnchorAnimation
\since 4.7
\inherits Animation
- \brief The AnchorAnimation element allows you to animate anchor changes.
+ \brief The AnchorAnimation element animates changes in anchor values.
- AnchorAnimation will animated any changes specified by a state's AnchorChanges.
- In the following snippet we animate the addition of a right anchor to our item.
- \qml
- Item {
- id: myItem
- width: 100
- }
- ...
- State {
- AnchorChanges {
- target: myItem
- anchors.right: container.right
- }
- }
- ...
- Transition {
- //smoothly reanchor myItem and move into new position
- AnchorAnimation {}
- }
- \endqml
+ AnchorAnimation is used to animate an AnchorChange. It will anchor all
+ anchor changes specified in a \l State.
+
+ In the following snippet we animate the addition of a right anchor to a \l Rectangle:
+
+ \snippet doc/src/snippets/declarative/anchoranimation.qml 0
\sa AnchorChanges
*/
diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h
index 2279b0e..59bd465 100644
--- a/src/declarative/util/qdeclarativeanimation_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p.h
@@ -134,10 +134,12 @@ public:
private Q_SLOTS:
void timelineComplete();
void componentFinalized();
- void behaviorControlRunningChanged(bool running);
-
private:
virtual void setTarget(const QDeclarativeProperty &);
+ void notifyRunningChanged(bool running);
+ friend class QDeclarativeBehavior;
+
+
};
class QDeclarativePauseAnimationPrivate;
diff --git a/src/declarative/util/qdeclarativeanimation_p_p.h b/src/declarative/util/qdeclarativeanimation_p_p.h
index b6d6bbb..e38580c 100644
--- a/src/declarative/util/qdeclarativeanimation_p_p.h
+++ b/src/declarative/util/qdeclarativeanimation_p_p.h
@@ -311,8 +311,6 @@ public:
QVariant from;
QVariant to;
- QEasingCurve easing;
-
QObject *target;
QString propertyName;
QString properties;
diff --git a/src/declarative/util/qdeclarativebehavior.cpp b/src/declarative/util/qdeclarativebehavior.cpp
index 525df30..fadb2ae 100644
--- a/src/declarative/util/qdeclarativebehavior.cpp
+++ b/src/declarative/util/qdeclarativebehavior.cpp
@@ -75,28 +75,21 @@ public:
\since 4.7
\brief The Behavior element allows you to specify a default animation for a property change.
- Behaviors provide one way to specify \l{qdeclarativeanimation.html}{animations} in QML.
-
- In the example below, the rectangle will use a bounce easing curve over 200 millisecond for any changes to its y property:
- \code
- Rectangle {
- width: 20; height: 20
- color: "#00ff00"
- y: 200 // initial value
- Behavior on y {
- NumberAnimation {
- easing.type: Easing.OutBounce
- easing.amplitude: 100
- duration: 200
- }
- }
- }
- \endcode
+ A Behavior defines the default animation to be applied whenever a
+ particular property value changes.
+
+ For example, the following Behavior defines a NumberAnimation to be run
+ whenever the \l Rectangle's \c width value changes. When the MouseArea
+ is clicked, the \c width is changed, triggering the behavior's animation:
+
+ \snippet doc/src/snippets/declarative/behavior.qml 0
- Currently only a single Behavior may be specified for a property;
- this Behavior can be enabled and disabled via the \l{enabled} property.
+ To run multiple animations within a Behavior, use ParallelAnimation or
+ SequentialAnimation.
- \sa {declarative/animation/behaviors}{Behavior example}, QtDeclarative
+ Note that a property cannot have more than one assigned Behavior.
+
+ \sa {Property Behaviors}, {declarative/animation/behaviors}{Behavior example}, QtDeclarative
*/
@@ -113,7 +106,7 @@ QDeclarativeBehavior::~QDeclarativeBehavior()
\qmlproperty Animation Behavior::animation
\default
- The animation to use when the behavior is triggered.
+ This property holds the animation to run when the behavior is triggered.
*/
QDeclarativeAbstractAnimation *QDeclarativeBehavior::animation()
@@ -138,10 +131,6 @@ void QDeclarativeBehavior::setAnimation(QDeclarativeAbstractAnimation *animation
SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)),
this,
SLOT(qtAnimationStateChanged(QAbstractAnimation::State,QAbstractAnimation::State)));
- connect(this,
- SIGNAL(qtAnimationRunningChanged(bool)),
- d->animation,
- SLOT(behaviorControlRunningChanged(bool)));
}
}
@@ -150,13 +139,15 @@ void QDeclarativeBehavior::qtAnimationStateChanged(QAbstractAnimation::State new
{
Q_D(QDeclarativeBehavior);
if (!d->blockRunningChanged)
- emit qtAnimationRunningChanged(newState == QAbstractAnimation::Running);
+ d->animation->notifyRunningChanged(newState == QAbstractAnimation::Running);
}
/*!
\qmlproperty bool Behavior::enabled
- Whether the Behavior will be triggered when the property it is tracking changes.
+
+ This property holds whether the behavior will be triggered when the tracked
+ property changes value.
By default a Behavior is enabled.
*/
diff --git a/src/declarative/util/qdeclarativebehavior_p.h b/src/declarative/util/qdeclarativebehavior_p.h
index a3132d9..9801fb2 100644
--- a/src/declarative/util/qdeclarativebehavior_p.h
+++ b/src/declarative/util/qdeclarativebehavior_p.h
@@ -83,7 +83,6 @@ public:
Q_SIGNALS:
void enabledChanged();
- void qtAnimationRunningChanged(bool running);
private Q_SLOTS:
void componentFinalized();
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index deb835d..3ede335 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -1022,6 +1022,8 @@ QVariant NestedListModel::data(int index, int role) const
Q_ASSERT(_root && index >= 0 && index < _root->values.count());
checkRoles();
QVariant rv;
+ if (roleStrings.count() < role)
+ return rv;
ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index));
if (!node)
diff --git a/src/declarative/util/qdeclarativepackage.cpp b/src/declarative/util/qdeclarativepackage.cpp
index 1e49ad9..1a4f2a7 100644
--- a/src/declarative/util/qdeclarativepackage.cpp
+++ b/src/declarative/util/qdeclarativepackage.cpp
@@ -65,12 +65,12 @@ QT_BEGIN_NAMESPACE
\snippet examples/declarative/modelviews/package/Delegate.qml 0
These named items are used as the delegates by the two views who
- reference the special VisualDataModel.parts property to select
+ reference the special \l{VisualDataModel::parts} property to select
a model which provides the chosen delegate.
\snippet examples/declarative/modelviews/package/view.qml 0
- \sa {declarative/modelviews/package}{Package example}, QtDeclarative
+ \sa {declarative/modelviews/package}{Package example}, {demos/declarative/photoviewer}{Photo Viewer demo}, QtDeclarative
*/
/*!
diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp
index f729ced..a83cac8 100644
--- a/src/declarative/util/qdeclarativepixmapcache.cpp
+++ b/src/declarative/util/qdeclarativepixmapcache.cpp
@@ -114,6 +114,18 @@ public:
static int downloadProgressIndex;
};
+class QDeclarativePixmapReaderThreadObject : public QObject {
+ Q_OBJECT
+public:
+ QDeclarativePixmapReaderThreadObject(QDeclarativePixmapReader *);
+ void processJobs();
+ virtual bool event(QEvent *e);
+private slots:
+ void networkRequestDone();
+private:
+ QDeclarativePixmapReader *reader;
+};
+
class QDeclarativePixmapData;
class QDeclarativePixmapReader : public QThread
{
@@ -130,12 +142,11 @@ public:
protected:
void run();
-private slots:
- void networkRequestDone();
-
private:
+ friend class QDeclarativePixmapReaderThreadObject;
void processJobs();
void processJob(QDeclarativePixmapReply *);
+ void networkRequestDone(QNetworkReply *);
QList<QDeclarativePixmapReply*> jobs;
QList<QDeclarativePixmapReply*> cancelled;
@@ -143,14 +154,7 @@ private:
QObject *eventLoopQuitHack;
QMutex mutex;
- class ThreadObject : public QObject {
- public:
- ThreadObject(QDeclarativePixmapReader *);
- void processJobs();
- virtual bool event(QEvent *e);
- private:
- QDeclarativePixmapReader *reader;
- } *threadObject;
+ QDeclarativePixmapReaderThreadObject *threadObject;
QWaitCondition waitCondition;
QNetworkAccessManager *networkAccessManager();
@@ -161,7 +165,7 @@ private:
static int replyDownloadProgress;
static int replyFinished;
static int downloadProgress;
- static int thisNetworkRequestDone;
+ static int threadNetworkRequestDone;
static QHash<QDeclarativeEngine *,QDeclarativePixmapReader*> readers;
static QMutex readerMutex;
};
@@ -232,7 +236,7 @@ QMutex QDeclarativePixmapReader::readerMutex;
int QDeclarativePixmapReader::replyDownloadProgress = -1;
int QDeclarativePixmapReader::replyFinished = -1;
int QDeclarativePixmapReader::downloadProgress = -1;
-int QDeclarativePixmapReader::thisNetworkRequestDone = -1;
+int QDeclarativePixmapReader::threadNetworkRequestDone = -1;
void QDeclarativePixmapReply::postReply(ReadError error, const QString &errorString,
@@ -317,9 +321,8 @@ QDeclarativePixmapReader::~QDeclarativePixmapReader()
wait();
}
-void QDeclarativePixmapReader::networkRequestDone()
+void QDeclarativePixmapReader::networkRequestDone(QNetworkReply *reply)
{
- QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
QDeclarativePixmapReply *job = replies.take(reply);
if (job) {
@@ -335,7 +338,7 @@ void QDeclarativePixmapReader::networkRequestDone()
reply = networkAccessManager()->get(req);
QMetaObject::connect(reply, replyDownloadProgress, job, downloadProgress);
- QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone);
+ QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone);
replies.insert(reply, job);
return;
@@ -368,17 +371,17 @@ void QDeclarativePixmapReader::networkRequestDone()
threadObject->processJobs();
}
-QDeclarativePixmapReader::ThreadObject::ThreadObject(QDeclarativePixmapReader *i)
+QDeclarativePixmapReaderThreadObject::QDeclarativePixmapReaderThreadObject(QDeclarativePixmapReader *i)
: reader(i)
{
}
-void QDeclarativePixmapReader::ThreadObject::processJobs()
+void QDeclarativePixmapReaderThreadObject::processJobs()
{
QCoreApplication::postEvent(this, new QEvent(QEvent::User));
}
-bool QDeclarativePixmapReader::ThreadObject::event(QEvent *e)
+bool QDeclarativePixmapReaderThreadObject::event(QEvent *e)
{
if (e->type() == QEvent::User) {
reader->processJobs();
@@ -388,6 +391,12 @@ bool QDeclarativePixmapReader::ThreadObject::event(QEvent *e)
}
}
+void QDeclarativePixmapReaderThreadObject::networkRequestDone()
+{
+ QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
+ reader->networkRequestDone(reply);
+}
+
void QDeclarativePixmapReader::processJobs()
{
QMutexLocker locker(&mutex);
@@ -469,7 +478,7 @@ void QDeclarativePixmapReader::processJob(QDeclarativePixmapReply *runningJob)
QNetworkReply *reply = networkAccessManager()->get(req);
QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress);
- QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone);
+ QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone);
replies.insert(reply, runningJob);
}
@@ -520,15 +529,15 @@ void QDeclarativePixmapReader::run()
if (replyDownloadProgress == -1) {
const QMetaObject *nr = &QNetworkReply::staticMetaObject;
const QMetaObject *pr = &QDeclarativePixmapReply::staticMetaObject;
- const QMetaObject *ir = &QDeclarativePixmapReader::staticMetaObject;
+ const QMetaObject *ir = &QDeclarativePixmapReaderThreadObject::staticMetaObject;
replyDownloadProgress = nr->indexOfSignal("downloadProgress(qint64,qint64)");
replyFinished = nr->indexOfSignal("finished()");
downloadProgress = pr->indexOfSignal("downloadProgress(qint64,qint64)");
- thisNetworkRequestDone = ir->indexOfSlot("networkRequestDone()");
+ threadNetworkRequestDone = ir->indexOfSlot("networkRequestDone()");
}
mutex.lock();
- threadObject = new ThreadObject(this);
+ threadObject = new QDeclarativePixmapReaderThreadObject(this);
mutex.unlock();
processJobs();
@@ -605,7 +614,7 @@ void QDeclarativePixmapStore::unreferencePixmap(QDeclarativePixmapData *data)
m_unreferencedCost += data->cost();
if (m_timerId == -1)
- startTimer(CACHE_EXPIRE_TIME * 1000);
+ m_timerId = startTimer(CACHE_EXPIRE_TIME * 1000);
}
void QDeclarativePixmapStore::referencePixmap(QDeclarativePixmapData *data)
@@ -952,10 +961,9 @@ void QDeclarativePixmap::load(QDeclarativeEngine *engine, const QUrl &url, const
if (iter == store->m_cache.end()) {
if (async) {
+ // pixmaps can only be loaded synchronously
if (url.scheme() == QLatin1String("image")
&& QDeclarativeEnginePrivate::get(engine)->getImageProviderType(url) == QDeclarativeImageProvider::Pixmap) {
- qWarning().nospace() << "Pixmaps must be loaded synchronously, ignoring asynchronous property for Image with source: "
- << url.toString();
async = false;
}
}
diff --git a/src/declarative/util/qdeclarativesmoothedanimation.cpp b/src/declarative/util/qdeclarativesmoothedanimation.cpp
index e0d1097..11c3d4b 100644
--- a/src/declarative/util/qdeclarativesmoothedanimation.cpp
+++ b/src/declarative/util/qdeclarativesmoothedanimation.cpp
@@ -253,15 +253,22 @@ void QSmoothedAnimation::init()
\inherits NumberAnimation
\brief The SmoothedAnimation element allows a property to smoothly track a value.
- The SmoothedAnimation animates a property's value to a set target value
- using an ease in/out quad easing curve. If the animation is restarted
- with a different target value, the easing curves used to animate to the old
- and the new target values are smoothly spliced together to avoid any obvious
- visual glitches by maintaining the current velocity.
-
- The property animation is configured by setting the velocity at which the
- animation should occur, or the duration that the animation should take.
- If both a velocity and a duration are specified, the one that results in
+ A SmoothedAnimation animates a property's value to a set target value
+ using an ease in/out quad easing curve. When the target value changes,
+ the easing curves used to animate between the old and new target values
+ are smoothly spliced together to create a smooth movement to the new
+ target value that maintains the current velocity.
+
+ The follow example shows one \l Rectangle tracking the position of another
+ using SmoothedAnimation. The green rectangle's \c x and \c y values are
+ bound to those of the red rectangle. Whenever these values change, the
+ green rectangle smoothly animates to its new position:
+
+ \snippet doc/src/snippets/declarative/smoothedanimation.qml 0
+
+ A SmoothedAnimation can be configured by setting the \l velocity at which the
+ animation should occur, or the \l duration that the animation should take.
+ If both the \l velocity and \l duration are specified, the one that results in
the quickest animation is chosen for each change in the target value.
For example, animating from 0 to 800 will take 4 seconds if a velocity
@@ -271,10 +278,6 @@ void QSmoothedAnimation::init()
will take 8 seconds with a duration of 8000 set, and will take 8 seconds
with both a velocity of 200 and a duration of 8000 set.
- The follow example shows one rectangle tracking the position of another.
-
- \snippet doc/src/snippets/declarative/smoothedanimation.qml 0
-
The default velocity of SmoothedAnimation is 200 units/second. Note that if the range of the
value being animated is small, then the velocity will need to be adjusted
appropriately. For example, the opacity of an item ranges from 0 - 1.0.
@@ -287,7 +290,7 @@ void QSmoothedAnimation::init()
sources. The \l PropertyAnimation documentation shows a variety of methods
for creating animations.
- \sa {QML Animation}, {declarative/animation/basics}{Animation basics example}
+ \sa SpringAnimation, NumberAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example}
*/
QDeclarativeSmoothedAnimation::QDeclarativeSmoothedAnimation(QObject *parent)
diff --git a/src/declarative/util/qdeclarativespringanimation.cpp b/src/declarative/util/qdeclarativespringanimation.cpp
index be0af6d..8ce4832 100644
--- a/src/declarative/util/qdeclarativespringanimation.cpp
+++ b/src/declarative/util/qdeclarativespringanimation.cpp
@@ -215,7 +215,9 @@ void QDeclarativeSpringAnimationPrivate::updateMode()
You can also limit the maximum \l velocity of the animation.
The following \l Rectangle moves to the position of the mouse using a
- SpringAnimation when the mouse is clicked:
+ SpringAnimation when the mouse is clicked. The use of the \l Behavior
+ on the \c x and \c y values indicates that whenever these values are
+ changed, a SpringAnimation should be applied.
\snippet doc/src/snippets/declarative/springanimation.qml 0
@@ -224,7 +226,7 @@ void QDeclarativeSpringAnimationPrivate::updateMode()
sources. The \l PropertyAnimation documentation shows a variety of methods
for creating animations.
- \sa {QML Animation}, {declarative/animation/basics}{Animation basics example}, {declarative/toys/clocks}{Clocks example}
+ \sa SmoothedAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example}, {declarative/toys/clocks}{Clocks example}
*/
QDeclarativeSpringAnimation::QDeclarativeSpringAnimation(QObject *parent)
@@ -284,8 +286,8 @@ qreal QDeclarativeSpringAnimation::from() const
This property holds the value from which the animation will begin.
- If not set, the animation will start regardless of the
- value being tracked.
+ If not set, the animation will start whenever the tracked value has
+ changed, regardless of its value.
*/
void QDeclarativeSpringAnimation::setFrom(qreal value)
@@ -303,7 +305,10 @@ void QDeclarativeSpringAnimation::setFrom(qreal value)
/*!
\qmlproperty real SpringAnimation::velocity
+
This property holds the maximum velocity allowed when tracking the source.
+
+ The default value is 0 (no maximum velocity).
*/
qreal QDeclarativeSpringAnimation::velocity() const
@@ -322,13 +327,14 @@ void QDeclarativeSpringAnimation::setVelocity(qreal velocity)
/*!
\qmlproperty real SpringAnimation::spring
- This property holds the spring constant
- The spring constant describes how strongly the target is pulled towards the
- source. Setting spring to 0 turns off spring tracking. Useful values 0 - 5.0
+ This property describes how strongly the target is pulled towards the
+ source. The default value is 0 (that is, the spring-like motion is disabled).
+
+ The useful value range is 0 - 5.0.
- When a spring constant is set and the velocity property is greater than 0,
- velocity limits the maximum speed.
+ When this property is set and the \l velocity value is greater than 0,
+ the \l velocity limits the maximum speed.
*/
qreal QDeclarativeSpringAnimation::spring() const
{
@@ -347,10 +353,11 @@ void QDeclarativeSpringAnimation::setSpring(qreal spring)
\qmlproperty real SpringAnimation::damping
This property holds the spring damping value.
- This value describes how quickly a sprung follower comes to rest.
+ This value describes how quickly the spring-like motion comes to rest.
+ The default value is 0.
- The useful range is 0 - 1.0. The lower the value, the faster the
- follower comes to rest.
+ The useful value range is 0 - 1.0. The lower the value, the faster it
+ comes to rest.
*/
qreal QDeclarativeSpringAnimation::damping() const
{
@@ -392,7 +399,7 @@ void QDeclarativeSpringAnimation::setEpsilon(qreal epsilon)
/*!
\qmlproperty real SpringAnimation::modulus
- This property holds the modulus value.
+ This property holds the modulus value. The default value is 0.
Setting a \a modulus forces the target value to "wrap around" at the modulus.
For example, setting the modulus to 360 will cause a value of 370 to wrap around to 10.
@@ -417,8 +424,10 @@ void QDeclarativeSpringAnimation::setModulus(qreal modulus)
\qmlproperty real SpringAnimation::mass
This property holds the "mass" of the property being moved.
- mass is 1.0 by default. Setting a different mass changes the dynamics of
- a \l spring follow.
+ The value is 1.0 by default.
+
+ A greater mass causes slower movement and a greater spring-like
+ motion when an item comes to rest.
*/
qreal QDeclarativeSpringAnimation::mass() const
{
diff --git a/src/declarative/util/qdeclarativestyledtext.cpp b/src/declarative/util/qdeclarativestyledtext.cpp
index babd71b..91566bc 100644
--- a/src/declarative/util/qdeclarativestyledtext.cpp
+++ b/src/declarative/util/qdeclarativestyledtext.cpp
@@ -152,8 +152,6 @@ void QDeclarativeStyledTextPrivate::parse()
QTextCharFormat format;
if (formatStack.count())
format = formatStack.top();
- else
- format.setFont(baseFont);
if (parseTag(ch, text, drawText, format))
formatStack.push(format);
}
@@ -198,8 +196,10 @@ bool QDeclarativeStyledTextPrivate::parseTag(const QChar *&ch, const QString &te
if (char0 == QLatin1Char('b')) {
if (tagLength == 1)
format.setFontWeight(QFont::Bold);
- else if (tagLength == 2 && tag.at(1) == QLatin1Char('r'))
+ else if (tagLength == 2 && tag.at(1) == QLatin1Char('r')) {
textOut.append(QChar(QChar::LineSeparator));
+ return false;
+ }
} else if (char0 == QLatin1Char('i')) {
if (tagLength == 1)
format.setFontItalic(true);
diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp
index 34e1e2b..6561b8c 100644
--- a/src/declarative/util/qdeclarativetransition.cpp
+++ b/src/declarative/util/qdeclarativetransition.cpp
@@ -66,8 +66,6 @@ QT_BEGIN_NAMESPACE
\snippet doc/src/snippets/declarative/transition.qml 0
- Items can have multiple transitions, if
-
To specify multiple transitions, specify \l Item::transitions as a list:
\qml
@@ -78,7 +76,7 @@ QT_BEGIN_NAMESPACE
Transition { ... }
]
}
- |endqml
+ \endqml
\sa {declarative/animation/states}{states example}, {qmlstates}{States}, {state-transitions}{Transitions}, {QtDeclarative}
*/
diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp
index c3948c1..7546a50 100644
--- a/src/declarative/util/qdeclarativeview.cpp
+++ b/src/declarative/util/qdeclarativeview.cpp
@@ -194,45 +194,46 @@ void QDeclarativeViewPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem,
\since 4.7
\brief The QDeclarativeView class provides a widget for displaying a Qt Declarative user interface.
- Any QGraphicsObject or QDeclarativeItem
- created via QML can be placed on a standard QGraphicsScene and viewed with a standard
- QGraphicsView.
+ QDeclarativeItem objects can be placed on a standard QGraphicsScene and
+ displayed with QGraphicsView. QDeclarativeView is a QGraphicsView subclass
+ provided as a convenience for displaying QML files, and connecting between
+ QML and C++ Qt objects.
- QDeclarativeView is a QGraphicsView subclass provided as a convenience for displaying QML
- files, and connecting between QML and C++ Qt objects.
-
- QDeclarativeView performs the following functions:
+ QDeclarativeView provides:
\list
- \o Manages QDeclarativeComponent loading and object creation.
- \o Initializes QGraphicsView for optimal performance with QML:
+ \o Management of QDeclarativeComponent loading and object creation
+ \o Initialization of QGraphicsView for optimal performance with QML using these settings:
\list
- \o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState);
- \o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
- \o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex);
+ \o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState)
+ \o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate)
+ \o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex)
\endlist
- \o Initializes QGraphicsView for QML key handling:
+ \o Initialization of QGraphicsView for QML key handling using these settings:
\list
- \o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus);
- \o QGraphicsView::setFocusPolicy(Qt::StrongFocus);
- \o QGraphicsScene::setStickyFocus(true);
+ \o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus)
+ \o QGraphicsView::setFocusPolicy(Qt::StrongFocus)
+ \o QGraphicsScene::setStickyFocus(true)
\endlist
\endlist
Typical usage:
- \code
- ...
- QDeclarativeView *view = new QDeclarativeView(this);
- vbox->addWidget(view);
- QUrl url = QUrl::fromLocalFile(fileName);
- view->setSource(url);
+ \code
+ QDeclarativeView *view = new QDeclarativeView;
+ view->setSource(QUrl::fromLocalFile("myqmlfile.qml"));
view->show();
\endcode
+ Since QDeclarativeView is a QWidget-based class, it can be used to
+ display QML interfaces within QWidget-based GUI applications that do not
+ use the Graphics View framework.
+
To receive errors related to loading and executing QML with QDeclarativeView,
you can connect to the statusChanged() signal and monitor for QDeclarativeView::Error.
The errors are available via QDeclarativeView::errors().
+
+ \sa {Integrating QML with existing Qt UI code}, {Using QML in C++ Applications}
*/
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index dcb93cf..7c1e1fd 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -567,7 +567,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
\image qml-xmllistmodel-example.png
The XmlListModel data is loaded asynchronously, and \l status
- is set to \l XmlListModel::Ready when loading is complete.
+ is set to \c XmlListModel.Ready when loading is complete.
Note this means when XmlListModel is used for a view, the view is not
populated until the model is loaded.
@@ -596,7 +596,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
with a combined value of all key roles that is not already present in
the model.
- \sa {demos/declarative/rssnews}{RSS News demo}
+ \sa {RSS News}
*/
QDeclarativeXmlListModel::QDeclarativeXmlListModel(QObject *parent)
@@ -674,7 +674,7 @@ QString QDeclarativeXmlListModel::toString(int role) const
\qmlproperty url XmlListModel::source
The location of the XML data source.
- If both source and xml are set, xml will be used.
+ If both \c source and \l xml are set, \l xml is used.
*/
QUrl QDeclarativeXmlListModel::source() const
{
@@ -699,7 +699,7 @@ void QDeclarativeXmlListModel::setSource(const QUrl &src)
The text is assumed to be UTF-8 encoded.
- If both \l source and \c xml are set, \c xml will be used.
+ If both \l source and \c xml are set, \c xml is used.
*/
QString QDeclarativeXmlListModel::xml() const
{
diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp
index cfe848c..b842109 100644
--- a/src/imports/particles/qdeclarativeparticles.cpp
+++ b/src/imports/particles/qdeclarativeparticles.cpp
@@ -1245,7 +1245,7 @@ void QDeclarativeParticles::burst(int count, int emissionRate)
void QDeclarativeParticlesPainter::updateSize()
{
- if (!d->_componentComplete)
+ if (!d->componentComplete)
return;
const int parentX = parentItem()->x();
diff --git a/src/s60installs/bwins/QtDeclarativeu.def b/src/s60installs/bwins/QtDeclarativeu.def
index 2cc80a8..480d9ff 100644
--- a/src/s60installs/bwins/QtDeclarativeu.def
+++ b/src/s60installs/bwins/QtDeclarativeu.def
@@ -12,7 +12,7 @@ EXPORTS
??0QDeclarativeText@@QAE@PAVQDeclarativeItem@@@Z @ 11 NONAME ; QDeclarativeText::QDeclarativeText(class QDeclarativeItem *)
?trUtf8@QDeclarativePixmapReply@@SA?AVQString@@PBD0H@Z @ 12 NONAME ABSENT ; class QString QDeclarativePixmapReply::trUtf8(char const *, char const *, int)
?propertyTypeName@QDeclarativeProperty@@QBEPBDXZ @ 13 NONAME ; char const * QDeclarativeProperty::propertyTypeName(void) const
- ?wantsFocusChanged@QDeclarativeItem@@IAEX_N@Z @ 14 NONAME ; void QDeclarativeItem::wantsFocusChanged(bool)
+ ?wantsFocusChanged@QDeclarativeItem@@IAEX_N@Z @ 14 NONAME ABSENT ; void QDeclarativeItem::wantsFocusChanged(bool)
?getStaticMetaObject@QDeclarativeDebugService@@SAABUQMetaObject@@XZ @ 15 NONAME ; struct QMetaObject const & QDeclarativeDebugService::getStaticMetaObject(void)
?setLeft@QDeclarativeAnchors@@QAEXABVQDeclarativeAnchorLine@@@Z @ 16 NONAME ; void QDeclarativeAnchors::setLeft(class QDeclarativeAnchorLine const &)
?qt_metacall@QDeclarativeExpression@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 17 NONAME ; int QDeclarativeExpression::qt_metacall(enum QMetaObject::Call, int, void * *)
@@ -61,7 +61,7 @@ EXPORTS
??0QDeclarativeDomObject@@QAE@XZ @ 60 NONAME ; QDeclarativeDomObject::QDeclarativeDomObject(void)
?errors@QDeclarativeDomDocument@@QBE?AV?$QList@VQDeclarativeError@@@@XZ @ 61 NONAME ; class QList<class QDeclarativeError> QDeclarativeDomDocument::errors(void) const
?toChanged@QDeclarativeTransition@@IAEXXZ @ 62 NONAME ; void QDeclarativeTransition::toChanged(void)
- ?registerAutoParentFunction@QDeclarativePrivate@@YAHP6A?AW4AutoParentResult@1@PAVQObject@@0@Z@Z @ 63 NONAME ; int QDeclarativePrivate::registerAutoParentFunction(enum QDeclarativePrivate::AutoParentResult (*)(class QObject *, class QObject *))
+ ?registerAutoParentFunction@QDeclarativePrivate@@YAHP6A?AW4AutoParentResult@1@PAVQObject@@0@Z@Z @ 63 NONAME ABSENT ; int QDeclarativePrivate::registerAutoParentFunction(enum QDeclarativePrivate::AutoParentResult (*)(class QObject *, class QObject *))
?objectOwnership@QDeclarativeEngine@@SA?AW4ObjectOwnership@1@PAVQObject@@@Z @ 64 NONAME ; enum QDeclarativeEngine::ObjectOwnership QDeclarativeEngine::objectOwnership(class QObject *)
??0QDeclarativeDebugWatch@@QAE@PAVQObject@@@Z @ 65 NONAME ; QDeclarativeDebugWatch::QDeclarativeDebugWatch(class QObject *)
?value@QDeclarativePropertyMap@@QBE?AVQVariant@@ABVQString@@@Z @ 66 NONAME ; class QVariant QDeclarativePropertyMap::value(class QString const &) const
@@ -79,7 +79,7 @@ EXPORTS
?isInvalid@QDeclarativeDomValue@@QBE_NXZ @ 78 NONAME ; bool QDeclarativeDomValue::isInvalid(void) const
?trUtf8@QDeclarativeText@@SA?AVQString@@PBD0H@Z @ 79 NONAME ; class QString QDeclarativeText::trUtf8(char const *, char const *, int)
??0QDeclarativeListReference@@QAE@ABV0@@Z @ 80 NONAME ; QDeclarativeListReference::QDeclarativeListReference(class QDeclarativeListReference const &)
- ?registerType@QDeclarativePrivate@@YAHABURegisterInterface@1@@Z @ 81 NONAME ; int QDeclarativePrivate::registerType(struct QDeclarativePrivate::RegisterInterface const &)
+ ?registerType@QDeclarativePrivate@@YAHABURegisterInterface@1@@Z @ 81 NONAME ABSENT ; int QDeclarativePrivate::registerType(struct QDeclarativePrivate::RegisterInterface const &)
?classBegin@QDeclarativeItem@@MAEXXZ @ 82 NONAME ; void QDeclarativeItem::classBegin(void)
?setTransformOrigin@QDeclarativeItem@@QAEXW4TransformOrigin@1@@Z @ 83 NONAME ; void QDeclarativeItem::setTransformOrigin(enum QDeclarativeItem::TransformOrigin)
?request@QDeclarativePixmapCache@@SAPAVQDeclarativePixmapReply@@PAVQDeclarativeEngine@@ABVQUrl@@HH@Z @ 84 NONAME ABSENT ; class QDeclarativePixmapReply * QDeclarativePixmapCache::request(class QDeclarativeEngine *, class QUrl const &, int, int)
@@ -265,7 +265,7 @@ EXPORTS
?readyRead@QPacketProtocol@@IAEXXZ @ 264 NONAME ; void QPacketProtocol::readyRead(void)
?qt_metacall@QDeclarativeValueType@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 265 NONAME ; int QDeclarativeValueType::qt_metacall(enum QMetaObject::Call, int, void * *)
?propertyType@QDeclarativePropertyPrivate@@QBEHXZ @ 266 NONAME ; int QDeclarativePropertyPrivate::propertyType(void) const
- ?engine@QDeclarativeView@@QAEPAVQDeclarativeEngine@@XZ @ 267 NONAME ; class QDeclarativeEngine * QDeclarativeView::engine(void)
+ ?engine@QDeclarativeView@@QAEPAVQDeclarativeEngine@@XZ @ 267 NONAME ABSENT ; class QDeclarativeEngine * QDeclarativeView::engine(void)
?inputMethodQuery@QDeclarativeItem@@MBE?AVQVariant@@W4InputMethodQuery@Qt@@@Z @ 268 NONAME ; class QVariant QDeclarativeItem::inputMethodQuery(enum Qt::InputMethodQuery) const
?sizeHint@QDeclarativeView@@UBE?AVQSize@@XZ @ 269 NONAME ; class QSize QDeclarativeView::sizeHint(void) const
?flags@QDeclarativeCustomParser@@QBE?AV?$QFlags@W4Flag@QDeclarativeCustomParser@@@@XZ @ 270 NONAME ; class QFlags<enum QDeclarativeCustomParser::Flag> QDeclarativeCustomParser::flags(void) const
@@ -409,7 +409,7 @@ EXPORTS
?addRef@QDeclarativePixmapReply@@AAEXXZ @ 408 NONAME ABSENT ; void QDeclarativePixmapReply::addRef(void)
?mouseReleaseEvent@QDeclarativeText@@MAEXPAVQGraphicsSceneMouseEvent@@@Z @ 409 NONAME ; void QDeclarativeText::mouseReleaseEvent(class QGraphicsSceneMouseEvent *)
?isCustomType@QDeclarativeDomObject@@QBE_NXZ @ 410 NONAME ; bool QDeclarativeDomObject::isCustomType(void) const
- ?registerType@QDeclarativePrivate@@YAHABURegisterType@1@@Z @ 411 NONAME ; int QDeclarativePrivate::registerType(struct QDeclarativePrivate::RegisterType const &)
+ ?registerType@QDeclarativePrivate@@YAHABURegisterType@1@@Z @ 411 NONAME ABSENT ; int QDeclarativePrivate::registerType(struct QDeclarativePrivate::RegisterType const &)
?radius@QDeclarativeRectangle@@QBEMXZ @ 412 NONAME ; float QDeclarativeRectangle::radius(void) const
??0QDeclarativeComponent@@AAE@PAVQDeclarativeEngine@@PAVQDeclarativeCompiledData@@HHPAVQObject@@@Z @ 413 NONAME ; QDeclarativeComponent::QDeclarativeComponent(class QDeclarativeEngine *, class QDeclarativeCompiledData *, int, int, class QObject *)
?resources_count@QDeclarativeItemPrivate@@SAHPAV?$QDeclarativeListProperty@VQObject@@@@@Z @ 414 NONAME ; int QDeclarativeItemPrivate::resources_count(class QDeclarativeListProperty<class QObject> *)
@@ -877,7 +877,7 @@ EXPORTS
?setWidth@QDeclarativeItemPrivate@@UAEXM@Z @ 876 NONAME ; void QDeclarativeItemPrivate::setWidth(float)
?staticMetaObject@QDeclarativeDebugWatch@@2UQMetaObject@@B @ 877 NONAME ; struct QMetaObject const QDeclarativeDebugWatch::staticMetaObject
??_EQDeclarativeContext@@UAE@I@Z @ 878 NONAME ; QDeclarativeContext::~QDeclarativeContext(unsigned int)
- ?rootContext@QDeclarativeView@@QAEPAVQDeclarativeContext@@XZ @ 879 NONAME ; class QDeclarativeContext * QDeclarativeView::rootContext(void)
+ ?rootContext@QDeclarativeView@@QAEPAVQDeclarativeContext@@XZ @ 879 NONAME ABSENT ; class QDeclarativeContext * QDeclarativeView::rootContext(void)
?staticMetaObject@QDeclarativeDebugQuery@@2UQMetaObject@@B @ 880 NONAME ; struct QMetaObject const QDeclarativeDebugQuery::staticMetaObject
??0QDeclarativeExtensionPlugin@@QAE@PAVQObject@@@Z @ 881 NONAME ; QDeclarativeExtensionPlugin::QDeclarativeExtensionPlugin(class QObject *)
??_EQDeclarativeOpenMetaObject@@UAE@I@Z @ 882 NONAME ; QDeclarativeOpenMetaObject::~QDeclarativeOpenMetaObject(unsigned int)
@@ -1077,7 +1077,7 @@ EXPORTS
??1QDeclarativeEngine@@UAE@XZ @ 1076 NONAME ; QDeclarativeEngine::~QDeclarativeEngine(void)
?debugId@QDeclarativeDebugContextReference@@QBEHXZ @ 1077 NONAME ; int QDeclarativeDebugContextReference::debugId(void) const
?propertyNameParts@QDeclarativeDomProperty@@QBE?AV?$QList@VQByteArray@@@@XZ @ 1078 NONAME ; class QList<class QByteArray> QDeclarativeDomProperty::propertyNameParts(void) const
- ?rootContext@QDeclarativeEngine@@QAEPAVQDeclarativeContext@@XZ @ 1079 NONAME ; class QDeclarativeContext * QDeclarativeEngine::rootContext(void)
+ ?rootContext@QDeclarativeEngine@@QAEPAVQDeclarativeContext@@XZ @ 1079 NONAME ABSENT ; class QDeclarativeContext * QDeclarativeEngine::rootContext(void)
?resetWidth@QDeclarativeItemPrivate@@UAEXXZ @ 1080 NONAME ; void QDeclarativeItemPrivate::resetWidth(void)
??AQDeclarativeOpenMetaObject@@QAEAAVQVariant@@ABVQByteArray@@@Z @ 1081 NONAME ; class QVariant & QDeclarativeOpenMetaObject::operator[](class QByteArray const &)
?bottom@QDeclarativeItemPrivate@@QBE?AVQDeclarativeAnchorLine@@XZ @ 1082 NONAME ; class QDeclarativeAnchorLine QDeclarativeItemPrivate::bottom(void) const
@@ -1182,7 +1182,7 @@ EXPORTS
??_EQDeclarativeEngineDebug@@UAE@I@Z @ 1181 NONAME ; QDeclarativeEngineDebug::~QDeclarativeEngineDebug(unsigned int)
?bottom@QDeclarativeScaleGrid@@QBEHXZ @ 1182 NONAME ; int QDeclarativeScaleGrid::bottom(void) const
?d_func@QDeclarativePropertyMap@@AAEPAVQDeclarativePropertyMapPrivate@@XZ @ 1183 NONAME ; class QDeclarativePropertyMapPrivate * QDeclarativePropertyMap::d_func(void)
- ?forceFocus@QDeclarativeItem@@QAEXXZ @ 1184 NONAME ; void QDeclarativeItem::forceFocus(void)
+ ?forceFocus@QDeclarativeItem@@QAEXXZ @ 1184 NONAME ABSENT ; void QDeclarativeItem::forceFocus(void)
?trUtf8@QDeclarativeView@@SA?AVQString@@PBD0@Z @ 1185 NONAME ; class QString QDeclarativeView::trUtf8(char const *, char const *)
??0QDeclarativeTransition@@QAE@PAVQObject@@@Z @ 1186 NONAME ; QDeclarativeTransition::QDeclarativeTransition(class QObject *)
?horizontalCenter@QDeclarativeAnchors@@QBE?AVQDeclarativeAnchorLine@@XZ @ 1187 NONAME ; class QDeclarativeAnchorLine QDeclarativeAnchors::horizontalCenter(void) const
@@ -1442,7 +1442,7 @@ EXPORTS
?drawRect@QDeclarativeRectangle@@AAEXAAVQPainter@@@Z @ 1441 NONAME ; void QDeclarativeRectangle::drawRect(class QPainter &)
?read@QDeclarativeProperty@@QBE?AVQVariant@@XZ @ 1442 NONAME ; class QVariant QDeclarativeProperty::read(void) const
?isEmpty@QDeclarativePropertyMap@@QBE_NXZ @ 1443 NONAME ; bool QDeclarativePropertyMap::isEmpty(void) const
- ?wantsFocus@QDeclarativeItem@@QBE_NXZ @ 1444 NONAME ; bool QDeclarativeItem::wantsFocus(void) const
+ ?wantsFocus@QDeclarativeItem@@QBE_NXZ @ 1444 NONAME ABSENT ; bool QDeclarativeItem::wantsFocus(void) const
??6@YAAAVQDataStream@@AAV0@ABUQDeclarativeObjectData@QDeclarativeEngineDebugServer@@@Z @ 1445 NONAME ; class QDataStream & operator<<(class QDataStream &, struct QDeclarativeEngineDebugServer::QDeclarativeObjectData const &)
?trUtf8@QDeclarativeDebugObjectQuery@@SA?AVQString@@PBD0H@Z @ 1446 NONAME ; class QString QDeclarativeDebugObjectQuery::trUtf8(char const *, char const *, int)
??0QDeclarativeBinding@@QAE@ABVQString@@PAVQObject@@PAVQDeclarativeContext@@1@Z @ 1447 NONAME ; QDeclarativeBinding::QDeclarativeBinding(class QString const &, class QObject *, class QDeclarativeContext *, class QObject *)
@@ -1676,4 +1676,12 @@ EXPORTS
??0QDeclarativeImageProvider@@QAE@W4ImageType@0@@Z @ 1675 NONAME ; QDeclarativeImageProvider::QDeclarativeImageProvider(enum QDeclarativeImageProvider::ImageType)
?setMethodBody@QDeclarativeEngineDebug@@QAE_NHABVQString@@0@Z @ 1676 NONAME ; bool QDeclarativeEngineDebug::setMethodBody(int, class QString const &, class QString const &)
?resetBindingForObject@QDeclarativeEngineDebug@@QAE_NHABVQString@@@Z @ 1677 NONAME ; bool QDeclarativeEngineDebug::resetBindingForObject(int, class QString const &)
+ ?forceActiveFocus@QDeclarativeItem@@QAEXXZ @ 1678 NONAME ; void QDeclarativeItem::forceActiveFocus(void)
+ ?activeFocusChanged@QDeclarativeItem@@IAEX_N@Z @ 1679 NONAME ; void QDeclarativeItem::activeFocusChanged(bool)
+ ?focusScopeItemChange@QDeclarativeItemPrivate@@UAEX_N@Z @ 1680 NONAME ; void QDeclarativeItemPrivate::focusScopeItemChange(bool)
+ ?hasActiveFocus@QDeclarativeItem@@QBE_NXZ @ 1681 NONAME ; bool QDeclarativeItem::hasActiveFocus(void) const
+ ?engine@QDeclarativeView@@QBEPAVQDeclarativeEngine@@XZ @ 1682 NONAME ; class QDeclarativeEngine * QDeclarativeView::engine(void) const
+ ?rootContext@QDeclarativeView@@QBEPAVQDeclarativeContext@@XZ @ 1683 NONAME ; class QDeclarativeContext * QDeclarativeView::rootContext(void) const
+ ?rootContext@QDeclarativeEngine@@QBEPAVQDeclarativeContext@@XZ @ 1684 NONAME ; class QDeclarativeContext * QDeclarativeEngine::rootContext(void) const
+ ?qmlregister@QDeclarativePrivate@@YAHW4RegistrationType@1@PAX@Z @ 1685 NONAME ; int QDeclarativePrivate::qmlregister(enum QDeclarativePrivate::RegistrationType, void *)
diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def
index bcb91fa..9a3cefa 100644
--- a/src/s60installs/eabi/QtDeclarativeu.def
+++ b/src/s60installs/eabi/QtDeclarativeu.def
@@ -44,7 +44,7 @@ EXPORTS
_ZN16QDeclarativeInfoD1Ev @ 43 NONAME
_ZN16QDeclarativeInfoD2Ev @ 44 NONAME
_ZN16QDeclarativeItem10classBeginEv @ 45 NONAME
- _ZN16QDeclarativeItem10forceFocusEv @ 46 NONAME
+ _ZN16QDeclarativeItem10forceFocusEv @ 46 NONAME ABSENT
_ZN16QDeclarativeItem10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 47 NONAME
_ZN16QDeclarativeItem10resetWidthEv @ 48 NONAME
_ZN16QDeclarativeItem10sceneEventEP6QEvent @ 49 NONAME
@@ -69,7 +69,7 @@ EXPORTS
_ZN16QDeclarativeItem17componentCompleteEv @ 68 NONAME
_ZN16QDeclarativeItem17setBaselineOffsetEf @ 69 NONAME
_ZN16QDeclarativeItem17setImplicitHeightEf @ 70 NONAME
- _ZN16QDeclarativeItem17wantsFocusChangedEb @ 71 NONAME
+ _ZN16QDeclarativeItem17wantsFocusChangedEb @ 71 NONAME ABSENT
_ZN16QDeclarativeItem18keyPressPreHandlerEP9QKeyEvent @ 72 NONAME
_ZN16QDeclarativeItem18setTransformOriginENS_15TransformOriginE @ 73 NONAME
_ZN16QDeclarativeItem19childrenRectChangedERK6QRectF @ 74 NONAME
@@ -143,7 +143,7 @@ EXPORTS
_ZN16QDeclarativeView11qt_metacallEN11QMetaObject4CallEiPPv @ 142 NONAME
_ZN16QDeclarativeView11qt_metacastEPKc @ 143 NONAME
_ZN16QDeclarativeView11resizeEventEP12QResizeEvent @ 144 NONAME
- _ZN16QDeclarativeView11rootContextEv @ 145 NONAME
+ _ZN16QDeclarativeView11rootContextEv @ 145 NONAME ABSENT
_ZN16QDeclarativeView12sceneResizedE5QSize @ 146 NONAME
_ZN16QDeclarativeView13setResizeModeENS_10ResizeModeE @ 147 NONAME
_ZN16QDeclarativeView13setRootObjectEP7QObject @ 148 NONAME
@@ -151,7 +151,7 @@ EXPORTS
_ZN16QDeclarativeView15continueExecuteEv @ 150 NONAME
_ZN16QDeclarativeView16staticMetaObjectE @ 151 NONAME DATA 16
_ZN16QDeclarativeView19getStaticMetaObjectEv @ 152 NONAME
- _ZN16QDeclarativeView6engineEv @ 153 NONAME
+ _ZN16QDeclarativeView6engineEv @ 153 NONAME ABSENT
_ZN16QDeclarativeView9setSourceERK4QUrl @ 154 NONAME
_ZN16QDeclarativeViewC1EP7QWidget @ 155 NONAME
_ZN16QDeclarativeViewC1ERK4QUrlP7QWidget @ 156 NONAME
@@ -202,7 +202,7 @@ EXPORTS
_ZN18QDeclarativeEngine10setBaseUrlERK4QUrl @ 201 NONAME
_ZN18QDeclarativeEngine11qt_metacallEN11QMetaObject4CallEiPPv @ 202 NONAME
_ZN18QDeclarativeEngine11qt_metacastEPKc @ 203 NONAME
- _ZN18QDeclarativeEngine11rootContextEv @ 204 NONAME
+ _ZN18QDeclarativeEngine11rootContextEv @ 204 NONAME ABSENT
_ZN18QDeclarativeEngine12importPluginERK7QStringS2_PS0_ @ 205 NONAME
_ZN18QDeclarativeEngine13addImportPathERK7QString @ 206 NONAME
_ZN18QDeclarativeEngine13addPluginPathERK7QString @ 207 NONAME
@@ -385,9 +385,9 @@ EXPORTS
_ZN19QDeclarativeDomListD1Ev @ 384 NONAME
_ZN19QDeclarativeDomListD2Ev @ 385 NONAME
_ZN19QDeclarativeDomListaSERKS_ @ 386 NONAME
- _ZN19QDeclarativePrivate12registerTypeERKNS_12RegisterTypeE @ 387 NONAME
- _ZN19QDeclarativePrivate12registerTypeERKNS_17RegisterInterfaceE @ 388 NONAME
- _ZN19QDeclarativePrivate26registerAutoParentFunctionEPFNS_16AutoParentResultEP7QObjectS2_E @ 389 NONAME
+ _ZN19QDeclarativePrivate12registerTypeERKNS_12RegisterTypeE @ 387 NONAME ABSENT
+ _ZN19QDeclarativePrivate12registerTypeERKNS_17RegisterInterfaceE @ 388 NONAME ABSENT
+ _ZN19QDeclarativePrivate26registerAutoParentFunctionEPFNS_16AutoParentResultEP7QObjectS2_E @ 389 NONAME ABSENT
_ZN19QDeclarativePrivate30qdeclarativeelement_destructorEP7QObject @ 390 NONAME
_ZN19QListModelInterface10itemsMovedEiii @ 391 NONAME
_ZN19QListModelInterface11qt_metacallEN11QMetaObject4CallEiPPv @ 392 NONAME
@@ -1075,7 +1075,7 @@ EXPORTS
_ZNK15QPacketProtocol17maximumPacketSizeEv @ 1074 NONAME
_ZNK16QDeclarativeItem10metaObjectEv @ 1075 NONAME
_ZNK16QDeclarativeItem10parentItemEv @ 1076 NONAME
- _ZNK16QDeclarativeItem10wantsFocusEv @ 1077 NONAME
+ _ZNK16QDeclarativeItem10wantsFocusEv @ 1077 NONAME ABSENT
_ZNK16QDeclarativeItem10widthValidEv @ 1078 NONAME
_ZNK16QDeclarativeItem11heightValidEv @ 1079 NONAME
_ZNK16QDeclarativeItem11mapFromItemERK12QScriptValueff @ 1080 NONAME
@@ -1707,4 +1707,11 @@ EXPORTS
_ZN25QDeclarativeImageProviderC2ENS_9ImageTypeE @ 1706 NONAME
_ZNK25QDeclarativeImageProvider9imageTypeEv @ 1707 NONAME
_ZN23QDeclarativeEngineDebug21resetBindingForObjectEiRK7QString @ 1708 NONAME
+ _ZN16QDeclarativeItem16forceActiveFocusEv @ 1709 NONAME
+ _ZN16QDeclarativeItem18activeFocusChangedEb @ 1710 NONAME
+ _ZNK16QDeclarativeItem14hasActiveFocusEv @ 1711 NONAME
+ _ZNK16QDeclarativeView11rootContextEv @ 1712 NONAME
+ _ZNK16QDeclarativeView6engineEv @ 1713 NONAME
+ _ZNK18QDeclarativeEngine11rootContextEv @ 1714 NONAME
+ _ZN19QDeclarativePrivate11qmlregisterENS_16RegistrationTypeEPv @ 1715 NONAME
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 3d2dbf0..a7fb3b8 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -52,8 +52,7 @@ SUBDIRS += \
qdeclarativeqt \
qdeclarativerepeater \
qdeclarativesmoothedanimation \
- qdeclarativesmoothedfollow\
- qdeclarativespringfollow \
+ qdeclarativespringanimation \
qdeclarativesqldatabase \
qdeclarativestates \
qdeclarativestyledtext \
diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
index a965ef3..3e80c2c 100644
--- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
@@ -310,7 +310,7 @@ void tst_qdeclarativeanimations::badTypes()
c.create();
QVERIFY(c.errors().count() == 1);
- QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: double expected"));
+ QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected"));
}
//make sure we get a compiler error
diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
index bb7fc7b..174967b 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
@@ -401,6 +401,7 @@ void tst_qdeclarativebehaviors::sameValue()
target->setProperty("x", 0);
QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100));
+ QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished.
target->setX(100);
QCOMPARE(target->x(), qreal(100));
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml
index db7f2b5..2c79729 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml
@@ -7,7 +7,7 @@ MyTypeObject {
uintProperty: if(1) 10
intProperty: if(1) -19
realProperty: if(1) 23.2
- doubleProperty: if(1) -19.7
+ doubleProperty: if(1) -19.75
floatProperty: if(1) 8.5
colorProperty: if(1) "red"
dateProperty: if(1) "1982-11-25"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml
index 72ae865..1cd78a5 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml
@@ -9,7 +9,7 @@ MyTypeObject {
uintProperty = 10
intProperty = -19
realProperty = 23.2
- doubleProperty = -19.7
+ doubleProperty = -19.75
floatProperty = 8.5
colorProperty = "red"
dateProperty = "1982-11-25"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
index 849879e..19bfd37 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -572,7 +572,7 @@ public:
Q_INVOKABLE void method_NoArgs() { invoke(0); }
Q_INVOKABLE int method_NoArgs_int() { invoke(1); return 6; }
- Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.7; }
+ Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.75; }
Q_INVOKABLE QPointF method_NoArgs_QPointF() { invoke(3); return QPointF(123, 4.5); }
Q_INVOKABLE QObject *method_NoArgs_QObject() { invoke(4); return this; }
Q_INVOKABLE MyInvokableObject *method_NoArgs_unknown() { invoke(5); return this; }
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 43900ae..a6d2dac 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -179,7 +179,7 @@ void tst_qdeclarativeecmascript::assignBasicTypes()
QCOMPARE(object->uintProperty(), uint(10));
QCOMPARE(object->intProperty(), -19);
QCOMPARE((float)object->realProperty(), float(23.2));
- QCOMPARE((float)object->doubleProperty(), float(-19.7));
+ QCOMPARE((float)object->doubleProperty(), float(-19.75));
QCOMPARE((float)object->floatProperty(), float(8.5));
QCOMPARE(object->colorProperty(), QColor("red"));
QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
@@ -207,7 +207,7 @@ void tst_qdeclarativeecmascript::assignBasicTypes()
QCOMPARE(object->uintProperty(), uint(10));
QCOMPARE(object->intProperty(), -19);
QCOMPARE((float)object->realProperty(), float(23.2));
- QCOMPARE((float)object->doubleProperty(), float(-19.7));
+ QCOMPARE((float)object->doubleProperty(), float(-19.75));
QCOMPARE((float)object->floatProperty(), float(8.5));
QCOMPARE(object->colorProperty(), QColor("red"));
QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
@@ -280,8 +280,8 @@ void tst_qdeclarativeecmascript::signalAssignment()
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->string(), QString());
- emit object->argumentSignal(19, "Hello world!", 10.3);
- QCOMPARE(object->string(), QString("pass 19 Hello world! 10.3"));
+ emit object->argumentSignal(19, "Hello world!", 10.25);
+ QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25"));
}
}
@@ -1387,7 +1387,7 @@ void tst_qdeclarativeecmascript::callQtInvokables()
QCOMPARE(o.actuals().count(), 0);
o.reset();
- QVERIFY(engine->evaluate("object.method_NoArgs_real()").strictlyEquals(QScriptValue(engine, 19.7)));
+ QVERIFY(engine->evaluate("object.method_NoArgs_real()").strictlyEquals(QScriptValue(engine, 19.75)));
QCOMPARE(o.error(), false);
QCOMPARE(o.invoked(), 2);
QCOMPARE(o.actuals().count(), 0);
@@ -1818,7 +1818,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toBool(), true);
delete object;
@@ -1831,7 +1831,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toBool(), true);
delete object;
@@ -1844,7 +1844,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toBool(), true);
delete object;
@@ -1857,7 +1857,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->methodCalled(), false);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->methodCalled(), true);
delete object;
@@ -1870,7 +1870,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->methodCalled(), false);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->methodCalled(), true);
delete object;
@@ -1883,7 +1883,7 @@ void tst_qdeclarativeecmascript::scriptConnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toInt(), 2);
delete object;
@@ -1899,13 +1899,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toInt(), 2);
delete object;
@@ -1918,13 +1918,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toInt(), 2);
delete object;
@@ -1937,13 +1937,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toInt(), 3);
delete object;
@@ -1955,13 +1955,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect()
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 0);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toInt(), 1);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toInt(), 2);
emit object->basicSignal();
QCOMPARE(object->property("test").toInt(), 2);
- emit object->argumentSignal(19, "Hello world!", 10.3);
+ emit object->argumentSignal(19, "Hello world!", 10.25);
QCOMPARE(object->property("test").toInt(), 3);
delete object;
diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-arm.png b/tests/auto/declarative/qdeclarativeimage/data/heart-arm.png
new file mode 100644
index 0000000..3245027
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeimage/data/heart-arm.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200-arm.png b/tests/auto/declarative/qdeclarativeimage/data/heart200-arm.png
new file mode 100644
index 0000000..b16db76
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeimage/data/heart200-arm.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
index adee312..b8d2828 100644
--- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
+++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp
@@ -123,8 +123,8 @@ void tst_qdeclarativeimage::noSource()
void tst_qdeclarativeimage::imageSource_data()
{
QTest::addColumn<QString>("source");
- QTest::addColumn<qreal>("width");
- QTest::addColumn<qreal>("height");
+ QTest::addColumn<double>("width");
+ QTest::addColumn<double>("height");
QTest::addColumn<bool>("remote");
QTest::addColumn<bool>("async");
QTest::addColumn<QString>("error");
@@ -136,6 +136,7 @@ void tst_qdeclarativeimage::imageSource_data()
QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << 0.0 << 0.0 << false
<< true << "file::2:1: QML Image: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString();
QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << "";
+ QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << "";
QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << "";
QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true
<< false << "file::2:1: QML Image: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
@@ -145,8 +146,8 @@ void tst_qdeclarativeimage::imageSource_data()
void tst_qdeclarativeimage::imageSource()
{
QFETCH(QString, source);
- QFETCH(qreal, width);
- QFETCH(qreal, height);
+ QFETCH(double, width);
+ QFETCH(double, height);
QFETCH(bool, remote);
QFETCH(bool, async);
QFETCH(QString, error);
@@ -155,6 +156,7 @@ void tst_qdeclarativeimage::imageSource()
if (remote) {
QVERIFY(server.isValid());
server.serveDirectory(SRCDIR "/data");
+ server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
}
if (!error.isEmpty())
@@ -177,8 +179,8 @@ void tst_qdeclarativeimage::imageSource()
if (error.isEmpty()) {
TRY_WAIT(obj->status() == QDeclarativeImage::Ready);
- QCOMPARE(obj->width(), width);
- QCOMPARE(obj->height(), height);
+ QCOMPARE(obj->width(), qreal(width));
+ QCOMPARE(obj->height(), qreal(height));
QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch);
QCOMPARE(obj->progress(), 1.0);
} else {
@@ -276,6 +278,8 @@ void tst_qdeclarativeimage::svg()
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-mac.png"));
#elif defined(Q_OS_WIN32)
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-win32.png"));
+#elif defined(QT_ARCH_ARM)
+ QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-arm.png"));
#else
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png"));
#endif
@@ -290,6 +294,8 @@ void tst_qdeclarativeimage::svg()
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-mac.png"));
#elif defined(Q_OS_WIN32)
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-win32.png"));
+#elif defined(QT_ARCH_ARM)
+ QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-arm.png"));
#else
QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png"));
#endif
diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
index 9d62f22..e0b46f0 100644
--- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
+++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp
@@ -256,9 +256,7 @@ void tst_qdeclarativeimageprovider::requestPixmap_async()
engine.addImageProvider("test", provider);
QVERIFY(engine.imageProvider("test") != 0);
- QTest::ignoreMessage(QtWarningMsg,
- "Pixmaps must be loaded synchronously, ignoring asynchronous property for Image with source: \"image://test/pixmap-async-test.png\"");
-
+ // pixmaps are loaded synchronously regardless of 'asynchronous' value
QString componentStr = "import Qt 4.7\nImage { asynchronous: true; source: \"image://test/pixmap-async-test.png\" }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt
new file mode 100644
index 0000000..3fdac09
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importFile.errors.txt
@@ -0,0 +1 @@
+1:1:"MyComponent.qml": no such directory
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importFile.qml b/tests/auto/declarative/qdeclarativelanguage/data/importFile.qml
new file mode 100644
index 0000000..a0d8410
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/importFile.qml
@@ -0,0 +1,3 @@
+import "MyComponent.qml" 1.0
+
+MyComponent { text: "Hello" }
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt
index 886da55..6e11786 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt
@@ -1,2 +1,2 @@
4:5:Unable to create type NestedErrorsType
-4:8:Invalid property assignment: double expected
+4:8:Invalid property assignment: number expected
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt
index d0a0b00..d2b8c54 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt
@@ -1 +1 @@
-3:19:Invalid property assignment: double expected
+3:19:Invalid property assignment: number expected
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index e687ba0..fcdf926 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -289,6 +289,7 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("importNonExistOlder (installed)") << "importNonExistOlder.qml" << "importNonExistOlder.errors.txt" << false;
QTest::newRow("importNewerVersion (installed)") << "importNewerVersion.qml" << "importNewerVersion.errors.txt" << false;
QTest::newRow("invalidImportID") << "invalidImportID.qml" << "invalidImportID.errors.txt" << false;
+ QTest::newRow("importFile") << "importFile.qml" << "importFile.errors.txt" << false;
QTest::newRow("signal.1") << "signal.1.qml" << "signal.1.errors.txt" << false;
QTest::newRow("signal.2") << "signal.2.qml" << "signal.2.errors.txt" << false;
diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
index 8964f8a..b06ad7c 100644
--- a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
+++ b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp
@@ -124,6 +124,7 @@ QML_DECLARE_TYPE(ValueInterceptorTestType);
{ \
cpptype v = (value); cpptype v2 = (value); \
QVERIFY(QDeclarativeMetaType::copy(QMetaType:: metatype, &v, 0)); \
+ QCOMPARE((cpptype)(v),(cpptype)(defaultvalue)); \
QVERIFY(v == (defaultvalue)); \
QVERIFY(QDeclarativeMetaType::copy(QMetaType:: metatype, &v, &v2)); \
QVERIFY(v == (value)); \
@@ -273,7 +274,7 @@ void tst_qdeclarativemetatype::copy()
QWidget widgetValue;
COPY_TEST(QObject *, QObjectStar, &objectValue, 0);
COPY_TEST(QWidget *, QWidgetStar, &widgetValue, 0);
- COPY_TEST(qreal, QReal, 10.2, 0);
+ COPY_TEST(qreal, QReal, 10.5, 0);
{
QVariant tv = QVariant::fromValue(QVariant(10));
diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow1.qml b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow1.qml
deleted file mode 100644
index 8c9d8ad..0000000
--- a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow1.qml
+++ /dev/null
@@ -1,3 +0,0 @@
-import Qt 4.7
-
-SmoothedFollow {}
diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow2.qml b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow2.qml
deleted file mode 100644
index a634302..0000000
--- a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow2.qml
+++ /dev/null
@@ -1,5 +0,0 @@
-import Qt 4.7
-
-SmoothedFollow {
- to: 10; duration: 300; reversingMode: SmoothedFollow.Immediate
-}
diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow3.qml b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow3.qml
deleted file mode 100644
index c60da7f..0000000
--- a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollow3.qml
+++ /dev/null
@@ -1,6 +0,0 @@
-import Qt 4.7
-
-SmoothedFollow {
- to: 10; velocity: 250; reversingMode: SmoothedFollow.Sync
- maximumEasingTime: 150
-}
diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowDisabled.qml b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowDisabled.qml
deleted file mode 100644
index 486bdee..0000000
--- a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowDisabled.qml
+++ /dev/null
@@ -1,13 +0,0 @@
-import Qt 4.7
-
-Rectangle {
- width: 300; height: 300;
- Rectangle {
- objectName: "theRect"
- color: "red"
- width: 60; height: 60;
- x: 100; y: 100;
- SmoothedFollow on x { id: animX; objectName: "animX"; to: 200; enabled: true; duration: 200 }
- SmoothedFollow on y { id: animY; objectName: "animY"; to: 200; enabled: false; duration: 200 }
- }
-}
diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowValueSource.qml b/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowValueSource.qml
deleted file mode 100644
index 2e01d74..0000000
--- a/tests/auto/declarative/qdeclarativesmoothedfollow/data/smoothedfollowValueSource.qml
+++ /dev/null
@@ -1,13 +0,0 @@
-import Qt 4.7
-
-Rectangle {
- width: 300; height: 300;
- Rectangle {
- objectName: "theRect"
- color: "red"
- width: 60; height: 60;
- x: 100; y: 100;
- SmoothedFollow on x { objectName: "easeX"; to: 200; velocity: 500 }
- SmoothedFollow on y { objectName: "easeY"; to: 200; duration: 250; velocity: 500 }
- }
-}
diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro b/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro
deleted file mode 100644
index dff4922..0000000
--- a/tests/auto/declarative/qdeclarativesmoothedfollow/qdeclarativesmoothedfollow.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
-macx:CONFIG -= app_bundle
-
-SOURCES += tst_qdeclarativesmoothedfollow.cpp
-
-symbian: {
- importFiles.sources = data
- importFiles.path = .
- DEPLOYMENT = importFiles
-} else {
- DEFINES += SRCDIR=\\\"$$PWD\\\"
-}
-
-CONFIG += parallel_test
-
diff --git a/tests/auto/declarative/qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp b/tests/auto/declarative/qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp
deleted file mode 100644
index b9ac23f..0000000
--- a/tests/auto/declarative/qdeclarativesmoothedfollow/tst_qdeclarativesmoothedfollow.cpp
+++ /dev/null
@@ -1,194 +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 test suite 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 <qtest.h>
-#include <QtDeclarative/qdeclarativeengine.h>
-#include <QtDeclarative/qdeclarativecomponent.h>
-#include <QtDeclarative/qdeclarativeview.h>
-
-#include <private/qdeclarativesmoothedfollow_p.h>
-#include <private/qdeclarativerectangle_p.h>
-#include <private/qdeclarativevaluetype_p.h>
-#include "../../../shared/util.h"
-
-#ifdef Q_OS_SYMBIAN
-// In Symbian OS test data is located in applications private dir
-#define SRCDIR "."
-#endif
-
-class tst_qdeclarativesmoothedfollow : public QObject
-{
- Q_OBJECT
-public:
- tst_qdeclarativesmoothedfollow();
-
-private slots:
- void defaultValues();
- void values();
- void disabled();
- void valueSource();
- void followTo();
-
-private:
- QDeclarativeEngine engine;
-};
-
-tst_qdeclarativesmoothedfollow::tst_qdeclarativesmoothedfollow()
-{
-}
-
-void tst_qdeclarativesmoothedfollow::defaultValues()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedfollow1.qml"));
- QDeclarativeSmoothedFollow *obj = qobject_cast<QDeclarativeSmoothedFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 0.);
- QCOMPARE(obj->velocity(), 200.);
- QCOMPARE(obj->duration(), -1);
- QCOMPARE(obj->maximumEasingTime(), -1);
- QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedFollow::Eased);
-
- delete obj;
-}
-
-void tst_qdeclarativesmoothedfollow::values()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedfollow2.qml"));
- QDeclarativeSmoothedFollow *obj = qobject_cast<QDeclarativeSmoothedFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 10.);
- QCOMPARE(obj->velocity(), 200.);
- QCOMPARE(obj->duration(), 300);
- QCOMPARE(obj->maximumEasingTime(), -1);
- QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedFollow::Immediate);
-
- delete obj;
-}
-
-void tst_qdeclarativesmoothedfollow::disabled()
-{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedfollow3.qml"));
- QDeclarativeSmoothedFollow *obj = qobject_cast<QDeclarativeSmoothedFollow*>(c.create());
-
- QVERIFY(obj != 0);
-
- QCOMPARE(obj->to(), 10.);
- QCOMPARE(obj->velocity(), 250.);
- QCOMPARE(obj->maximumEasingTime(), 150);
- QCOMPARE(obj->reversingMode(), QDeclarativeSmoothedFollow::Sync);
-
- delete obj;
-}
-
-void tst_qdeclarativesmoothedfollow::valueSource()
-{
- QDeclarativeEngine engine;
-
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedfollowValueSource.qml"));
-
- QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QVERIFY(rect);
-
- QDeclarativeRectangle *theRect = rect->findChild<QDeclarativeRectangle*>("theRect");
- QVERIFY(theRect);
-
- QDeclarativeSmoothedFollow *easeX = rect->findChild<QDeclarativeSmoothedFollow*>("easeX");
- QVERIFY(easeX);
- QVERIFY(easeX->enabled());
-
- QDeclarativeSmoothedFollow *easeY = rect->findChild<QDeclarativeSmoothedFollow*>("easeY");
- QVERIFY(easeY);
- QVERIFY(easeY->enabled());
-
- // XXX get the proper duration
- QTest::qWait(200);
-
- QTRY_COMPARE(theRect->x(), easeX->to());
- QTRY_COMPARE(theRect->y(), easeY->to());
-
- QTRY_COMPARE(theRect->x(), qreal(200));
- QTRY_COMPARE(theRect->y(), qreal(200));
-}
-
-void tst_qdeclarativesmoothedfollow::followTo()
-{
- QDeclarativeView canvas;
- canvas.setFixedSize(240,320);
-
- canvas.setSource(QUrl::fromLocalFile(SRCDIR "/data/smoothedfollowDisabled.qml"));
- canvas.show();
- canvas.setFocus();
- QVERIFY(canvas.rootObject() != 0);
-
- QDeclarativeRectangle *rect = canvas.rootObject()->findChild<QDeclarativeRectangle*>("theRect");
- QVERIFY(rect != 0);
-
- QDeclarativeSmoothedFollow *animX = canvas.rootObject()->findChild<QDeclarativeSmoothedFollow*>("animX");
- QVERIFY(animX != 0);
- QDeclarativeSmoothedFollow *animY = canvas.rootObject()->findChild<QDeclarativeSmoothedFollow*>("animY");
- QVERIFY(animY != 0);
-
- QVERIFY(animX->enabled());
- QVERIFY(!animY->enabled());
-
- // animX should track 'to'
- animX->setTo(50.0);
- // animY should not track this 'to' change
- animY->setTo(50.0);
-
- // XXX get the proper duration
- QTest::qWait(250);
-
- QTRY_COMPARE(rect->x(), animX->to());
-
- QCOMPARE(rect->x(), 50.0);
- QCOMPARE(rect->y(), 100.0);
-}
-
-QTEST_MAIN(tst_qdeclarativesmoothedfollow)
-
-#include "tst_qdeclarativesmoothedfollow.moc"
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments.qml b/tests/auto/declarative/qdeclarativetext/data/alignments.qml
index b1f701b..762e2b6 100644
--- a/tests/auto/declarative/qdeclarativetext/data/alignments.qml
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments.qml
@@ -20,9 +20,9 @@ Rectangle {
id: t
anchors.fill: parent
- horizontalAlignment: TextEdit.AlignRight
- verticalAlignment: TextEdit.AlignBottom
- wrapMode: TextEdit.WordWrap
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignBottom
+ wrapMode: Text.WordWrap
text: top.txt
}
Timer {
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml
index b1f701b..9281a06 100644
--- a/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml
@@ -16,7 +16,7 @@ Rectangle {
height: 40
color: "green"
- Text {
+ TextEdit {
id: t
anchors.fill: parent
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index 0723b36..57a5e29 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -53,6 +53,7 @@
#include <private/qdeclarativetextedit_p_p.h>
#include <QFontMetrics>
#include <QDeclarativeView>
+#include <QDir>
#include <QStyle>
#include <QInputContext>
#include <private/qapplication_p.h>
@@ -63,6 +64,23 @@
#define SRCDIR "."
#endif
+QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
+{
+ // XXX This will be replaced by some clever persistent platform image store.
+ QString persistent_dir = SRCDIR "/data";
+ QString arch = "unknown-architecture"; // QTest needs to help with this.
+
+ QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png";
+
+ if (!QFile::exists(expectfile)) {
+ actual.save(expectfile);
+ qWarning() << "created" << expectfile;
+ }
+
+ return expectfile;
+}
+
+
class tst_qdeclarativetextedit : public QObject
{
@@ -309,17 +327,17 @@ void tst_qdeclarativetextedit::alignments_data()
QTest::addColumn<int>("vAlign");
QTest::addColumn<QString>("expectfile");
- QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << SRCDIR "/data/alignments_lt.png";
- QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << SRCDIR "/data/alignments_rt.png";
- QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << SRCDIR "/data/alignments_ct.png";
+ QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << "alignments_lt";
+ QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << "alignments_rt";
+ QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << "alignments_ct";
- QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_lb.png";
- QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_rb.png";
- QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_cb.png";
+ QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << "alignments_lb";
+ QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << "alignments_rb";
+ QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << "alignments_cb";
- QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_lc.png";
- QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_rc.png";
- QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_cc.png";
+ QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << "alignments_lc";
+ QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << "alignments_rc";
+ QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << "alignments_cc";
}
@@ -329,13 +347,6 @@ void tst_qdeclarativetextedit::alignments()
QFETCH(int, vAlign);
QFETCH(QString, expectfile);
-#ifdef Q_WS_X11
- // Font-specific, but not likely platform-specific, so only test on one platform
- QFont fn;
- fn.setRawName("-misc-fixed-medium-r-*-*-8-*-*-*-*-*-*-*");
- QApplication::setFont(fn);
-#endif
-
QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.qml");
canvas->show();
@@ -353,14 +364,11 @@ void tst_qdeclarativetextedit::alignments()
QPainter p(&actual);
canvas->render(&p);
+ expectfile = createExpectedFileIfNotFound(expectfile, actual);
+
QImage expect(expectfile);
-#ifdef Q_WS_X11
- // Font-specific, but not likely platform-specific, so only test on one platform
- if (QApplicationPrivate::graphics_system_name == "raster" || QApplicationPrivate::graphics_system_name == "") {
- QCOMPARE(actual,expect);
- }
-#endif
+ QCOMPARE(actual,expect);
}
@@ -846,6 +854,18 @@ void tst_qdeclarativetextedit::navigation()
void tst_qdeclarativetextedit::copyAndPaste() {
#ifndef QT_NO_CLIPBOARD
+
+#ifdef Q_WS_MAC
+ {
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ else
+ QSKIP("This machine doesn't support the clipboard", SkipAll);
+ }
+#endif
+
QString componentStr = "import Qt 4.7\nTextEdit { text: \"Hello world!\" }";
QDeclarativeComponent textEditComponent(&engine);
textEditComponent.setData(componentStr.toLatin1(), QUrl());
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index aceebf3..6e15a4a 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -47,6 +47,7 @@
#include <private/qdeclarativetextinput_p.h>
#include <private/qdeclarativetextinput_p_p.h>
#include <QDebug>
+#include <QDir>
#include <QStyle>
#include <QInputContext>
#include <private/qapplication_p.h>
@@ -56,6 +57,22 @@
#define SRCDIR "."
#endif
+QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
+{
+ // XXX This will be replaced by some clever persistent platform image store.
+ QString persistent_dir = SRCDIR "/data";
+ QString arch = "unknown-architecture"; // QTest needs to help with this.
+
+ QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png";
+
+ if (!QFile::exists(expectfile)) {
+ actual.save(expectfile);
+ qWarning() << "created" << expectfile;
+ }
+
+ return expectfile;
+}
+
class tst_qdeclarativetextinput : public QObject
{
@@ -176,7 +193,8 @@ void tst_qdeclarativetextinput::width()
QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput*>(textinputComponent.create());
QVERIFY(textinputObject != 0);
- QCOMPARE(textinputObject->width(), qreal(metricWidth) + 1.);//1 for the cursor
+ int delta = abs(int(textinputObject->width()) - metricWidth);
+ QVERIFY(delta <= 3.0); // As best as we can hope for cross-platform.
delete textinputObject;
}
@@ -381,9 +399,9 @@ void tst_qdeclarativetextinput::horizontalAlignment_data()
QTest::addColumn<int>("hAlign");
QTest::addColumn<QString>("expectfile");
- QTest::newRow("L") << int(Qt::AlignLeft) << SRCDIR "/data/halign_left.png";
- QTest::newRow("R") << int(Qt::AlignRight) << SRCDIR "/data/halign_right.png";
- QTest::newRow("C") << int(Qt::AlignHCenter) << SRCDIR "/data/halign_center.png";
+ QTest::newRow("L") << int(Qt::AlignLeft) << "halign_left";
+ QTest::newRow("R") << int(Qt::AlignRight) << "halign_right";
+ QTest::newRow("C") << int(Qt::AlignHCenter) << "halign_center";
}
void tst_qdeclarativetextinput::horizontalAlignment()
@@ -391,13 +409,6 @@ void tst_qdeclarativetextinput::horizontalAlignment()
QFETCH(int, hAlign);
QFETCH(QString, expectfile);
-#ifdef Q_WS_X11
- // Font-specific, but not likely platform-specific, so only test on one platform
- QFont fn;
- fn.setRawName("-misc-fixed-medium-r-*-*-8-*-*-*-*-*-*-*");
- QApplication::setFont(fn);
-#endif
-
QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment.qml");
canvas->show();
@@ -409,17 +420,18 @@ void tst_qdeclarativetextinput::horizontalAlignment()
ob->setProperty("horizontalAlignment",hAlign);
QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
actual.fill(qRgb(255,255,255));
- QPainter p(&actual);
- canvas->render(&p);
+ {
+ QPainter p(&actual);
+ canvas->render(&p);
+ }
+
+ expectfile = createExpectedFileIfNotFound(expectfile, actual);
QImage expect(expectfile);
-#ifdef Q_WS_X11
- // Font-specific, but not likely platform-specific, so only test on one platform
- if (QApplicationPrivate::graphics_system_name == "raster" || QApplicationPrivate::graphics_system_name == "") {
- QCOMPARE(actual,expect);
- }
-#endif
+ QCOMPARE(actual,expect);
+
+ delete canvas;
}
void tst_qdeclarativetextinput::positionAt()
@@ -464,11 +476,13 @@ void tst_qdeclarativetextinput::positionAt()
void tst_qdeclarativetextinput::maxLength()
{
- //QString componentStr = "import Qt 4.7\nTextInput { maximumLength: 10; }";
QDeclarativeView *canvas = createView(SRCDIR "/data/maxLength.qml");
+ QVERIFY(canvas->rootObject() != 0);
canvas->show();
canvas->setFocus();
- QVERIFY(canvas->rootObject() != 0);
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+
QDeclarativeTextInput *textinputObject = qobject_cast<QDeclarativeTextInput *>(canvas->rootObject());
QVERIFY(textinputObject != 0);
QVERIFY(textinputObject->text().isEmpty());
@@ -686,6 +700,18 @@ void tst_qdeclarativetextinput::navigation()
void tst_qdeclarativetextinput::copyAndPaste() {
#ifndef QT_NO_CLIPBOARD
+
+#ifdef Q_WS_MAC
+ {
+ PasteboardRef pasteboard;
+ OSStatus status = PasteboardCreate(0, &pasteboard);
+ if (status == noErr)
+ CFRelease(pasteboard);
+ else
+ QSKIP("This machine doesn't support the clipboard", SkipAll);
+ }
+#endif
+
QString componentStr = "import Qt 4.7\nTextInput { text: \"Hello world!\" }";
QDeclarativeComponent textInputComponent(&engine);
textInputComponent.setData(componentStr.toLatin1(), QUrl());
@@ -776,6 +802,9 @@ void tst_qdeclarativetextinput::echoMode()
QDeclarativeView *canvas = createView(SRCDIR "/data/echoMode.qml");
canvas->show();
canvas->setFocus();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
QVERIFY(canvas->rootObject() != 0);
@@ -823,6 +852,7 @@ void tst_qdeclarativetextinput::echoMode()
QCOMPARE(input->text(), QLatin1String("a"));
QCOMPARE(input->displayText(), QLatin1String("a"));
input->setFocus(false);
+ QVERIFY(input->hasActiveFocus() == false);
QCOMPARE(input->displayText(), QLatin1String("Q"));
}
diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
index 81334f2..a4819f3 100644
--- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
+++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp
@@ -141,8 +141,8 @@ void tst_qdeclarativevaluetypes::pointf()
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
- QCOMPARE(object->property("p_x").toDouble(), 11.3);
- QCOMPARE(object->property("p_y").toDouble(), -10.9);
+ QCOMPARE(float(object->property("p_x").toDouble()), float(11.3));
+ QCOMPARE(float(object->property("p_y").toDouble()), float(-10.9));
QCOMPARE(object->property("copy"), QVariant(QPointF(11.3, -10.9)));
delete object;
@@ -191,8 +191,8 @@ void tst_qdeclarativevaluetypes::sizef()
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
- QCOMPARE(object->property("s_width").toDouble(), 0.1);
- QCOMPARE(object->property("s_height").toDouble(), 100923.2);
+ QCOMPARE(float(object->property("s_width").toDouble()), float(0.1));
+ QCOMPARE(float(object->property("s_height").toDouble()), float(100923.2));
QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2)));
delete object;
@@ -287,10 +287,10 @@ void tst_qdeclarativevaluetypes::rectf()
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
- QCOMPARE(object->property("r_x").toDouble(), 103.8);
- QCOMPARE(object->property("r_y").toDouble(), 99.2);
- QCOMPARE(object->property("r_width").toDouble(), 88.1);
- QCOMPARE(object->property("r_height").toDouble(), 77.6);
+ QCOMPARE(float(object->property("r_x").toDouble()), float(103.8));
+ QCOMPARE(float(object->property("r_y").toDouble()), float(99.2));
+ QCOMPARE(float(object->property("r_width").toDouble()), float(88.1));
+ QCOMPARE(float(object->property("r_height").toDouble()), float(77.6));
QCOMPARE(object->property("copy"), QVariant(QRectF(103.8, 99.2, 88.1, 77.6)));
delete object;
diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
index 5344698..de8d222 100644
--- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
+++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
@@ -130,6 +130,8 @@ void tst_QDeclarativeViewer::orientation()
QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300));
QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->size(), viewer->sizeHint());
+
+ delete viewer;
}
void tst_QDeclarativeViewer::loading()
@@ -150,16 +152,16 @@ void tst_QDeclarativeViewer::loading()
TEST_INITIAL_SIZES(viewer);
- viewer->resize(QSize(400, 500));
+ viewer->resize(QSize(250, 350));
qApp->processEvents();
// window resized
- QTRY_COMPARE(rootItem->width(), 400.0);
- QTRY_COMPARE(rootItem->height(), 500.0 - MENUBAR_HEIGHT(viewer));
- QCOMPARE(viewer->view()->size(), QSize(400, 500 - MENUBAR_HEIGHT(viewer)));
+ QTRY_COMPARE(rootItem->width(), 250.0);
+ QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer));
+ QCOMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
- QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500 - MENUBAR_HEIGHT(viewer)));
- QCOMPARE(viewer->size(), QSize(400, 500));
+ QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer)));
+ QCOMPARE(viewer->size(), QSize(250, 350));
QCOMPARE(viewer->size(), viewer->sizeHint());
viewer->reload();
@@ -175,16 +177,16 @@ void tst_QDeclarativeViewer::loading()
QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->size(), viewer->sizeHint());
- viewer->resize(QSize(400, 500));
+ viewer->resize(QSize(250, 350));
qApp->processEvents();
// window resized again
- QTRY_COMPARE(rootItem->width(), 400.0);
- QTRY_COMPARE(rootItem->height(), 500.0 - MENUBAR_HEIGHT(viewer));
- QCOMPARE(viewer->view()->size(), QSize(400, 500 - MENUBAR_HEIGHT(viewer)));
+ QTRY_COMPARE(rootItem->width(), 250.0);
+ QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer));
+ QCOMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
- QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(400, 500 - MENUBAR_HEIGHT(viewer)));
- QCOMPARE(viewer->size(), QSize(400, 500));
+ QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer)));
+ QCOMPARE(viewer->size(), QSize(250, 350));
QCOMPARE(viewer->size(), viewer->sizeHint());
viewer->open(SRCDIR "/data/orientation.qml");
@@ -199,6 +201,8 @@ void tst_QDeclarativeViewer::loading()
QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300));
QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->size(), viewer->sizeHint());
+
+ delete viewer;
}
void tst_QDeclarativeViewer::fileBrowser()
@@ -233,6 +237,8 @@ void tst_QDeclarativeViewer::fileBrowser()
QVERIFY(viewer->view());
QVERIFY(viewer->menuBar());
QVERIFY(browserItem);
+
+ delete viewer;
}
void tst_QDeclarativeViewer::resizing()
@@ -288,6 +294,8 @@ void tst_QDeclarativeViewer::resizing()
rootItem->setWidth(150);
rootItem->setHeight(200);
QTRY_COMPARE(viewer->size(), QSize(250, 350));
+
+ delete viewer;
}
void tst_QDeclarativeViewer::paths()
@@ -300,6 +308,8 @@ void tst_QDeclarativeViewer::paths()
viewer->addPluginPath("miscPluginPath");
viewer->view()->engine()->pluginPathList().contains("miscPluginPath");
+
+ delete viewer;
}
void tst_QDeclarativeViewer::slowMode()
@@ -309,6 +319,8 @@ void tst_QDeclarativeViewer::slowMode()
viewer->setSlowMode(true);
viewer->setSlowMode(false);
+
+ delete viewer;
}
QTEST_MAIN(tst_QDeclarativeViewer)
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
index 8e98874..3140265 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
+++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
@@ -134,7 +134,7 @@ void tst_QDeclarativeWorkerScript::messaging_data()
QTest::newRow("invalid") << QVariant();
QTest::newRow("bool") << qVariantFromValue(true);
QTest::newRow("int") << qVariantFromValue(1001);
- QTest::newRow("real") << qVariantFromValue(10334.323);
+ QTest::newRow("real") << qVariantFromValue(10334.375);
QTest::newRow("string") << qVariantFromValue(QString("More cheeeese, Gromit!"));
QTest::newRow("variant list") << qVariantFromValue((QVariantList() << "a" << "b" << "c"));
}
diff --git a/tests/auto/declarative/qmlvisual/focusscope/test.qml b/tests/auto/declarative/qmlvisual/focusscope/test.qml
index d83bad4..24b4b99 100644
--- a/tests/auto/declarative/qmlvisual/focusscope/test.qml
+++ b/tests/auto/declarative/qmlvisual/focusscope/test.qml
@@ -19,14 +19,14 @@ Rectangle {
color: "transparent"
border.width: 5
- border.color: myScope.wantsFocus?"blue":"black"
+ border.color: myScope.activeFocus?"blue":"black"
Rectangle {
id: item1
x: 10; y: 10
width: 100; height: 100; color: "green"
border.width: 5
- border.color: wantsFocus?"blue":"black"
+ border.color: activeFocus?"blue":"black"
Keys.onDigit9Pressed: console.log("Top Left");
KeyNavigation.right: item2
focus: true
@@ -42,7 +42,7 @@ Rectangle {
x: 310; y: 10
width: 100; height: 100; color: "green"
border.width: 5
- border.color: wantsFocus?"blue":"black"
+ border.color: activeFocus?"blue":"black"
KeyNavigation.left: item1
Keys.onDigit9Pressed: console.log("Top Right");
@@ -62,7 +62,7 @@ Rectangle {
x: 10; y: 300
width: 100; height: 100; color: "green"
border.width: 5
- border.color: wantsFocus?"blue":"black"
+ border.color: activeFocus?"blue":"black"
Keys.onDigit9Pressed: console.log("Bottom Left");
KeyNavigation.up: myScope
diff --git a/tests/auto/declarative/qmlvisual/focusscope/test2.qml b/tests/auto/declarative/qmlvisual/focusscope/test2.qml
index 7a6ed83..19c8bed 100644
--- a/tests/auto/declarative/qmlvisual/focusscope/test2.qml
+++ b/tests/auto/declarative/qmlvisual/focusscope/test2.qml
@@ -10,27 +10,27 @@ Rectangle {
FocusScope {
y: 100
focus: true
- Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+ Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
FocusScope {
y: 100
focus: true
- Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+ Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
FocusScope {
y: 100
focus: true
- Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+ Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
FocusScope {
y: 100
focus: true
- Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+ Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
FocusScope {
y: 100
focus: true
- Rectangle { width: 50; height: 50; color: parent.wantsFocus?"red":"blue" }
+ Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" }
}
}
}
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml
index 7ca0ca5..0df727b 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativesmoothedanimation/smoothedfollow.qml
@@ -14,27 +14,27 @@ Rectangle {
}
Rectangle {
- width: 50; height: 20; y: 60; color: "red"
- SmoothedFollow on x { to: rect.x; velocity: 400; enabled: true }
+ width: 50; height: 20; x: rect.x; y: 60; color: "red"
+ Behavior on x { SmoothedAnimation { velocity: 400 } }
}
Rectangle {
- width: 50; height: 20; y: 90; color: "yellow"
- SmoothedFollow on x { to: rect.x; velocity: 300; reversingMode: SmoothedAnimation.Immediate; enabled: true }
+ width: 50; height: 20; x: rect.x; y: 90; color: "yellow"
+ Behavior on x { SmoothedAnimation { velocity: 300; reversingMode: SmoothedAnimation.Immediate } }
}
Rectangle {
- width: 50; height: 20; y: 120; color: "green"
- SmoothedFollow on x { to: rect.x; reversingMode: SmoothedAnimation.Sync; enabled: true }
+ width: 50; height: 20; x: rect.x; y: 120; color: "green"
+ Behavior on x { SmoothedAnimation { reversingMode: SmoothedAnimation.Sync } }
}
Rectangle {
- width: 50; height: 20; y: 150; color: "purple"
- SmoothedFollow on x { to: rect.x; maximumEasingTime: 200; enabled: true }
+ width: 50; height: 20; x: rect.x; y: 150; color: "purple"
+ Behavior on x { SmoothedAnimation { maximumEasingTime: 200 } }
}
Rectangle {
- width: 50; height: 20; y: 180; color: "blue"
- SmoothedFollow on x { to: rect.x; duration: 300; enabled: true }
+ width: 50; height: 20; x: rect.x; y: 180; color: "blue"
+ Behavior on x { SmoothedAnimation { duration: 300 } }
}
}
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml
index d981763..c64497a 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml
@@ -22,10 +22,11 @@ Rectangle {
smooth: true
transform: Rotation {
id: hourRotation
- origin.x: 7.5; origin.y: 73; angle: 0
- SpringFollow on angle {
- spring: 2; damping: 0.2; modulus: 360
- to: (clock.hours * 30) + (clock.minutes * 0.5)
+ origin.x: 7.5; origin.y: 73
+ angle: (clock.hours * 30) + (clock.minutes * 0.5)
+
+ Behavior on angle {
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
}
}
}
@@ -36,10 +37,11 @@ Rectangle {
smooth: true
transform: Rotation {
id: minuteRotation
- origin.x: 6.5; origin.y: 83; angle: 0
- SpringFollow on angle {
- spring: 2; damping: 0.2; modulus: 360
- to: clock.minutes * 6
+ origin.x: 6.5; origin.y: 83
+ angle: clock.minutes * 6
+
+ Behavior on angle {
+ SpringAnimation { spring: 2; damping: 0.2; modulus: 360 }
}
}
}
@@ -50,10 +52,11 @@ Rectangle {
smooth: true
transform: Rotation {
id: secondRotation
- origin.x: 2.5; origin.y: 80; angle: 0
- SpringFollow on angle {
- spring: 5; damping: 0.25; modulus: 360
- to: clock.seconds * 6
+ origin.x: 2.5; origin.y: 80
+ angle: clock.seconds * 6
+
+ Behavior on angle {
+ SpringAnimation { spring: 5; damping: 0.25; modulus: 360 }
}
}
}
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml
index cabdce7..05b93df 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml
@@ -3,6 +3,7 @@ import Qt 4.7
Rectangle {
color: "#ffffff"
width: 320; height: 240
+
Rectangle {
id: rect
color: "#00ff00"
@@ -25,22 +26,22 @@ Rectangle {
Rectangle {
color: "#ff0000"
x: rect.width; width: rect.width; height: 20
- y: 200
- SpringFollow on y { to: rect.y; velocity: 200 }
+ y: rect.y
+ Behavior on y { SpringAnimation { velocity: 200 } }
}
// Spring
Rectangle {
color: "#ff0000"
x: rect.width * 2; width: rect.width/2; height: 20
- y: 200
- SpringFollow on y { to: rect.y; spring: 1.0; damping: 0.2 }
+ y: rect.y
+ Behavior on y { SpringAnimation { spring: 1.0; damping: 0.2 } }
}
Rectangle {
color: "#880000"
x: rect.width * 2.5; width: rect.width/2; height: 20
- y: 200
- SpringFollow on y { to: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
+ y: rect.y
+ Behavior on y { SpringAnimation { spring: 1.0; damping: 0.2; mass: 3.0 } } // "heavier" object
}
// Follow mouse
@@ -49,15 +50,22 @@ Rectangle {
anchors.fill: parent
Rectangle {
id: ball
+ property int targetX: mouseRegion.mouseX - 10
+ property int targetY: mouseRegion.mouseY - 10
+
+ x: targetX
+ y: targetY
width: 20; height: 20
radius: 10
color: "#0000ff"
- SpringFollow on x { id: f1; to: mouseRegion.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
- SpringFollow on y { id: f2; to: mouseRegion.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+
+ Behavior on x { SpringAnimation { spring: 1.0; damping: 0.05; epsilon: 0.25 } }
+ Behavior on y { SpringAnimation { spring: 1.0; damping: 0.05; epsilon: 0.25 } }
+
states: [
State {
name: "following"
- when: !f1.inSync || !f2.inSync
+ when: ball.x != ball.targetX || ball.y != ball.targetY
PropertyChanges { target: ball; color: "#ff0000" }
}
]
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 6461b67..4b1162e 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -49,6 +49,7 @@
#include <QTranslator>
#include <QDebug>
#include <QMessageBox>
+#include <QAtomicInt>
#include "qdeclarativetester.h"
QT_USE_NAMESPACE
@@ -91,19 +92,25 @@ void showWarnings()
}
}
+static QAtomicInt recursiveLock(0);
+
void myMessageOutput(QtMsgType type, const char *msg)
{
- if (!logger.isNull()) {
- QString strMsg = QString::fromAscii(msg);
- QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg));
+ QString strMsg = QString::fromLatin1(msg);
+
+ if (!logger.isNull() && !QCoreApplication::closingDown()) {
+ if (recursiveLock.testAndSetOrdered(0, 1)) {
+ QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg));
+ recursiveLock = 0;
+ }
} else {
- warnings += msg;
+ warnings += strMsg;
warnings += QLatin1Char('\n');
}
if (systemMsgOutput) { // Windows
systemMsgOutput(type, msg);
} else { // Unix
- fprintf(stderr, "%s\n",msg);
+ fprintf(stderr, "%s\n", msg);
fflush(stderr);
}
}